Choose a length and truncate the stream
04Expand returns exactly L bytes by taking a prefix of its block stream. The counter limits the maximum amount from one call.
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 ↗
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.
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.
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 ↗