One-key MAC
Message authentication code algorithm
title: "One-key MAC" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["message-authentication-codes", "finite-fields"] description: "Message authentication code algorithm" topic_path: "general/message-authentication-codes" source: "https://en.wikipedia.org/wiki/One-key_MAC" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Message authentication code algorithm ::
One-key MAC (OMAC) is a family of message authentication codes constructed from a block cipher much like the CBC-MAC algorithm. It may be used to provide assurance of the authenticity and, hence, the integrity of data. Two versions are defined:
- The original OMAC of February 2003, which is rarely used. The preferred name is now "OMAC2".
- The OMAC1 refinement,
OMAC is free for all uses: it is not covered by any patents.
History
The core of the CMAC algorithm is a variation of CBC-MAC that Black and Rogaway proposed and analyzed under the name "XCBC" and submitted to NIST. The XCBC algorithm efficiently addresses the security deficiencies of CBC-MAC, but requires three keys.
Iwata and Kurosawa proposed an improvement of XCBC that requires less key material (just one key) and named the resulting algorithm One-Key CBC-MAC (OMAC) in their papers. They later submitted the OMAC1 (= CMAC), a refinement of OMAC, and additional security analysis.
Algorithm
::figure[src="https://upload.wikimedia.org/wikipedia/commons/e/e2/CMAC_-_Cipher-based_Message_Authentication_Code.pdf" caption=""] ::
To generate an ℓ-bit CMAC tag (t) of a message (m) using a b-bit block cipher (E) and a secret key (k), one first generates two b-bit sub-keys (k1 and k2) using the following algorithm (this is equivalent to multiplication by x and x2 in a finite field GF(2b)). Let ≪ denote the standard left-shift operator and ⊕ denote bit-wise exclusive or:
- Calculate a temporary value k0 = Ek(0).
- If msb(k0) = 0, then k1 = k0 ≪ 1, else k1 = (k0 ≪ 1) ⊕ C; where C is a certain constant that depends only on b. (Specifically, C is the non-leading coefficients of the lexicographically first irreducible degree-b binary polynomial with the minimal number of ones: for 64-bit, for 128-bit, and for 256-bit blocks.)
- If , then , else .
- Return keys (k1, k2) for the MAC generation process.
As a small example, suppose , , and . Then and .
The CMAC tag generation process is as follows:
- Divide message into b-bit blocks , where m1, ..., m**n−1 are complete blocks. (The empty message is treated as one incomplete block.)
- If mn is a complete block then else .
- Let .
- For , calculate .
- Output .
The verification process is as follows:
- Use the above algorithm to generate the tag.
- Check that the generated tag is equal to the received tag.
Variants
CMAC-C1 is a variant of CMAC that provides additional commitment and context-discovery security guarantees.
Implementations
- Python implementation: see the usage of the
AES_CMAC()function in "impacket/blob/master/tests/misc/test_crypto.py", and its definition in "impacket/blob/master/impacket/crypto.py" - Ruby implementation
References
References
- Dworkin, Morris. (2016). "Recommendation for Block Cipher Modes of Operation: The CMAC Mode for Authentication".
- Rogaway, Phillip. "CMAC: Non-licensing".
- (2000-08-20). "Advances in Cryptology – CRYPTO 2000". Springer, Berlin, Heidelberg.
- "A Suggestion for Handling Arbitrary-Length Messages with the CBC MAC".
- (2003-02-24). "Fast Software Encryption". Springer, Berlin, Heidelberg.
- (2003). "OMAC: One-Key CBC MAC – Addendum".
- (2003-12-08). "Progress in Cryptology - INDOCRYPT 2003". Springer Berlin Heidelberg.
- (2024). "Advances in Cryptology – CRYPTO 2024". Springer Nature Switzerland.
- (15 December 2018). "Impacket is a collection of Python classes for working with network protocols.: SecureAuthCorp/impacket".
- (4 May 2016). "Ruby C extension for the AES-CMAC keyed hash function (RFC 4493): louismullie/cmac-rb".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::