This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

any limitation to call nrf_drv_rng_rand?

I am developing SDK17.0.0 based application with S112. 

when I try getting a random value at the end of main, the nrf_drv_rng_rand return err_code=0x05, and it leads to "<error> app: Fatal error and <warning> app: System reset".

When I use button to trigger nrf_drv_rng_rand call, it works well.

Is it known issue? How can I workaround it?

Thanks,

srony

Parents
  • Hi,

    0x05 is NRF_ERROR_NOT_FOUND and that is returned if there is not enough buffered random data (underlying call to sd_rand_application_vector_get() returned NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES). So in this case you could wait a bit and try again later or request fewer random bytes and try again. Generally you need to wait a bit for the random data to be generated, and if you need more TRNG data in one go you may also need to set RNG_CONFIG_POOL_SIZE in sdk_config.h higher.

    (If you need a lot of random data and/or need it fast you may want to use the RNG feature of nrf_crypto instead. That way you can get much more random numbers faster, as it uses the RNG peripheral to seed the mbed TLS CTR-DRBG implementation. This would also follow NIST SP 800-90A Revision 1.)

Reply
  • Hi,

    0x05 is NRF_ERROR_NOT_FOUND and that is returned if there is not enough buffered random data (underlying call to sd_rand_application_vector_get() returned NRF_ERROR_SOC_RAND_NOT_ENOUGH_VALUES). So in this case you could wait a bit and try again later or request fewer random bytes and try again. Generally you need to wait a bit for the random data to be generated, and if you need more TRNG data in one go you may also need to set RNG_CONFIG_POOL_SIZE in sdk_config.h higher.

    (If you need a lot of random data and/or need it fast you may want to use the RNG feature of nrf_crypto instead. That way you can get much more random numbers faster, as it uses the RNG peripheral to seed the mbed TLS CTR-DRBG implementation. This would also follow NIST SP 800-90A Revision 1.)

Children
Related