Hash Lab

Password hashing / KDF

HKDF

HMAC-based Extract-and-Expand Key Derivation Function, by Hugo Krawczyk (CRYPTO 2010, RFC 5869). HKDF is the modern default fornon-passwordkey derivation: TLS 1.3, Signal, Noise, Tor, QUIC, WireGuard, and libsodium’s kdf module all use it.

At a glance

OutputUp to 255 · hashLen bytes per call
Inputsinput key material (IKM), optional salt, optional “info” context
ConstructionExtract (HMAC over IKM with salt as key) then Expand (HMAC chain)
Internal primitiveHMAC over any cryptographic hash (typically SHA-256 / SHA-512)
StandardRFC 5869
StatusModern, recommended

HKDF is NOT for passwords

HKDF runs in microseconds. It assumes the input key material already has high entropy (a Diffie-Hellman shared secret, a random session key). For deriving keys from passwords, use Argon2id, scrypt, or PBKDF2.

The two stages

  1. Extract: PRK = HMAC(salt, IKM). Concentrates IKM entropy into a fixed-length PRK. Random salt makes HKDF a strong randomness extractor.
  2. Expand: produce as many output bytes as needed by chaining HMACs. Each block T(i) = HMAC(PRK, T(i-1) ∥ info ∥ i).

The info field, domain separation

Reusing the same PRK for multiple keys is fine as long as info differs. Always include protocol name, version, and key purpose in info.

Where it is used

References

Generate

Run hkdf on your input

16 bytes

32

Quick quiz

Test yourself on hkdf

10 multiple-choice questions. Pick an answer for each, then submit to see explanations.

  1. Q1.Designer of HKDF:

  2. Q2.RFC:

  3. Q3.HKDF construction:

  4. Q4.Is HKDF appropriate for passwords?

  5. Q5.What is the info field used for?

  6. Q6.Which protocol's key schedule is HKDF?

  7. Q7.libsodium's crypto_kdf uses:

  8. Q8.Max output of a single HKDF call:

  9. Q9.Extract step:

  10. Q10.Which protocol does NOT use HKDF?

0 of 10 answered