aeat.adapters.persistence.storage.master_key._kdf module¶
Argon2id KEK derivation for the per-bucket unlock pipeline.
The substrate derives every passphrase-bound key-encryption key via Argon2id at the OWASP 2024 baseline parameters declared by KdfParams.default(). The on-disk manifest carries the parameter set the bucket was enrolled under so a future cost-bump is non-breaking; this helper consumes whatever ManifestKdfParams the manifest supplies and routes it through the existing argon2-cffi dependency.
The helper is a thin typed wrapper. It does not maintain caches or module-global state; the unlock pipeline owns the resulting bytes through a BucketSession.
- derive_kek(passphrase, kdf_params)[source]¶
Derive a 32-byte KEK from passphrase and the manifest’s kdf_params.
- Parameters:
passphrase (
bytes) – Operator passphrase encoded to bytes by the caller.kdf_params (
ManifestKdfParams) – Manifest-side KDF record carrying algorithm, parameter version, the Argon2id cost parameters, the salt, and the requested output length.
- Return type:
- Returns:
Exactly 32 bytes of Argon2id output suitable for AES-256-GCM wrapping of the bucket’s data-encryption key.
- Raises:
KeyDerivationError – If kdf_params.algorithm is not argon2id or kdf_params.output_length is not 32.