The AVR series microcontrollers are a collection of cheap and versatile chips that are used in many applications ranging from hobbist projects to commercial infrastructure. One major problem for some hobbists is the lack of secure random number generation on the Arduino platform. The included pseudo-random number generator (PRNG) is very easy to defeat and is useless for any crypto-related uses. One recommendation from the Arduino Reference Manual is to use atmospheric noise from the chip's analog sensor pins as seed data[6].
Unfortunately this method is extremely weak and should not be used to emulate a true random number generator (TRNG). Existing methods such as using the internal timer drift or using a dedicated generator are either too slow, requires extensive external hardware or modifications to the microcontroller's internal mech
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BIRTHDAY SPACINGS TEST, M= 512 N=2**24 LAMBDA= 2.0000 | |
data.bin using bits 1 to 24 p-value= .241977 | |
data.bin using bits 2 to 25 p-value= .994238 | |
data.bin using bits 3 to 26 p-value= .190980 | |
data.bin using bits 4 to 27 p-value= .088161 | |
data.bin using bits 5 to 28 p-value= .449030 | |
data.bin using bits 6 to 29 p-value= .584528 | |
data.bin using bits 7 to 30 p-value= .098073 | |
data.bin using bits 8 to 31 p-value= .549704 | |
data.bin using bits 9 to 32 p-value= .932893 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <MPU6050.h> | |
uint8_t randomByte(uint8_t analogPin) { | |
int firstValue = analogRead(analogPin); | |
const uint8_t minTemporalEntropyScale = 8; //Resolution in microseconds of the onboard micros() timer | |
int bitsCaptured = 0; |