Skip to main content
alessandro.breuza
Associate III
January 29, 2019
Solved

STM32 Crypto Lib on STM32L051C8

  • January 29, 2019
  • 2 replies
  • 932 views

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

This topic has been closed for replies.
Best answer by Amir NEIFAR

​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

2 replies

alessandro.breuza
Associate III
January 30, 2019

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

Adding __CRC_CLK_ENABLE() before encryption solved the issue.

Amir NEIFAR
Amir NEIFARBest answer
Visitor II
January 31, 2019

​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