Ability to disable RSSI-based random number generator in radio.c #621
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows library users to disable the random number generator in
radio.c
and replace it with a custom one.LoRaWAN 1.0 specs requires
DevNonce
to be a random number. The specs asks specifically a high quality random and proposes the wideband RSSI measurement as a random source ("TheDevNonce
can be extracted by issuing a sequence of RSSI measurements under the assumption that the quality of randomness fulfills the criteria of true randomness").LMIC library implements exactly that. The implementation seeds its random number generator with 120 random bits using RSSI measurement and von Neumann random extraction technique. This requires at least, on average 480 SPI read operations to
LORARegRssiWideband
register, while the radio is kept inRXMODE_RSSI
.On my implementation (STM32L4 + ST-provided HAL functions for SPI) seeding the RNG takes about 150ms. As the radio is kept powered down by default, it is a huge burden on each re-init, especially since many MCU's have built-in true-RNGs (which completes in my case in ~50 CPU cycles).
What changed?
LMIC_DISABLE_RADIO_RAND
) to completely disable the random number generator inradio.c
oslmic.h
, movedu1_t radio_rand1 (void);
from a seemingly random location next to other os/radio related definitions.#define os_getRndU1() radio_rand1()
moved next to other os defines, in a similar manner as the rest os-related defines are created