KDF family

HKDF

HMAC-based extract-and-expand key derivation function (RFC 5869)

standard 4 variants RFC 5869; NIST SP 800-56C

Overview

HKDF derives one or more strong cryptographic keys from input keying material such as a Diffie-Hellman shared secret. It is the standard KDF in TLS 1.3, HPKE, Signal, QUIC and many other protocols.

HKDF splits key derivation into two stages. Extract compresses possibly non-uniform input keying material, together with an optional salt, into a fixed-length pseudorandom key using HMAC. Expand then stretches that key into as many output bytes as needed, with an info string that binds the output to its purpose, by iterating HMAC with a counter. Separating the stages gives a clean security argument based on HMAC being a good randomness extractor and pseudorandom function.

Protocols often call Extract and Expand separately, building key schedules where one extracted secret yields many purpose-specific keys; TLS 1.3 is the prominent example. NextSSL exposes the combined function, the two stages individually (hkdf-extract, hkdf-expand) and an HKDF-SHA256 instantiation. NIST SP 800-56C allows HKDF-style two-step derivation for key agreement. The salt is optional but recommended; it need not be secret, and a fixed protocol-specific salt is acceptable.

History

2010–2020
  1. Krawczyk's HKDF paper at CRYPTO; specified in RFC 5869

  2. Specified in NIST SP 800-56C

How it works

  1. Extract: PRK = HMAC(salt, IKM), with a zero-filled salt if none is given.
  2. Expand: T(1) = HMAC(PRK, info || 0x01), T(i) = HMAC(PRK, T(i-1) || info || i).
  3. Output the first L bytes of T(1) || T(2) || ...
  4. Use distinct info strings for each derived key.

Security notes

Well analysed and sound. HKDF is not a password hashing function: for low-entropy passwords use Argon2, scrypt or PBKDF2. Output is limited to 255 times the hash length per Expand call.

Typical uses

Key schedules in TLS 1.3, QUIC and HPKEDeriving encryption and MAC keys from ECDH or ML-KEM secretsDomain-separated sub-keys from a master key

Variants in NextSSL

4
AlgorithmTierSizes (bytes)StandardsAPI
HKDF
hkdf
standard FIPS key 1–268435456 · out 1–16320 RFC 5869, NIST SP 800-56C safe
HKDF-Expand
hkdf-expand
standard FIPS key 28–268435456 · out 1–16320 · salt 0 RFC 5869, NIST SP 800-56C safe
HKDF-Extract
hkdf-extract
standard FIPS key 1–268435456 · out 28–64 · info 0 RFC 5869, NIST SP 800-56C safe
HKDF-SHA-256
hkdf-sha256
standard FIPS key 1–268435456 · out 1–8160 RFC 5869, NIST SP 800-56C safe

Frequently asked questions

Which HKDF variants does NextSSL include?

NextSSL registers 4 HKDF variants: hkdf, hkdf-expand, hkdf-extract, hkdf-sha256.