CMAC AES calculation with specified IV and Key

3,946 views
Skip to first unread message

Leonardo Carreira

unread,
May 9, 2011, 3:53:37 AM5/9/11
to Crypto++ Users
Hi Masters,

Actually in Cryptopp5.6.1 there's a class to handle CMAC calculation..
But, i found a problem when use it with IV initialization..
I've already tried to initialize the IV, but it seems didn't work.. :(
Could you help me to give me simple snippet code to handle CMAC
AES-128 calculation, specify the IV and random byte input data?
And can we get K0, K1 and K2 of our CMAC Key (when CMAC calculation
time)?


Actually, my classmate have already done this..
But i want to create my own application which does the same..

Here's the output of my classmate's tool : (CMAC AES-128 CBC)

* 1st step
IV = 00000000000000000000000000000000
Key = 00000000000000000000000000000000
Input = 25
CMAC Result = F60AA29D615BC9C4C0A7C8A08D963DEF
=======================================================
* 2nd step
IV = F60AA29D615BC9C4C0A7C8A08D963DEF
Key = 00000000000000000000000000000000
Input = 25
CMAC Result = 1368BD293F9DC7DF8019BF0A90E7A853
=======================================================
* 3rd step
IV = F60AA29D615BC9C4C0A7C8A08D963DEF
Key = 00000000000000000000000000000000
Input = 25
CMAC Result = FBE134EEB0F9A5A9736E0C6DB4CFF2EB


How to achieve this using CMAC Cryptopp?
Please help me regarding this.

Thanks,

Leo

Leonardo Carreira

unread,
May 9, 2011, 8:58:26 PM5/9/11
to Crypto++ Users
Hi All,

Actually, Crypto's pp CMAC can fill my need if the data is multiple
AES data block (16 bytes)..
So, what padding values that need to be used if the data is not
multiple 16 bytes?..

Jeffrey Walton

unread,
May 10, 2011, 2:34:43 AM5/10/11
to Crypto++ Users
A CMAC is a CBC-MAC done right (no problems if the message is not a
multiple of the underlying block size). Crypto++ has an example in its
self test code - see ValidateCMAC in validate1.cpp (it will lead you
into datatest.cpp). The wiki now has a sample at http://www.cryptopp.com/wiki/CMAC.

Jeff

Jeffrey Walton

unread,
May 10, 2011, 3:23:26 AM5/10/11
to Crypto++ Users
CMACs do not use an external IV.
Reply all
Reply to author
Forward
0 new messages