MAC · Keyed Hash FIPS 198-1 / RFC 2104 RFC 4231 §4.3 Verified

HMAC-SHA-256

Message authentication code of a message under a key, checked against RFC 4231.

Open in app Download .ncw

HMAC-SHA-256

Overview & Cryptographic Context

HMAC (Hash-based Message Authentication Code), standardized in RFC 2104 and NIST FIPS 198-1, constructs a PRF and message authentication code from an unkeyed cryptographic hash function H using two nested passes with inner (0x36) and outer (0x5c) XOR pads:

HMAC(K, m) = H((K' ⊕ opad) ‖ H((K' ⊕ ipad) ‖ m))

Because Merkle-Damgård hashes like SHA-256 are vulnerable to length-extension attacks when used naively as H(K ‖ m), the outer hash invocation over the inner 32-byte digest prevents an attacker from appending data without knowing K. This workflow reproduces RFC 4231 §4.3 (Test Case 2), authenticating the ASCII phrase "what do ya want for nothing?" under the 4-byte ASCII key "Jefe" (zero-padded internally to the 64-byte SHA-256 block size B).

Pipeline Architecture & Wiring Flow

Workflow Input (Key, Data) ──► HMAC Generator (algorithm = SHA-256) ──► Workflow Output (MAC 32B)
  1. Key & Message Ingress (Workflow Input): Supplies the secret Key (4 bytes, 4a656665) and the message Data (28 bytes).
  2. Keyed Hash Computation (HMAC Generator): Configured with algorithm = "SHA-256". The node automatically normalizes keys shorter or longer than 64 bytes per RFC 2104 before computing the 32-byte tag.
  3. MAC Output (Workflow Output): Emits the resulting 32-byte (256-bit) authentication code on the MAC output port.

Nodes & Configuration

NodeNode Role & Key ParametersCount
Workflow InputSupplies Key and Data byte streams1
HMAC GeneratorConfigured with algorithm = "SHA-256"1
Workflow OutputCollects the 32-byte MAC output1

Node reference →

Inputs, Outputs & Test Vector Verification

Verification Source: RFC 4231 §4.3 (Test Case 2, HMAC-SHA-256)

Inputs

NameTypeValue (Hex)
Keybytes (4 B, ASCII "Jefe")4a656665
Databytes (28 B, ASCII "what do ya want for nothing?")7768617420646f2079612077616e7420666f72206e6f7468696e673f

Expected Outputs

NameTypeValue (Hex)
MACbytes (32 B)5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843