Skip to main content

Module kdf

Module kdf 

Source
Expand description

Shared guards for key derivation from untrusted inputs. Guards for Argon2 parameters read from untrusted file headers.

Every code path that derives a key from header-supplied parameters (decryption and listing alike) must validate them here first, so a crafted .shadow file cannot request an enormous allocation or an excessive amount of CPU time.

Constants§

KDF_MEMORY_BUDGET_KIB
Total Argon2 buffer memory allowed across all concurrent derivations.
MAX_KDF_ITERATIONS
MAX_KDF_KEY_SIZE
MAX_KDF_MEMORY_KIB
Upper bounds for KDF parameters read from untrusted file headers. These prevent a crafted file from causing OOM or excessive CPU use.
MAX_KDF_PARALLELISM

Functions§

derive_untrusted_key
Derives a parsed file’s key from a password, guarding the (untrusted) KDF parameters its header requests.
validate_kdf_request
Validates the KDF parameters a file header requests, against the bounds above. The request is version-agnostic, so every format version passes through the same checks.
with_kdf_memory_permit
Runs f (a key derivation) while holding a reservation of cost_kib against the global memory budget, blocking until enough budget is free.