use ChaCha8-based CSPRNG

This commit is contained in:
Daniel Micay 2018-08-25 23:00:00 -04:00
parent 2b7c9362bb
commit c41e659383
5 changed files with 235 additions and 7 deletions

View file

@ -3,10 +3,15 @@
#include <stdint.h>
#define RANDOM_CACHE_SIZE 4096
#include "chacha.h"
#define RANDOM_CACHE_SIZE 256ULL
#define RANDOM_RESEED_SIZE 256ULL * 1024
struct random_state {
size_t index;
size_t reseed;
chacha_ctx ctx;
uint8_t cache[RANDOM_CACHE_SIZE];
};