cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Crypto Lib on STM32L051C8

alessandro.breuza
Associate III

Hello,

I'm trying to integrate latest crypto lib (v. 3.1.2, FW implementation) into my TrueSTUDIO project but encryption with AES-CBC-128 fails.

Example project in Fw_Crypto\STM32L0\Projects\STM32L053R8-Nucleo\AES\AES192_CBC fails both encryption and decryption phases.

Digging into the issue I reduced key size to 128bits and set Key, IV and Plaintext as all 0's (16B long): encryption works correctly (according to various online AES calculators).

Changing a single bit in Plaintext will break encryption: it looks like some data are ignored and some other are read multiple times (always comparing result with online calculators).

If I split the 16B of plaintext into 4 groups (4B each - let's call them p1 p2 p3 p4), library behaves as if plaintext was p2 p1 p1 p1: changing bits in p3 and p4 does not change ciphertext (!).

What am I missing?

Alessandro

1 ACCEPTED SOLUTION

Accepted Solutions
Amir NEIFAR
Associate III

​Hi Alessandro,

You can find in the below link the cryptolib user manual it detail about the cryptolib and clearly mention that you have to activate the CRC peripheral. (As you mention)

https://www.st.com/content/ccc/resource/technical/document/user_manual/group0/f9/6e/f2/a2/b4/ec/49/c0/DM00215061/files/DM00215061.pdf/jcr:content/translations/en.DM00215061.pdf

Please mark this ticket as answered to allow communities getting benefits about your ticket.

Thank you in advance.

Regards,

Amir

View solution in original post

2 REPLIES 2
alessandro.breuza
Associate III

Ok, I found the problem: CRC peripheral was not enabled.

Adding __CRC_CLK_ENABLE() before encryption solved the issue.

Amir NEIFAR
Associate III

​Hi Alessandro,

You can find in the below link the cryptolib user manual it detail about the cryptolib and clearly mention that you have to activate the CRC peripheral. (As you mention)

https://www.st.com/content/ccc/resource/technical/document/user_manual/group0/f9/6e/f2/a2/b4/ec/49/c0/DM00215061/files/DM00215061.pdf/jcr:content/translations/en.DM00215061.pdf

Please mark this ticket as answered to allow communities getting benefits about your ticket.

Thank you in advance.

Regards,

Amir