Enhance randomness (AVR, ESP8266, Linux, NRF5) (#845)
This commit changes the way random numbers are available with MySensors. The AVR platform uses a 32 Bit random seed build from a floating analog pin. The way of the generation of this seed is FIPS 140-2 compliant. For support MCU with a fast way to generate random data, the hwGetentropy() command is now available to allow rapid generation of random data. The ESP8266 platform uses the internal random source for randomness for hwGetentropy() and Arduino's random() function. The NRF5 platform initializes the pseudo random number generator from internal hardware number generator. The internal AES-ECB unit generates random data after filling with HWRNG data by AES-CBC. On Linux getrandom() is implemented via syscall(). signerAtsha204SoftGetNonce speed: AVR = ~14000us (sha204Soft) NRF51 = ~152us (AES-CBC), 1739us (old sha204Soft) NRF52 = ~31us (AES-CBC), 183us (old sha204Soft) ESP8266 = ~20us (RANDOM_REG32), 380us (old sha204Soft) All Nonce results tested for FIPS 140-2 compliance successfully.
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
*
|
||||
* @b Important<br>
|
||||
* You will need to ensure @ref MY_SIGNING_SOFT_RANDOMSEED_PIN is set to an unconnected analog pin
|
||||
* in order to provide entropy to the software RNG.
|
||||
* in order to provide entropy to the software RNG if your hardware has no HWRNG.
|
||||
*
|
||||
* @note The generated keys displayed in the serial log with this setting needs to be written down
|
||||
* and transferred to all nodes this gateway will communicate with. This is mandatory for ALL
|
||||
@@ -436,7 +436,7 @@ void setup()
|
||||
while (hwMillis() - enter < (unsigned long)500);
|
||||
#ifdef USE_SOFT_SIGNING
|
||||
// initialize pseudo-RNG
|
||||
randomSeed(analogRead(MY_SIGNING_SOFT_RANDOMSEED_PIN));
|
||||
hwRandomNumberInit();
|
||||
#endif
|
||||
|
||||
Serial.begin(MY_BAUD_RATE);
|
||||
|
||||
Reference in New Issue
Block a user