Key derivation
Derive keys from shared secrets or other keying material.
Select an algorithm and call derive (for KBKDF, the mode method) with the secret as the only positional
argument. All other parameters are keyword-only. Output lengths are checked
against the limit of each standard and raise ValueError when out of range.
These functions expect high-entropy input such as a Diffie-Hellman shared secret. Use the password hashing family for passwords.
Algorithms
- HKDF Extract-and-expand KDF (RFC 5869) over every fixed-output hash in
oxcrypto.hash. - ANSI X9.63 KDF Hash-based KDF from ANSI X9.63 and SEC 1 with SHA-1, SHA-2 or SHA-3.
- One-step KDF Hash-based one-step KDF from NIST SP 800-56C with SHA-1, SHA-2 or SHA-3.
- bake-kdf and belt-keyrep Belarusian KDF and key transformation from STB 34.101.66 and STB 34.101.31.
- KBKDF Key-based KDF from NIST SP 800-108 in counter, feedback and double-pipeline modes with HMAC or CMAC-AES.
Zeroization
Every KDF crate here currently leaves some intermediate blocks unwiped. Each
algorithm page identifies the affected intermediate values. oxcrypto enables the zeroize feature of the hash, HMAC,
CMAC and AES crates, which are written to wipe their states on drop; oxcrypto has
not verified this independently.
Zeroization stops at the Python boundary. The Python bytes you pass in (secrets,
salts, keys) and the derived keys returned are immutable and are not wiped, and
Python may keep copies of them.