Offers and answers now go through the HC1 codec: the sender creates a ref per session and the answer must echo it, so pasting an offer as the answer or an answer for another code is rejected with a specific message while the live offer stays usable. Pasted input may be a full link. webrtc.ts drops its Base64 JSON signaling and exchanges validated SDP only; identity hellos travel in the code envelope. Tests, the browser check, compare-ice and the docs follow the new format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
5.0 KiB
Markdown
89 lines
5.0 KiB
Markdown
# Remembered-device protocol and storage
|
|
|
|
Phase 3 adds optional hosted-browser identities. Temporary sessions still use
|
|
manual fingerprint comparison.
|
|
This is an application protocol design and implementation review, not an
|
|
independent cryptographic audit.
|
|
|
|
## Authentication transcript
|
|
|
|
A device has an ECDSA P-256 key pair. An identity-enabled connection code
|
|
(see `src/lib/codes.ts` for the `HC1.` encoding) uses signaling envelope
|
|
version 4 with a public key (65-byte uncompressed point, lowercase hex) and a
|
|
fresh 32-byte cryptographically random nonce. Both local
|
|
and remote SDP fingerprints continue to be validated as full SHA-256 values.
|
|
Temporary codes use version 3. Old builds reject version 4 before connecting.
|
|
Current builds accept both; if either participant uses a temporary identity,
|
|
both must manually verify fingerprints and no device is remembered.
|
|
|
|
When both codes advertise identities, each FileSession ready frame includes an
|
|
ECDSA/SHA-256 signature. The signed UTF-8 bytes are JSON.stringify of this ordered
|
|
array, with no optional fields:
|
|
|
|
```
|
|
["HellCon device proof", 1, 4, role,
|
|
offerPublicKey, offerNonce, answerPublicKey, answerNonce,
|
|
offerFingerprint, answerFingerprint]
|
|
```
|
|
|
|
The role is `offerer` or `answerer`. Fingerprints are uppercase hex bytes separated
|
|
by one space. Signatures use Web Crypto's 64-byte P1363 encoding, lowercase hex.
|
|
The recipient verifies the other role with the other public key. Both keys,
|
|
both fresh nonces, and both DTLS certificate fingerprints are bound to the proof.
|
|
Roles and domain/version separation prevent reflection and cross-protocol use;
|
|
fresh contributions from both peers prevent replay into a new connection.
|
|
The signed fingerprints bind the identity to the encrypted transport. A proof
|
|
from another connection cannot authenticate an attacker-controlled DTLS peer.
|
|
|
|
Each connection opts in separately and trusts at most one public key, its paired
|
|
device. A local user either compares both full fingerprints or connects on a
|
|
paired connection. A connection name has no protocol meaning. A matching paired
|
|
key permits local verification to proceed automatically, but metadata and file
|
|
data stay gated until the peer's fresh signature verifies. Unknown, changed,
|
|
missing, or downgraded identities require manual fingerprint comparison.
|
|
A changed key never replaces a paired device automatically: replacing it is an
|
|
explicit, unticked choice on the verification step. An invalid or missing
|
|
signature in a negotiated identity session closes the session. Each file still
|
|
requires acceptance. The session receive queue is bounded to 2 MiB while signature
|
|
verification is pending and throughout transfers; the existing 1 MiB send windows
|
|
remain unchanged.
|
|
|
|
A peer key is only saved to a connection after both peers' ready frames pass
|
|
verification, and only if the user left **Remember this device** ticked on the
|
|
verification step. Manual first pairing therefore authenticates the keys through
|
|
the compared transport fingerprints and proofs. Public identities in codes are
|
|
linkable; the UI makes this explicit before opt-in. No identities or connection
|
|
names are added to diagnostic logs, and connection names are not sent to peers.
|
|
|
|
## Storage and recovery
|
|
|
|
The `hellcon-devices` IndexedDB store holds one CryptoKey private key and its
|
|
public key, shared by all connections. Each record in `hellcon-connections`
|
|
holds its own opt-in flag and paired public key. New private keys are
|
|
non-extractable; existing stored keys remain usable.
|
|
Browser storage does not protect against compromised app code, a hostile host,
|
|
or compromised browser: app code can still use a stored key to sign.
|
|
New connections are not opted in. Creating an identity opts in the connection it
|
|
was created from. Clearing site data loses the identity and pairings; an empty
|
|
store never creates trust automatically. Storage errors leave temporary sessions
|
|
available. Unreadable identity storage can be explicitly cleared before creating
|
|
a new identity and pairing again. Atomic revision checks reject stale identity
|
|
writes from other tabs; connection records are read and written in single
|
|
transactions. Identity deletion requires explicit consent, keeps paired devices,
|
|
and is disabled during a session. Removing a connection forgets its device.
|
|
Before each identity-enabled connection, the connection record and identity are
|
|
read again from storage. A device forgotten in another tab loses automatic
|
|
verification on the next connection, and a replaced local identity is picked up.
|
|
A failed refresh stops setup instead of using cached trust.
|
|
|
|
There is no central revocation service. Peers must forget a compromised key.
|
|
|
|
Review checks: both role directions, substitution of either identity, alteration
|
|
of either nonce or fingerprint, forged signatures, replay into fresh contexts,
|
|
metadata gating during asynchronous verification, non-extractable private keys,
|
|
and persistence/reconnection with real browser CryptoKeys. These
|
|
checks do not replace an independent protocol review.
|
|
|
|
Web Crypto algorithm and key-storage reference:
|
|
https://www.w3.org/TR/WebCryptoAPI/
|