AnsweredAssumed Answered

LTC_AES_EncryptCbc does not return correct results

Question asked by Chris Westervelt on Jan 27, 2017
Latest reply on Feb 14, 2017 by Mark Butcher

Hi,

 

I'm using the LTC libraries with the K82 part.  I have noticed that if I use a 32 bit key and 64 bytes of data and feed it to the library that the first 16 bytes come back correct but the residual bytes do not.  Here is an example.

 

Key =          63 68 69 63 6B 65 6E 20 74 65 72 69 79 61 6B 69
                   2C 20 69 73 20 76 65 72 79 20 79 75 6D 6D 79 21

 

Data IN =    49 20 77 6F 75 6C 64 20 6C 69 6B 65 20 74 68 65
                    20 47 65 6E 65 72 61 6C 20 47 61 75 27 73 20 43
                    68 69 63 6B 65 6E 2C 20 70 6C 65 61 73 65 2C 20
                    61 6E 64 20 77 6F 6E 74 6F 6E 20 73 6F 75 70 2E = "I would like the General Gau's Chicken, please, and wonton soup."

 

Data OUT =  49 30 D0 2C 0B 75 CF 5C 15 24 B4 0D A6 5C F9 7B
                      2E B6 1A 0F 3B 20 13 7E E2 8D 89 95 F0 21 F7 C6
                      D6 38 A0 13 96 90 57 B0 AC 2E A9 80 91 EE 53 47
                      F7 64 0D A4 9D A9 20 B4 BD 23 A1 C8 17 76 EF E6

 

It should be:  

4930d02c0b75cf5c1524b40da65cf97b
2bb4acabb18bfa4c193fb18b375a2b5d
0fb3bc5063d6ce4362f6fce29afa56ab
93c47eac1fbcdd92b2848487762184a2

If I run this through LTC_AES_DecryptCbc it comes back ok but that does not mean we are compliant.  I have no Idea why this is happening.

 

I use the WolfSSL libraries that call into the LTC libraries 

code looks like this:

wc_AesSetKey(&temp->session->aes, (const byte *) temp->session->aes.key, temp->session->keylen, NULL,
AES_ENCRYPTION);
wc_AesCbcEncrypt(&temp->session->aes, BufOut, &((struct CmdEncDec *) (&frameIN->data))->data,
((struct CmdEncDec *) (&frameIN->data))->len);

Outcomes