Key derivation

HKDF-SHA-256

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

standard Safe API Specified in a FIPS standard

About HKDF-SHA-256

HKDF-SHA-256 is one of 4 HKDF variants in the NextSSL registry, a key derivation function. It uses a 1–268,435,456-byte key and a 1–8,160-byte output. Its registry entry cites RFC 5869 and NIST SP 800-56C. It is also known as hkdf-sha-256. NextSSL lists it in the standard tier and exposes it through the safe API.

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

Sizes

FieldBytesMeaning
key1 – 268,435,456Secret key
out1 – 8,160Output

Use it

from nextssl_demo import NextSSL

ns = NextSSL()              # safe API: safe and standard tiers
okm = ns.call("kdf", "hkdf-sha256", None, ikm, salt, b"context", 32)[0]

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Other HKDF variants

3

Frequently asked questions

What is HKDF-SHA-256?

HKDF-SHA-256 is a KDF in the HKDF family. HKDF derives one or more strong cryptographic keys from input keying material such as a Diffie-Hellman shared secret. It is also known as hkdf-sha-256.

What are the HKDF-SHA-256 sizes?

In NextSSL, HKDF-SHA-256 uses: key 1 to 268,435,456 bytes, output 1 to 8,160 bytes.

Who designed HKDF-SHA-256 and when?

HKDF-SHA-256 belongs to the HKDF family, first published in 2010 by Hugo Krawczyk. Its origin: RFC 5869; NIST SP 800-56C.

Which standards define HKDF-SHA-256?

HKDF-SHA-256 is referenced by RFC 5869, NIST SP 800-56C. It is specified in a FIPS standard.

Is HKDF-SHA-256 safe to use?

HKDF-SHA-256 is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.

What other HKDF variants are there?

NextSSL also registers hkdf, hkdf-expand, hkdf-extract in the HKDF family.