hardened_malloc/random.h

20 lines
477 B
C
Raw Normal View History

2018-08-22 00:53:22 +05:30
#ifndef RANDOM_H
#define RANDOM_H
2018-08-24 02:00:44 +05:30
#include <stdint.h>
#define RANDOM_CACHE_SIZE 4096
2018-08-22 00:53:22 +05:30
struct random_state {
2018-08-24 02:00:44 +05:30
size_t index;
uint8_t cache[RANDOM_CACHE_SIZE];
2018-08-22 00:53:22 +05:30
};
void get_random_seed(void *buf, size_t size);
void random_state_init(struct random_state *state);
void get_random_bytes(struct random_state *state, void *buf, size_t size);
size_t get_random_size(struct random_state *state);
size_t get_random_size_uniform(struct random_state *state, size_t bound);
#endif