Visual RFC.
ALL RFCs / RFC 2104
Read the RFC ↗
RFC 2104 / Keyed message authentication

Check a message with a shared secret

01

Two parties holding the same secret can calculate a tag for the exact message bytes. The tag authenticates data without hiding it.

RFC 2104 · § 1EXAMPLE
4 / 4
Check a message with a shared secretA ninth byte, exclamation mark, changes the computed example tag. Old supplied tag does not match; stop at MAC validation before acceptance.Check exact message bytes with a shared keySender with KReceiver with KHi There! + old tagCalculated tag preview: 5b5b4571…Original tag preview: b0344c61…Mismatch stops MAC acceptancePublic test key · MACs do not hide messages
04
Stop a changed message

The received message changes while its supplied tag does not. The calculated comparison fails and the arrow stops at validation.

Source for this drawing: RFC 2104 · Read RFC section 1 ↗

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

A seal answers a specific question.

A certificate or signature supports particular checks about a key or message. It does not automatically prove that every claim or sender is trustworthy.

Helpful first, if these ideas are unfamiliar

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

Related RFCs and changes

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

KEY POINT

A valid MAC is a shared-key integrity check, not encryption or a public digital signature.

  • HMAC is a hash-based message authentication code (MAC). A MAC is a check value, or tag, calculated with a secret key. A cryptographic hash compresses input bytes to a fixed-size digest; HMAC combines a hash with a shared key using the specific construction in §2. An unkeyed checksum does not serve the same purpose (§1).
  • The sender and receiver use the same chosen hash and secret K. The sender sends message bytes and a tag; the receiver calculates the tag for the bytes it received and checks it. The drawing illustrates that use of a MAC, not a wire format or an application authorization decision (§§1,6).
  • All numerical examples use public test keys. The main example is RFC 4231 §4.2: HMAC-SHA-256, key byte 0b repeated 20 times and the eight ASCII bytes "Hi There" (without a trailing NUL). Its full 32-byte tag in four hexadecimal groups is b0344c61d8db3853 5ca8afceaf0bf12b 881dc200c9833da7 26e9376c2e32cff7. A displayed tag prefix followed by … is only a preview, not an actual shortened tag.
  • In the changed-message example, "Hi There!" is nine bytes but carries the original tag. Recomputing with the same key produces a different tag, so this chosen comparison fails before message acceptance. This is a computed example, not proof that all distinct messages have distinct tags.
  • The message remains readable. Both key holders can generate valid tags; this is not a public digital signature or proof to a third party of which holder sent the message. HMAC itself supplies neither a packet format nor freshness, replay prevention, secret exchange or key storage. Algorithm and protocol security depend on their surrounding design (§§1,3,6).
DETAILS

Selected construction rules and public test data; not a cryptographic library, key exchange, authentication protocol or deployment certification.

Read the RFC section ↗

All chapters in RFC 2104

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 ↗