While searching for answers ,I understand that RFC AES-CMAC 4493 is suggested by NIST to overcome if payload is not aligned in 16 bytes.

I would like to know what drawbacks/insecure caused by AES-CMAC if length is not aligned in 16 bytes. Would the generated TAG value is easily tampered?

how and when the One-Key CBC MAC1 (OMAC1) is used? here what is the ONE-KEY stands for?( Normal CMAC Gen/Ver - Same single key is used for Generation and verification).

  • $\begingroup$ 1. please link to these claims 2. CMAC seems recommended in line 2 to overcome issues with alignment, and now there are drawbacks? $\endgroup$ – Maarten Bodewes Jan 23 '18 at 14:36

I hope you mean drawback caused by AES CBC-MAC which is resolved in AES-CMAC.

AES_CBC MAC if used properly with ISO padding technique should not result into a tag collision.

So AES-CBC MAC should look something like this.


In AES-CBC MAC if the last block is not 16 byte aligned (considering AES as PRF) then padding must be done to the last block. Padding should be done based on ISO (bit padding, using binary one followed by zeros, e.g. $\texttt{100..00}$) For ISO 1 indicates the start of the padding. If the block is already 16 byte aligned then a dummy block (with ISO padding) should be concatenated . After this only the tag should be calculated.

Let's see the collision situation: last block say m is of 13 bytes. Hence as per ISO padding the block would become $m\|\texttt{100}$ and then tag will be calculated. What if there is a block called $m'$ which ends with $\mathtt{100}$ as the real data and if the dummy 16 byte block is not added then tag will be of same as with $m\|\mathtt{100}$. This means that a collision can be created.

As per security two different data should not result in the same MAC with the same Key. Hence it can become insecure.

To overcome this, there is a solution in AES-CMAC where there is no need to add a dummy block if the it is already block aligned to the PRF (in this case it is AES then 16 bytes aligned).

In AES CMAC there are three keys ($K$,$K_1$ and $K_2$). $K_1$ and $K_2$ are derived from $K$. For the subkeys ($K_1$ and $K_2$ ) generation, please see section 2.3 (Subkey Generation Algorithm).

If the last block is not aligned (16 bytes in case AES PRF) then pad the last block as ISO padding . Encrypt it with AES and XOR the output with $K_1$ . The tag is calculated on the XOR-ed output with the same key $K$.

Please see the image for padded case in AES-CMACAES-CMAC last block not alligned to 16 bytes for AES PRF

If the last block is aligned (16 bytes in case AES as PRF) then XOR the output of the block with the $K_2$. The tag is calculated on the XOR-ed output with the same key $K$.

Please see the image for the non padded case.AES-CMAC for block aligned data

Note: referenced from Professor Dan Boneh.

  • $\begingroup$ Thanks for your answers Vikash. Could you share the test vectors with payload not aligned on 16 bytes? so that i can test the CMAC implemented algorithm $\endgroup$ – danny Feb 5 '18 at 10:00
  • $\begingroup$ @danny Please do not use the comments to ask people followup questions. $\endgroup$ – Maarten Bodewes Feb 27 '20 at 11:34
  • $\begingroup$ Vikash, I changed quite a lot of formatting of your question. Please review the changes by clicking [edited ... ago] above my name. Review and spell check your answers before submission please. "Allign" was spelled incorrectly all the time, and I'm sure that Dan would prefer that you spell his name correctly (although he might consider being called "Don" a compliment). $\endgroup$ – Maarten Bodewes Feb 27 '20 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.