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_key_from_untrusted_params
Derives a key from KDF parameters read out of an untrusted file header.
validate_untrusted_kdf_params
Validates KDF parameters taken from an untrusted file header.
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.