[share] Share links and the browser build (v0.3.0) #5

Manually merged
mnovak merged 1 commits from feature/share-wasm into main 2026-10-31 18:31:54 +01:00
Owner

Day 2 core: private share links and the browser build of the core (v0.3.0).

What

  • docs/SHARE.md (written first): the link, https://host/s/<id>#k=<key>[&p=1], and the blob format.
    • Blob: CSH1, flags, then for password shares Argon2id parameters and a salt, then the nonce and the XChaCha20-Poly1305 ciphertext. The AAD is everything before the ciphertext.
    • Keys: no password → the 32-byte link key is the message key. With a password → HKDF-SHA256(link key ‖ Argon2id(password)), so both are needed.
    • Limits: KDF parameters are checked before Argon2 runs; a blob is at most 64 KiB.
  • custos-share:
    • seal / open.
    • Payload::from_item leaves out empty fields, the TOTP seed and auto-type settings.
    • Errors carry no secrets.
    • Sealed prints its fragment as [redacted] and zeroes it on drop.
  • custos-wasm: the web vault's and the share page's crypto, compiled to wasm32-unknown-unknown.
    • No wasm-bindgen. A JSON call export plus alloc/dealloc; dealloc zeroes memory.
    • One import, random_fill, backed by crypto.getRandomValues through getrandom's custom backend (.cargo/config.toml).
    • Operations: open, lock, items, reveal, totp, qr (SVG), share_seal, share_open.
    • js/custos.mjs (about 50 lines) is the whole JS side.
  • Threat model: rows for the share server operator, link holders and preview bots. Also the honest caveat that the web vault trusts the server that serves its code, and that browser memory cannot be wiped.

Self-review / tests

  • cargo test --workspace --release: 54 passed (gen 16, share 11, vault 11, totp 5, qr 5, wasm 4, doctests 2).
  • The mandatory Day 2 tests in this repo:
    • 5, tamper: every single-byte flip, truncation, extension and wrong key fails with DecryptFailed, Malformed or PasswordRequired, never garbage. The message holds no secret.
    • 6, password: a wrong or empty password fails; the right one works. The link alone (with p=1 removed) and the password alone (with another link key) both fail.
  • Built for wasm32 with the server's nixpkgs toolchain (rustc 1.94.1, lld): 590 KB; its only import is env.random_fill.
  • Node (V8) run of js/test.mjs against a real vault with the default KDF:
    • unlock in 0.92 s;
    • share seal + open 5 ms, or 49 ms with a password;
    • 100 link keys all distinct, so the RNG import works.
  • Also tested in the browser through the private app's web pages, under a CSP with only 'wasm-unsafe-eval' added.
Day 2 core: private share links and the browser build of the core (v0.3.0). **What** - `docs/SHARE.md` (written first): the link, `https://host/s/<id>#k=<key>[&p=1]`, and the blob format. - Blob: `CSH1`, flags, then for password shares Argon2id parameters and a salt, then the nonce and the XChaCha20-Poly1305 ciphertext. The AAD is everything before the ciphertext. - Keys: no password → the 32-byte link key is the message key. With a password → HKDF-SHA256(link key ‖ Argon2id(password)), so both are needed. - Limits: KDF parameters are checked before Argon2 runs; a blob is at most 64 KiB. - `custos-share`: - `seal` / `open`. - `Payload::from_item` leaves out empty fields, the TOTP seed and auto-type settings. - Errors carry no secrets. - `Sealed` prints its fragment as `[redacted]` and zeroes it on drop. - `custos-wasm`: the web vault's and the share page's crypto, compiled to `wasm32-unknown-unknown`. - No wasm-bindgen. A JSON `call` export plus `alloc`/`dealloc`; `dealloc` zeroes memory. - One import, `random_fill`, backed by `crypto.getRandomValues` through getrandom's custom backend (`.cargo/config.toml`). - Operations: open, lock, items, reveal, totp, qr (SVG), share_seal, share_open. - `js/custos.mjs` (about 50 lines) is the whole JS side. - Threat model: rows for the share server operator, link holders and preview bots. Also the honest caveat that **the web vault trusts the server that serves its code**, and that browser memory cannot be wiped. **Self-review / tests** - `cargo test --workspace --release`: **54 passed** (gen 16, share 11, vault 11, totp 5, qr 5, wasm 4, doctests 2). - The mandatory Day 2 tests in this repo: - **5, tamper**: every single-byte flip, truncation, extension and wrong key fails with `DecryptFailed`, `Malformed` or `PasswordRequired`, never garbage. The message holds no secret. - **6, password**: a wrong or empty password fails; the right one works. The link alone (with `p=1` removed) and the password alone (with another link key) both fail. - Built for wasm32 with the server's nixpkgs toolchain (rustc 1.94.1, lld): 590 KB; its only import is `env.random_fill`. - Node (V8) run of `js/test.mjs` against a real vault with the default KDF: - unlock in 0.92 s; - share seal + open 5 ms, or 49 ms with a password; - 100 link keys all distinct, so the RNG import works. - Also tested in the browser through the private app's web pages, under a CSP with only `'wasm-unsafe-eval'` added.
mnovak added 1 commit 2026-10-31 18:31:43 +01:00
mnovak manually merged commit e3128b35aa into main 2026-10-31 18:31:54 +01:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/CustosPublic#5