AnsweredAssumed Answered

LTC AES key setting strangeness

Question asked by Mark Butcher on Nov 6, 2018
Latest reply on Nov 11, 2018 by Jing Pan

Hi All


When using the LTC in a KL82 for AES encryption and decryption I found strange results when setting the AES for decryption.


For the test I encrypt and decrypt a single block of 32 bytes.

When entering the AES 256 key for encryption I set the mode to

LTC0_MD = (LTC_MD_ALG_AES | LTC_MD_AAI_CBC);                     // AES key for encryption [0x00100100]
(although 0 also works)

The encryption is then OK.


When entering the AES 256 key for decryption I set the mode to
LTC0_MD = (LTC_MD_ALG_AES | LTC_MD_AAI_CBC | LTC_MD_AAI_DK); // AES key for decryption [0x00101100]

This is accepted - but the decryption fails.


If I then remove the LTC_MD_ALG_AES flag (0x00100000) and set the key the LTC sets its error interrupt (with error saying that there is an AES  mode error). The only way to clear this error is to reset the LTC.
However now the AES256 decryption of the block works.


In fact previously I was just setting the DK bit (which I think is what the SDK examples do) when setting the key for decryption and it had worked. Only when I realised that it was causing the error interrupt to be set, and stopped this by presumably setting the algorithm correctly, did the decryption start failing.


Can anyone explain this?






P.S. I am posting a second question about AES CBC across multiple block so data in a second post, which is related to this too.