I am trying to use functions of ecdh example in my softdevice based project.
err_code = nrf_crypto_ecc_key_pair_generate(NULL, &g_nrf_crypto_ecc_secp256r1_curve_info, &m_bob_private_key, &bob_public_key);
key generator function you see below crashes my application. Firstly I have tried to debug with Keil but it gave "softdevice assertion error" which I think is not about the bug, the debugging itself. So I have done something different to debug it, I looked into function and went through SDK files, and finally, I see that "nrf_crypto_rng_vector_generate" function makes the application crashed (When I make this line comment, it is not crashed)
After seeing this, in order to look what's going on, I write code and directly used "nrf_crypto_rng_vector_generate" on my main code. And used APP_ERROR_CHECK for investigating whats it throwing.
#define VECTOR_LENGTH 10 uint8_t m_random_vector[VECTOR_LENGTH]; // Result buffer. uint8_t m_min[VECTOR_LENGTH] = {0x00, 0x00, 0xFF}; // Lower bound as big-endian. uint8_t m_max[VECTOR_LENGTH] = {0x00, 0xFF, 0xFF}; // Upper bound as big-endian. // Generate a random vector of specified length. ret_code_t ret_val; ret_val = nrf_crypto_rng_vector_generate(m_random_vector, VECTOR_LENGTH); APP_ERROR_CHECK(ret_val);
Then I used J-Link RTT viewer, for getting error code, it returns 34050 which is an unknown error code.
Then I've tried to use "random_vector_generate" function placed in nrf_drv_rng.c for knowing whether it is a pure softdevice problem or not, and then it worked. So i think it is possible to use rng module while softdevice running. But I don't know and can't found something about whether the crypto library can be used with softdevice or not. Please help.
Softdevice that I use: s132_nrf52_6.1.1
SDK : nRF5_SDK_15.2.0