One-key MAC
One-key MAC 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, which became an NIST recommendation in May 2005 under the name CMAC.
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 and named the resulting algorithm One-Key CBC-MAC in their papers. They later submitted the OMAC1, a refinement of OMAC, and additional security analysis.
Algorithm
To generate an -bit CMAC tag of a message using a b-bit block cipher and a secret key, one first generates two b-bit sub-keys using the following algorithm. Let ≪ denote the standard left-shift operator and ⊕ denote bit-wise exclusive or:- Calculate a temporary value k0 = Ek.
- If msb = 0, then k1 = k0 ≪ 1, else k1 = ⊕ C; where C is a certain constant that depends only on b.
- If, then, else.
- Return keys for the MAC generation process.
The CMAC tag generation process is as follows:
- Divide message into b-bit blocks, where m1,..., mn−1 are complete blocks.
- If mn is a complete block then else.
- Let.
- For, calculate.
- Output.
- Use the above algorithm to generate the tag.
- Check that the generated tag is equal to the received tag.
Variants
Implementations
- Python implementation: see the usage of the
AES_CMACfunction in "", and its definition in "" - Ruby implementation