AES-CMAC
The block-cipher MAC standardised by NIST in SP 800-38B, usually instantiated with AES
About AES-CMAC
AES-CMAC is one of 2 CMAC variants in the NextSSL registry, a message authentication code. It uses a 16–32-byte key and a 16-byte (128-bit) authentication tag. Its registry entry cites RFC 4493 and NIST SP 800-38B. It is also known as omac. NextSSL lists it in the standard tier and exposes it through the safe API.
Overview
CMAC is a message authentication code built from a block cipher. It is the NIST-approved fix for CBC-MAC's problems with variable-length messages and is widely used with AES in payment, smart-card, automotive and network protocols.
CMAC processes the message like CBC-MAC: each block is XORed into a running value and encrypted. Before the final block is processed, one of two subkeys K1 or K2, derived by multiplying the encryption of zero by x or x² in GF(2^128), is XORed in. Which subkey is used depends on whether the last block is complete or padded, so padding cannot be exploited to forge tags.
The construction is OMAC1 by Tetsu Iwata and Kaoru Kurosawa, standardised in SP 800-38B in 2005. NextSSL includes AES-CMAC (RFC 4493) and AES-CMAC-PRF-128 (RFC 4615), a pseudo-random function variant that accepts keys of any length for use in IKEv2 key derivation. CMAC is also the MAC inside AES-SIV. It needs only the AES encryption direction.
History
2005–2006Specified in NIST SP 800-38B
Specified in RFC 4493
Specified in RFC 4615
Security notes
AES-CMAC is secure up to about 2^64 blocks under one key, after which birthday-bound forgeries become possible. Tags should be compared in constant time, and keys must not be reused for other purposes such as encryption.
Typical uses
Sizes
| Field | Bytes | Meaning |
|---|---|---|
| key | 16 – 32 | Secret key |
| tag | 16 | Authentication tag |
Use it
from nextssl_demo import NextSSL
ns = NextSSL() # safe API: safe and standard tiers
key = ns.random(16)
tag = ns.call("mac", "aes-cmac", None, key, b"message", 0)[0]
ok = ns.check("mac_verify", "aes-cmac", None, key, b"message", tag)
nextssl_mac("aes-cmac", NULL, key, data, 0, tag);
nextssl_mac_verify("aes-cmac", NULL, key, data, tag);
use nextssl_core::Params;
use nextssl_registry::{self as reg, Policy};
let alg = reg::new_mac_in(reg::all(), Policy::Safe, "aes-cmac", &Params::new())?;
let tag = alg.tag(&key, b"message")?;
let ok = alg.verify(&key, b"message", &tag)?;
Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.
Other CMAC variants
1Similar names
Looking for something else?More message authentication codes
All 30Frequently asked questions
What is AES-CMAC?
AES-CMAC is a MAC in the CMAC family. CMAC is a message authentication code built from a block cipher. It is also known as omac.
What are the AES-CMAC sizes?
In NextSSL, AES-CMAC uses: key 16 to 32 bytes, tag 16 bytes.
Who designed AES-CMAC and when?
AES-CMAC belongs to the CMAC family, first published in 2005 by Tetsu Iwata, Kaoru Kurosawa. Its origin: NIST SP 800-38B; RFC 4493.
Which standards define AES-CMAC?
AES-CMAC is referenced by RFC 4493, NIST SP 800-38B. It is specified in a FIPS standard.
Is AES-CMAC safe to use?
AES-CMAC is in the standard tier. Standardised and sound. Reachable from the safe API. It can be called from the safe API.
What other CMAC variants are there?
NextSSL also registers aes-cmac-prf-128 in the CMAC family.
Related families
The Advanced Encryption Standard: the world's default 128-bit block cipher
HMAC_DRBGNIST SP 800-90A deterministic random bit generator built on HMAC
CBC-MAC and DES-MACThe original block-cipher MAC: secure only for fixed-length messages
HMACThe standard way to build a MAC from a cryptographic hash (RFC 2104, FIPS 198-1)
PMACRogaway's fully parallelisable block-cipher MAC