esp32: Add esp_fill_random() function

Convenience function to fill a buffer with random bytes.

Add some unit tests (only sanity checks, really.)
This commit is contained in:
Angus Gratton
2018-08-15 18:20:16 +10:00
committed by bot
parent 767ec27350
commit 83a179abb0
12 changed files with 124 additions and 71 deletions

View File

@@ -14,14 +14,6 @@
#include "randombytes_default.h"
#include "esp_system.h"
static void randombytes_esp32_random_buf(void * const buf, const size_t size)
{
uint8_t *p = (uint8_t *)buf;
for (size_t i = 0; i < size; i++) {
p[i] = esp_random();
}
}
static const char *randombytes_esp32_implementation_name(void)
{
return "esp32";
@@ -39,7 +31,7 @@ const struct randombytes_implementation randombytes_esp32_implementation = {
.random = esp_random,
.stir = NULL,
.uniform = NULL,
.buf = randombytes_esp32_random_buf,
.buf = esp_fill_random,
.close = NULL,
};