Visual RFC.
ALL RFCs / RFC 5869
Read the RFC ↗
RFC 5869 / HKDF KEY DERIVATION

Choose a length and truncate the stream

04

Expand returns exactly L bytes by taking a prefix of its block stream. The counter limits the maximum amount from one call.

RFC 5869 · § 2.3EXAMPLE
3 / 3
Choose a length and truncate the streamWith SHA-256 and L42, ceil42/32 requires two blocks. The result retains all 32 T1 bytes plus only ten T2 bytes. A separate L8161 request exceeds the 8160-octet bound and stops at the length check without producing another block or wrapping the counter.Return exactly L octets, within the boundSHA-256 example · HashLen = 32Separate request: L = 8161Length requestLength check8161 exceeds boundMaximum = 255 × 32 = 8160 octetsNo counter wrap · no output for this requestL is in octets; it is not automatically part of info
03
Reject a separate over-limit request.

8161 exceeds 255 × 32 = 8160. Do not wrap the counter or promise an additional block from the same expand call.

Source for this drawing: RFC 5869 · Read RFC section 2.3 ↗

Protocol participantThreat or exceptionProtocol controlSimplified drawings · precise section references
New to this? Start hereA quick picture + helpful background

A message needs an address.

Think of a packet as a small addressed envelope. Devices pass it onward; transport protocols decide what delivery promises an application gets.

Helpful first, if these ideas are unfamiliar

These pictures are analogies to help you learn. The linked RFC explains the actual rules.

Terms in this drawing
L
Requested output keying material length, measured in octets.
Prefix
The first requested bytes of an ordered byte stream.
Related RFCs and changes

“Updates” changes part of an earlier RFC. “Obsoletes” replaces it. This list shows selected related documents.

KEY POINT

Compute N = ceil(L / HashLen); concatenate the N generated blocks and return their first L octets.

  • Compute N = ceil(L / HashLen); concatenate the N generated blocks and return their first L octets.
  • With SHA-256 and L=42, two 32-octet blocks are required. Return all 32 bytes of T(1) and the first 10 bytes of T(2); do not return all 64 bytes.
  • L must satisfy L ≤ 255 × HashLen. With SHA-256 the maximum is 8160 octets; 8161 cannot be served by this expand call.
  • L is a length in octets, not bits. It is not automatically encoded in info or appended to the HMAC message.
DETAILS

Lengths and bars are schematic. The first two states use the official test’s L=42 with SHA-256. The final state is a separate invalid request L=8161: the illustrative implementation rejects it before producing output. The RFC gives the bound but does not prescribe this UI/error label or a specific exception type.

Read the RFC section ↗

All chapters in RFC 5869

Drawing view

Scroll the drawing to see every part. Playback controls stay above it.

RFC 9700 / CHAPTERS

Chapters

For full details, tables, algorithms, and exceptions, read the original RFC.

RFC status and corrections ↗