-
Notifications
You must be signed in to change notification settings - Fork 3k
Random Number Generator support #3045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes!
|
Awesome.
|
@nuket If you download nordic SDK V11, you will see a module handling the RNG. If the softdevice is present (which is always the case for now in mbed-OS), then the module relies on the softdevice primitives otherwise it use the registers available. That might give you inspiration if you look at this module until we add the support in mbed-os. |
Ahh yes, I was looking at the |
Awesome, the The Nordic SoftDevice RNG returns up to 32 bytes at a time. Unsure whether bias correction is enabled. In order to get more than 32 bytes of random data for the CTR-DRBG in SHA-512 mode, when |
Spoke a little too soon. The SoftDevice RNG seems to work fine, but attempting to seed the CTR-DRBG leads to a Hard Fault (blinkenlights!), which prints this on the console just before dying:
Which seems to indicate a stack overflow?
Based on comments in #2635, the default RTX stack size looks like it's 200 bytes:
Problem is that there's an allocation of 384 bytes in
I'm going to try setting a larger stack size for my target and see if that fixes the problem. For reference, I modified the BLE_HeartRate example main.cpp to look like this, to test my code in near-isolation, but with the SoftDevice running:
|
Hmm. Well, that didn't work. Setting |
Still unsure why this HardFault is happening. I instrumented mbedtls_ctr_drbg_reseed to look like:
But it dies right after printing the third line. Is anyone from Nordic following this issue? |
Hi. Did you have this #2969 included in mbed-os you using for development? |
BTW It is said that nRF52's RNG generates true non-deterministic random numbers based on internal |
Is it possible that softdevice RNG API had been called before bleInitComplete happened? |
Is there a reason why the RNG driver is not available in Nordic SDK v11 included in mbed-os? It seems to be there for the nRF51 and v13 of the SDK (only used for the nRF52840). |
Mbed OS SDK updates happening here |
New TRNG driver has been merged to master: #6116 |
Description
Target
Nordic nRF5x and any other chip with hardware RNG support
Enhancement
Are there any plans to design / implement an mbed OS API to access the Random Number Generator (RNG) available on Nordic and other chips? I'm trying to seed the mbed TLS CTR-DRBG implementation, but have no access to a good source of entropy. I've tried about all I can to use the hardware RNG unit, but nothing has worked, maybe someone from Nordic can jump in on this, maybe I'm forgetting to power up or enable the particular hardware unit.
Any attempt to perform write operations on the NRF_RNG register, as in the following code, causes the chip to infinitely reset immediately at start (as I try to use the RNG during the static initialization of a cryptographic Salt class):
The text was updated successfully, but these errors were encountered: