Comprehensive HMAC implementation with detailed step-by-step computation, security analysis, and interactive simulation.
HMAC(K, M) = H((K ⊕ opad) || H((K ⊕ ipad) || M)) Where: - H = Cryptographic hash function (SHA-256, SHA-1, MD5) - K = Secret key - M = Message to authenticate - ipad = Inner padding (0x36 repeated block size times) - opad = Outer padding (0x5C repeated block size times) - || = Concatenation - ⊕ = XOR operation
Example: "Data"
Example: "key123"
Block size: 64 bytes
HMAC proves the message originated from someone knowing the secret key
Only someone with K can generate the correct HMAC tag
Any change to the message will produce a different HMAC tag
Hash functions are sensitive to input changes
Secret key is never exposed in the computation
Key is XORed with padding, never directly used
Difficult to find two messages with same HMAC tag
Based on underlying hash function collision resistance
HMAC:
Requires secret key for computation
Plain Hash:
No key required, anyone can compute
HMAC:
Provides message authentication
Plain Hash:
Only provides integrity, no authentication
HMAC:
Protected against length extension attacks
Plain Hash:
Vulnerable to length extension attacks
HMAC:
Message authentication codes
Plain Hash:
Digital signatures, checksums