Message authentication codes

AES-CMAC

The block-cipher MAC standardised by NIST in SP 800-38B, usually instantiated with AES

standard Safe API Specified in a FIPS standard

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–2006
  1. Specified in NIST SP 800-38B

  2. Specified in RFC 4493

  3. 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

Authentication on devices with an AES core but no hashPayment and smart-card protocolsAutomotive message authentication (AUTOSAR SecOC)IKEv2 PRF (AES-CMAC-PRF-128)

Sizes

FieldBytesMeaning
key16 – 32Secret key
tag16Authentication 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)

Calls follow the NextSSL C ABI and its language bindings. Buffer sizes are validated against the sizes above.

Other CMAC variants

1

Frequently 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.