![NXP Semiconductors LCP43 Series User Manual Download Page 50](http://html1.mh-extra.com/html/nxp-semiconductors/lcp43-series/lcp43-series_user-manual_1721817050.webp)
UM10503
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2012. All rights reserved.
User manual
Rev. 1.3 — 6 July 2012
50 of 1269
NXP Semiconductors
UM10503
Chapter 6: LPC43xx Security API
6.5.2 CMAC using AES hardware acceleration
CMAC is an authentication algorithm that uses the AES engine.
CMAC is calculated over the cipher text. This is better than calculating CMAC over the
plain text because the cipher text will be more random (due to using CBC), even if the
plain text is not random.
Generate sub-keys
To generate an l-bit CMAC tag T of message m using a b-bit block cipher E and secret key
k, first generate 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 << signify a standard
left-shift operator:
1. Calculate a temporary value k
0
= E
k
(0).
2. If msb(k
0
) = 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 b =128, C = 00...010000111.
3. If msb(k
1
) = 0 then k2 = k1 << 1 else k2 = (k1 << 1)
C.
Remark:
Images should consist of complete blocks; Mn* is 128-bit hence K2 is never
used.
Generate the CMAC tag
To generate a CMAC tag, follow these steps:
Fig 20. AES decryption flow
1
2
3
4
5
decrypt header
with AES
AES key = User Key
IV = 0
MAC
0x3456
789A
encrypt temporary
header with AES
= User Key
IV = 0
replace MAC by
constant
calculate CMAC
= User Key
IV = 0
16 + 512* HASH_SIZE
decrypt data with
CBC AES
= User Key
IV = user specific
P
A
D
DECRYPTION
AES key
AES key
AES key