kdf: version Argon2id profiles and raise the default to 64 MiB / t=3
The store and identity backup shared one hard-coded Argon2id profile
(m=19456 KiB, t=2, p=1) with nothing recorded on disk, so changing it
would have bricked every existing store and backup.
Record the profile with the data and raise the default:
- KdfProfile { Legacy = 0, Current = 1 }; Current is m=65536 KiB,
t=3, p=1, out=32.
- Backups: seal() writes a profile byte after owbak1. Legacy blobs
(exactly SEALED_BODY_LEN after MAGIC) still open; an unknown id is
an error, never a fallback.
- Stores: store_meta gains kdf_profile (additive, default 0). The
SQLCipher file key has no place to record a profile before the db
opens, so a legacy file is detected by trial-opening with the
legacy profile, then rekeyed to Current in one SQLCipher
transaction; store_meta is re-wrapped (salt + ciphertext + profile)
in a single transaction on the first successful unlock. Both are
one-shot: the next start takes the current path.
- docs/THREAT_MODEL.md states the new params and the versioning.
Measured in release on this host: kdf legacy 0.018s / current 0.095s;
Store reopen current 0.354s, legacy upgrade path 0.528s.
This commit is contained in:
parent
36969a7e95
commit
8f959e937f
3 changed files with 460 additions and 32 deletions
|
|
@ -59,9 +59,18 @@ What this does **not** buy:
|
|||
## Your store is encrypted
|
||||
|
||||
The sqlite store is SQLCipher (`rusqlite` feature `bundled-sqlcipher-vendored-openssl`).
|
||||
A 32-byte key is derived from the store passphrase with Argon2id (same params as
|
||||
identity backup) over a per-install 16-byte salt in `store_salt`, and handed to
|
||||
SQLCipher as a **raw** key (`PRAGMA key = "x'…'"`) — no second KDF pass over it.
|
||||
A 32-byte key is derived from the store passphrase with Argon2id — m =
|
||||
65_536 KiB (64 MiB), t = 3, p = 1, out = 32 — over a per-install 16-byte salt
|
||||
in `store_salt`, and handed to SQLCipher as a **raw** key (`PRAGMA key =
|
||||
"x'…'"`) — no second KDF pass over it. The identity backup and the
|
||||
message-key wrap in `store_meta` use the same profile. Parameters are
|
||||
versioned with the data: a backup blob names its profile in the header and
|
||||
`store_meta.kdf_profile` names the store's, and an unknown profile id is a
|
||||
clear error, never a silent fallback. Data written with the earlier
|
||||
19_456 KiB / t=2 / p=1 profile still opens: a legacy store is rekeyed and its
|
||||
message key re-wrapped with the current profile on the first successful
|
||||
unlock, and a legacy backup file opens as-is (re-exporting it writes the
|
||||
current profile).
|
||||
The key is the first statement after open, so the file header, schema, identity
|
||||
secret key, friend public keys, locators, profiles, payment rows and the
|
||||
per-friend ratchet session blobs (`ratchet_sessions`) are all ciphertext on
|
||||
|
|
|
|||
Loading…
Reference in a new issue