Skip to main content

Module pwkdf

Module pwkdf 

Source
Expand description

Password-based key wrapping: Argon2id derives a wrapping key from a passphrase / recovery code, which then seals a secret under AES-256-GCM. Used for the master-key escrow and backup wrap key (SSoT: Cryptography — Primitives § Password-based KDF).

Argon2id runs only at account recovery and device bootstrap — never on a hot path. The cost parameters are recorded inside the wrapped blob, so a desktop-wrapped blob unwraps correctly on a phone (slowly) and vice versa, and parameters can be raised over time without a flag day.

Structs§

WrappedSecret
A secret sealed under a passphrase-derived key, self-describing for unwrap.

Functions§

derive_wrap_key
Derive a 32-byte wrapping key from a passphrase and salt via Argon2id. Exposed so the backup artifact can use one passphrase-derived key for both its MANIFEST HMAC and its AMK-ledger seal (SSoT: Backup — Master-Key Escrow).
unwrap
Unwrap a WrappedSecret, re-deriving the wrapping key from the in-band parameters. Returns CryptoError::Auth on a wrong passphrase or a corrupt/tampered blob.
wrap
Wrap secret under passphrase using the canonical parameters for tier.
wrap_with
Wrap secret under passphrase with explicit Argon2id parameters (recorded in-band).