Skip to content

Instantly share code, notes, and snippets.

View bloc97's full-sized avatar
🧢

bloc97

🧢
  • Université de Montréal
  • Canada
View GitHub Profile
@bloc97
bloc97 / Method1_Diehard.log
Created December 30, 2017 23:04
Diehard test log for Method 1
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
@bloc97
bloc97 / 1024us.png
Last active January 2, 2018 03:22
TwoMethodsFigures
1024us.png
@bloc97
bloc97 / TwoMethods.md
Last active February 20, 2024 12:19
Two Fast Methods of Generating True Random Numbers on the Arduino

Two Fast Methods of Generating True Random Numbers on the Arduino

Arduino true random number generator

B. Peng

December 2017

Abstract

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

@bloc97
bloc97 / arduino_entropy_rng.c
Last active December 29, 2017 19:49
Two methods of harvesting entropy from an Arduino microcontroller board. Pseudo-Publication here: https://gist.github.com/bloc97/b55f684d17edd8f50df8e918cbc00f94
#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;