mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 12:10:59 +00:00
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:
@@ -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,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user