This page uses content from Wikipedia and is licensed under CC BY-SA.

**OMAC (One-key MAC)** is a message authentication code constructed from a block cipher much like the CBC-MAC algorithm.

Officially there are two OMAC algorithms (OMAC1 and OMAC2) which are both essentially the same except for a small tweak.
OMAC1 is equivalent to **CMAC**, which became an NIST recommendation in May 2005.

It is free for all uses: it is not covered by any patents.^{[citation needed]}
In cryptography, **CMAC** (Cipher-based Message Authentication Code)^{[1]} is a block cipher-based message authentication code algorithm. It may be used to provide assurance of the authenticity and, hence, the integrity of binary data. This mode of operation fixes security deficiencies of CBC-MAC (CBC-MAC is secure only for fixed-length messages).

The core of the CMAC algorithm is a variation of CBC-MAC that Black and Rogaway proposed and analyzed under the name XCBC^{[2]} and submitted to NIST.^{[3]} The XCBC algorithm efficiently addresses the security deficiencies of CBC-MAC, but requires three keys. Iwata and Kurosawa proposed an improvement of XCBC and named the resulting algorithm One-Key CBC-MAC (**OMAC**) in their papers.^{[4]} They later submitted OMAC1,^{[5]} a refinement of OMAC, and additional security analysis.^{[6]} The OMAC algorithm reduces the amount of key material required for XCBC. CMAC is equivalent to OMAC1.

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 (*k*_{1} and *k*_{2}) using the following algorithm (this is equivalent to multiplication by *x* and *x*^{2} in a finite field GF(2^{b})). Let ≪ denote the standard left-shift operator and ⊕ denote bit-wise exclusive or:

- Calculate a temporary value
*k*_{0}=*E*(0)._{k} - If msb(
*k*_{0}) = 0, then*k*_{1}=*k*_{0}≪ 1, else*k*_{1}= (*k*_{0}≪ 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: 0x1B for 64-bit, 0x87 for 128-bit, and 0x425 for 256-bit blocks.) - If msb(
*k*_{1}) = 0, then*k*_{2}=*k*_{1}≪ 1, else*k*_{2}= (*k*_{1}≪ 1) ⊕*C*. - Return keys (
*k*_{1},*k*_{2}) for the MAC generation process.

As a small example, suppose *b* = 4, *C* = 0011_{2}, and *k*_{0} = *E _{k}*(0) = 0101

The CMAC tag generation process is as follows:

- Divide message into
*b*-bit blocks*m*=*m*_{1}∥ ... ∥*m*_{n−1}∥*m*, where_{n}*m*_{1}, ...,*m*_{n−1}are complete blocks. (The empty message is treated as one incomplete block.) - If
*m*is a complete block then_{n}*m*′ =_{n}*k*_{1}⊕*m*else_{n}*m*′ =_{n}*k*_{2}⊕ (*m*∥ 10...0_{n}_{2}). - Let
*c*_{0}= 00...0_{2}. - For
*i*= 1, ...,*n*− 1, calculate*c*=_{i}*E*(_{k}*c*_{i−1}⊕*m*)._{i} *c*=_{n}*E*(_{k}*c*_{n−1}⊕*m*′)_{n}- Output
*t*= msb_{ℓ}(*c*)._{n}

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.

**^**Dworkin, M J. "Recommendation for block cipher modes of operation" (PDF). doi:10.6028/nist.sp.800-38b.**^**Black, John; Rogaway, Phillip (2000-08-20).*Advances in Cryptology – CRYPTO 2000*. Springer, Berlin, Heidelberg. pp. 197–215. doi:10.1007/3-540-44598-6_12. ISBN 3540445986.**^**Black, J; Rogaway, P. "A Suggestion for Handling Arbitrary-Length Messages with the CBC MAC" (PDF).**^**Iwata, Tetsu; Kurosawa, Kaoru (2003-02-24). "OMAC: One-Key CBC MAC".*Fast Software Encryption*. Springer, Berlin, Heidelberg. pp. 129–153. doi:10.1007/978-3-540-39887-5_11.**^**Iwata, Tetsu; Kurosawa, Kaoru (2003). "OMAC: One-Key CBC MAC – Addendum" (PDF).**^**Iwata, Tetsu; Kurosawa, Kaoru (2003-12-08). "Stronger Security Bounds for OMAC, TMAC, and XCBC". In Johansson, Thomas; Maitra, Subhamoy.*Progress in Cryptology – INDOCRYPT 2003*. Lecture Notes in Computer Science. Springer Berlin Heidelberg. pp. 402–415. doi:10.1007/978-3-540-24582-7_30. ISBN 9783540206095.

- RFC 4493 The AES-CMAC Algorithm
- RFC 4494 The AES-CMAC-96 Algorithm and Its Use with IPsec
- RFC 4615 The Advanced Encryption Standard-Cipher-based Message Authentication Code-Pseudo-Random Function-128 (AES-CMAC-PRF-128)
- OMAC Online Test
- More information on OMAC
- Phillip Rogaway's statement on intellectual property status of CMAC