CMAC Length Calculator
Compute the number of CMAC blocks, the padded length, and standard output truncations for AES-128 / AES-192 / AES-256 / TDES. Practical reference when wiring SCP03, DESFire EV2/EV3 secure messaging, or EMV CDA.
How to use this tool
What it does
Explains and computes AES-CMAC output and truncation lengths used in secure messaging.
When to use it
Use it when a secure channel truncates a MAC (for example an 8-byte C-MAC) and you need to confirm the expected length.
Worked example
Check that an SCP03 C-MAC is the low 8 bytes of the full 16-byte AES-CMAC.
Input
Result
About CMAC
CMAC (NIST SP 800-38B) is a Cipher-based MAC built on a block cipher. It uses two derived subkeys (K1, K2) selected by message length to handle padding without ambiguity. Common deployments truncate the 16-byte output to 8 bytes for transport efficiency.
Spec
NIST SP 800-38B; ISO/IEC 9797-1.
Companion
Reading
Frequently asked questions
What does CMAC padding do?
If the message is not an exact multiple of the block size, a single 0x80 byte followed by zeros is appended and the second subkey K2 is used. An exact multiple is processed with K1 and no padding.
Why do SCP03 and DESFire truncate the MAC?
To save bytes on a constrained channel. SCP03 carries 8 bytes of a 16-byte CMAC; truncation reduces forgery resistance proportionally, which is why the remaining length is specified rather than chosen.
What block size applies?
16 bytes for AES and 8 bytes for TDES, which is why the same message length gives different block counts depending on the cipher.
Is this a production MAC implementation?
No. It computes lengths, block counts and truncation only — it performs no keyed cryptography and is intended for sizing buffers and checking a specification against an implementation.
Does anything I paste leave my browser?
Nothing. The tool is entirely client-side: the page ships a static script, does no network calls, and never transmits what you paste. You can confirm it by opening the network tab, or by loading the page and then going offline.