cancel
Showing results for 
Search instead for 
Did you mean: 

Cryptolib RSA Nucleo-L476RG working slow

Wladimir
Associate II

Hello to all!

Using X-Cube-Cryptolib for RSA algorythm on Nucleo-L476RG board, encryption and subsequent decryption of demo message going very slow - 2 seconds, its mostly decription, i using hardware timer2 for time measuring.

Is there any ways to reduce decription time?

Best regards!

14 REPLIES 14

Code your own crypto more optimally? Perhaps there are commercial libraries that run faster, perhaps look at what's available for CM3 and CM4 platforms.

Large bit count, and Elliptic Curve stuff is going to be quite slow.

The L486 would likely provide faster AES-256

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Wladimir
Associate II

Are there any STM32 chips that support the RSA algorithm at the hardware level?

there isn't

Wladimir
Associate II

Hello!

The Cryptolib documentation has performance tables for the RSA encryption algorithm.

0693W00000AMy7fQAD.png0693W00000AMy7kQAD.pngIn the demo example for the NUCLEO-L476RG board, decryption using the RSA algorithm takes 195123172 clock cycles, the chip operates at a frequency of 80 MHz, so decryption takes 2.5 seconds. But, according to Table 53, the decryption time should take 57192232 clock cycles, which is less than a second, and the key size is larger than in the demo example.

How can i achieve at least this speed of decryption? Why does the speed in the demo example not match the speed in the documentation? Despite the fact that the key is smaller.

And if we look at table 54 - there is decryption time takes 7588416 clock cycles, outstanding!) With key size 2048.

How can i achieve that?

Best regards, Vladimir.

Wladimir
Associate II

Hello to all!!

Is it possible to increase the block of data for encryption and decryption for the RSA algorithm?

The current limit is 244 bytes.

Best regards!

I Wladimir,

Yes there are chips that support public key acceleration:

STM32L5, STM32WL, STM32L4Q, STM32WB and coming STM32U5 with DPA resistance

You have the information in AN5156 (except for STM32L4A which is quite recent)

Best regards

Jocelyn

Wladimir
Associate II

Hello!

How can i include cryptolyb library .a files into STM32CubeIDE project?

Project doesn't recognize them for now. I put them in source directory in project files catalog.

0693W00000ANemuQAD.jpg 

0693W00000ANeo2QAD.jpg 

The following errors occur:

" ../Src/main.c:313: undefined reference to `RSA_PKCS1v15_Encrypt' "

" ../Src/main.c:297: undefined reference to `RNGinit' "

Best regards!

Wladimir
Associate II

Adding libs directory to "Library Path" in Project Properties doesn't change anything.

Jocelyn RICARD
ST Employee

Hello Wladimir,

You can add the library in the Build configuration/Setting/GCC Linker/Libraries

In top window add:

:STM32CryptographicV3.0.0_CM4_GCC.a

in bottom window add the path to the library

Best regards

Jocelyn