mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-24 08:51:14 -04:00
use ChaCha8-based CSPRNG
This commit is contained in:
parent
2b7c9362bb
commit
c41e659383
5 changed files with 235 additions and 7 deletions
7
random.h
7
random.h
|
@ -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];
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue