HMAC Output Calculator
Size an HMAC tag, check how your key is padded or hashed, and count the compression calls a verification costs.
About HMAC Output Calculator
HMAC pads the key to the hash block size, XORs it with two distinct constants, and runs the hash twice. That costs one extra block on each pass, so a short message still needs at least four compression calls, and a key longer than the block is hashed before use — extra key length beyond the block adds no strength. Truncating a tag or using a 12-byte key silently drops MAC security below the level your threat model assumes, and the compression count is what determines API signing throughput at scale.
Formula
HMAC Output
HMAC(K, m) = H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ m)); the tag is the full digest length and security = min(key bits, digest bits).
- ipad
- 0x36 repeated to the block size
- opad
- 0x5c repeated to the block size
- block size
- 64 bytes for SHA-1/224/256, 128 bytes for SHA-384/512
Worked example
With the default values below, HMAC Output Calculator returns MAC Tag Size of 32. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Underlying hashone of HMAC-SHA-1, HMAC-SHA-256, HMAC-SHA-384, HMAC-SHA-512
- HMAC-SHA-256
- Key lengthaccepts 1–512 bytes
- 32 bytes
- Message lengthminimum 0 bytes
- 512 bytes
Results
- MAC Tag Size
- 32 bytes
- Hash Block Size
- 64 bytes
- Effective MAC Security
- 256 bits
- Compression Calls
- 12
- Key Handling
- Key zero-padded to the 64-byte block
- Assessment
- Strong — 256-bit MAC security
Step by step
- 1Values used
- 2HMAC Output
- 3MAC Tag Size= 32 bytes
- 4Hash Block Size= 64 bytes
- 5Effective MAC Security= 256 bits
- 6Compression Calls= 12
- 7Key Handling= Key zero-padded to the 64-byte block
- 8Assessment= Strong — 256-bit MAC security
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
How is HMAC Output calculated?
HMAC(K, m) = H((K ⊕ opad) ‖ H((K ⊕ ipad) ‖ m)); the tag is the full digest length and security = min(key bits, digest bits). HMAC pads the key to the hash block size, XORs it with two distinct constants, and runs the hash twice. That costs one extra block on each pass, so a short message still needs at least four compression calls, and a key longer than the block is hashed before use — extra key length beyond the block adds no strength.
Why does HMAC Output matter?
Truncating a tag or using a 12-byte key silently drops MAC security below the level your threat model assumes, and the compression count is what determines API signing throughput at scale.
What values do I need to enter?
This calculator takes 3 inputs: Underlying hash, Key length, Message length. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.
Can I truncate an HMAC tag?
Yes — FIPS 198-1 allows truncation to the leftmost bytes, and RFC 4868 uses 128-bit truncated tags in IPsec. Security becomes the truncated length, so never go below 128 bits for a general-purpose MAC.
