Tried using srand with rand to achieve more randomness. sudo cat /dev/pico_rng | rngtest -c 1000 still says that it is not even close to being good enough. Although, if we feed this data into the kernel with the other data sources it should be FIPS 140-2 compliant. By itself it is not.

This commit is contained in:
Mickey Malone
2021-02-12 07:34:15 -06:00
parent ce9e5deb54
commit 5571c8809c

View File

@@ -5,6 +5,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
// Pico
#include "pico/stdlib.h"
@@ -563,6 +564,23 @@ void get_random_data(char *buf, uint16_t len) {
memcpy(&buf[i-1], (void*)&adc_result, 2);
}
/**
* In an attempt to make the rng even more random this will slow down the amount of data the
* pico can generate. It appears to be more random, but not good enough for FIPS 140-2.
**/
/**
//Use the ADC as a seed to the arm gnu stdlib random number generator
srand((int)(adc_read() | (adc_read() << 16)));
memset(buf, 0, len);
int rand_result;
for(i = 0; i <= len-4; i=i+4)
{
rand_result = rand();
memcpy(&buf[i], (void*)&rand_result, 4);
}
**/
gpio_put(25, 0);
}