Keys and encryption

The two keys made from the link, what each one locks, and how every piece of the file is encrypted and checked.

Keys

Two keys

Two keys are derived from the secret with HKDF-SHA-256. Both are AES-256-GCM keys that the browser marks as non-extractable: the page can use them, but can't read them out.

The signal key

The signal key encrypts the setup messages. Its salt is the link ID.

The file key

The file key encrypts every frame between the two ends except the first, INIT, which carries only the random transfer ID. The file key's salt is made of two random values: that transfer ID, which the sender picks for every attempt, and an attempt ID that the recipient's page picks for every new connection. So neither a retried transfer nor a replayed first frame ever reuses a key and nonce pair.

Two layers of encryption

Two layers

WebRTC encrypts the connection between the two ends with DTLS. Fidant doesn't rely on that alone: every frame after INIT is also encrypted with AES-256-GCM under the file key, which only the two ends have.

Frames and nonces

Each frame starts with a 10-byte header with its version, kind and sequence number. The header is authenticated with the frame, and the nonce is built from the direction and the sequence number, so the two directions never share a nonce. A browser accepts only the next sequence number, so a dropped, reordered, repeated or altered frame stops the transfer.