AES CCM decryption/verification.

527 views
Skip to first unread message

Daniel Karcz

unread,
Nov 5, 2017, 1:06:51 PM11/5/17
to Crypto++ Users

Hi,

I have to understand decryption process of Crypto CCM implementation.
I'm using the first example AE (authentication/encryption) from Crypto++ Wiki. 


Here is my example output from this program:

key: 6DFB2E83D016999B8F4CA9B564AB2B6A
 iv: 37F1A6DD11DD2D14C3CABBAD

plain text: Authenticated Encryption
cipher text: 61CBA7195D8F9619C4190D61D0D953301FFE2169785BAC5501E768279E7BC5AA
recovered text: Authenticated Encryption

Now, here is my understanding of decryption process:

Text "Authenticated Encryption" is 24 bytes long so the firs 24 bytes are cipher:

"61CBA7195D8F9619C4190D61D0D953301FFE2169785BAC55"

we have remain 8 bytes and it is correct because  

TAG_SIZE = 8, so the last 8 bytes are the tag "01E768279E7BC5AA".


remain I have to write only encryption/veryfication function (because I'm facing Linux program using Crypto++ with embedded system which Crypto++ is not supporting). I have AES in CTR and CBC Crypto hardware support on that chip.

I have started from generating counter blocks:

so I tooked the iv 37F1A6DD11DD2D14C3CABBAD and I have add 3 bytes (counter) and tooked it as input data to AES ECB encryption with key  6DFB2E83D016999B8F4CA9B564AB2B6A 

 ****************************************
 Key: 6DFB2E83D016999B8F4CA9B564AB2B6A
 Algorithm: AES-128
 Mode: ECB
 Crypto operation: Encryption
 Data: 37F1A6DD11DD2D14C3CABBAD000000

 ----------------------------------------
 Encrypted data: 77B133ED82AE801FCABAC8F51BCA4141

Now I was suposing that I have a first counter block, so I've made a XOR operation with first 16 bytes of cipher text

Here is result 

16 7A 94 F4 DF 21 16 06 0E A3 C5 94 CB 13 12 71

and when I changed this into ASCII it is far away from first 16 bytes of plain text: "Authenticated En".

I'm getting crazy with this because it suppose to work that way, and I'm out of ideas with it.

Please help

















Daniel Karcz

unread,
Nov 7, 2017, 2:32:08 PM11/7/17
to Crypto++ Users
I will try to be more precisely:

What is the initial value of counter(CTR stream generator) in AES CCM mode in Crypto++ and by what value is incremented??

Jeffrey Walton

unread,
Nov 7, 2017, 3:57:17 PM11/7/17
to Daniel Karcz, Crypto++ Users
On Tue, Nov 7, 2017 at 2:32 PM, Daniel Karcz <daniel...@gmail.com> wrote:
I will try to be more precisely:

What is the initial value of counter(CTR stream generator) in AES CCM mode in Crypto++ and by what value is incremented??

Crypto++ uses the test vectors from NIST for validation. Also see https://csrc.nist.gov/projects/cryptographic-algorithm-validation-program

Jeff

Daniel Karcz

unread,
Nov 8, 2017, 1:46:36 AM11/8/17
to Crypto++ Users
Thank you Jeff, I've got it from here 


but I cannot track it down from those files.
Is there any way that i can pass it to CCM in Crypto++ or although display it?

Daniel

Jeffrey Walton

unread,
Nov 8, 2017, 6:26:55 AM11/8/17
to Daniel Karcz, Crypto++ Users
On Wed, Nov 8, 2017 at 1:46 AM, Daniel Karcz <daniel...@gmail.com> wrote:
> Thank you Jeff, I've got it from here
>
> https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Algorithm-Validation-Program/documents/mac/ccmtestvectors.zip
>
> but I cannot track it down from those files.
> Is there any way that i can pass it to CCM in Crypto++ or although display
> it?

Maybe you can use the CCM test vectors instead. They were taken from
the NIST test vectors.

https://github.com/weidai11/cryptopp/blob/master/TestVectors/ccm.txt

Jeff
Reply all
Reply to author
Forward
0 new messages