Expand description
Master-key derivation for at-rest encryption.
On launch the user enters a master passphrase. We combine it with a per-installation salt (kept in the data dir, unencrypted — its only job is to make rainbow-table attacks unreasonable) and feed both into Argon2id to derive a 32-byte master key. That key is used for:
PRAGMA keyon the SQLCipher connection- HKDF input for the Megolm session-persistence key (replaces the hardcoded all-zero key from Phase 1)
Constants§
Functions§
- derive_
master_ key - Derive a 32-byte master key from passphrase + salt via Argon2id.
Parameters follow the strong RFC 9106 / OWASP profile (64 MiB memory,
3 iterations, 4 lanes) and must stay in sync with the room-passphrase
KDF in
crypto::passphrase::derive_key. - derive_
subkey - Return a 32-byte subkey for
purpose(e.g. “megolm-persist”) derived from the master key via HKDF-SHA256. The master key is the input key material andpurposeis the HKDFinfoparameter — proper domain separation, no ad-hoc separator ambiguity. - keychain_
salt_ path - Returns the path holding the keychain salt. The salt is not secret; only the passphrase is.
- load_
or_ create_ salt - Load the keychain salt, generating + persisting it on first launch.