# CMAC Generation : If input payload length is not aligned in 16 bytes, what are the possible side effects?

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

• 1. please link to these claims 2. CMAC seems recommended in line 2 to overcome issues with alignment, and now there are drawbacks? – 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$$.

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