Topic: Implementation of ECC on STM32f446
Dear friends
I am going to implement ECC on launchpad stm32 Nucleo f446re + with FreeRTOS
First. because I am a new guy in this field what configuration I have to do before programming.
I did these configurations
1- I compiled the library for STM32 cortex m4 and linked it to my IDE
2- I defined these Items based of WOLFSSL STM32 SUPPORT
https://www.wolfssl.com/docs/stm32
WOLFSSL_STM32F4
FREERTOS
HAVE_ECC_SIGN
HAVE_ECC_VERIFY
STM32_RNG
STM32_CRYPTO
STM32
but the program gets stuck in the rng initiation function?
wc_InitRng(&rng);
I removed all other function to find the problem you can see the code here, it is Freertos template with two tasks that I put this function in task 2
#include <stdio.h>
#include <string.h>
#include <wolfssl/wolfcrypt/random.h>
#include <wolfssl/options.h>
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/ecc.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/wolfcrypt/hash.h>
#include "stm32f4xx.h"
#include "FreeRTOS.h" //provides TaskHandle_t
#include "task.h" //to create tasks
/**define some macro for making condition in tasks***************************************/
/**define global variable **************************************************************/
TaskHandle_t xTaskHandle1=NULL;
TaskHandle_t xTaskHandle2=NULL;
WC_RNG rng; // Data structure to keep random number
int ret = 0; // defining variable to keep status
/**prototype of functions****************************************************************/
extern void initialise_monitor_handles(); //0-to enable Semihosting -
void vTask1_handler(void *params);
void vTask2_handler(void *params);
/**main()********************************************************************************/
int main(void)
{
//0-to enable Semihosting exclude syscalls.c printf()
initialise_monitor_handles();
//project would work fine even without these two steps
//1.Resets the RCC clock configuration to the default reset state.HSI= ON, PLL OFF, system clock = 16 MHz, cpu_clock= 16MHz
RCC_DeInit();
//2.update the SystemCoreClock variable
SystemCoreClockUpdate();
//3. lets create 2 tasks, task-1 and task-2
xTaskCreate( vTask1_handler, "Hello_Task-1", configMINIMAL_STACK_SIZE, NULL, 2, &xTaskHandle1);
xTaskCreate( vTask2_handler, "Hello_Task-2", configMINIMAL_STACK_SIZE, NULL, 2, &xTaskHandle2);
printf("Start Program \n");
//4. enable scheduler to schedule tasks to run
vTaskStartScheduler();
for(;;);
}
/**Task 1********************************************************************************/
void vTask1_handler(void *params)
{
while(1)
{
printf("Start Task1\n");
printf("ret is =%d",ret);
printf("Finish Task 1 \n");
}
}
/**Task 2********************************************************************************/
void vTask2_handler(void *params)
{
while(1)
{
printf("Start Task2\n");
ret = wc_InitRng(&rng); //Gets the seed (from OS) and key cipher for rng.
printf("ret is =%d",ret);
printf("Finish Task 2 \n");
}
}
second, do you have any suggestions?