RSA for MCU
I'm currently working with RSA library from PolarSSL on TI Stellaris Cortex-M3 MCU. My application is very complicated, so I need to use an RTOS (FreeRTOS) inside.
When the first time I tried this library on my MCU, the program works fine. After I merge the library with my application, my CPU stops after executing RSA verification process. After tracing, I know the problem is within bignum.c file which rely heavily on malloc function (mpi_grow). The program works fine if I commented out all function related to it or change mpi_grow with a fixed length array.
But the problem is, due to my limited programming skill, not all mpi_grow can be converted to use fixed array successfully.
It is not recommended to use malloc in embedded processor, Is there any way to implement rsa algorithm without using malloc?
I understand that in some situations you can run into problems with malloc() on your MCU.
It is possible to make PolarSSL use no dynamic allocation at all for RSA. I'll try to see if I can get a write-up and patch in the Documentation section. If you need it sooner that end of next month, please contact me by mail (p.j.bakker at polarssl dot org)
I'm working on a thesis based on an STM Cortex-M3 and FreeRTOS + POLARSSL. I had the same problem with malloc in "mpi_grow".
In FreeRTOS you should use "pvPortMalloc" and "vPortFree" instead of "malloc" and "free". Read more on: http://www.freertos.org/a00111.html
I'm facing this problem also. My target is to port bignum&rsa functions to MCU(arm cortex m3). Any advice?
Polarssl is very good! Architecture is well designed, code is clean, document is find, and full of test and samples. It costed less for me to understand the lib.
take a look at: http://polarssl.org/forum_view_topic?topic_id=154 (ARM Cortex M3 LM3S6965 - RSA implementation)
I have a FW running with cortex-m3 and if you want I can send my source code to you... I also have a tool written with VC++ to send and recieve commands...
Im stduying on RSA implemantation too. Could you send me your source code me too.
In order to use the malloc() command on the Stellaris you
need to set the heap size in the startup file. it just below the stack size. malloc() uses that heap space for dynamic memory allocation.
I am trying to build PolarSSL into a embedded project on a MSP430/TI-CSS/TI-RTOS and would also appreciate if you could send me your example code.
I am using Cortex-M4(STM32F4), mbedTLS and not using any RTOS. I am also facing the same problem with calloc in mpi_grow.
Can anyone help me to resolve this issue.