13 #ifndef TOR_CRYPTO_RAND_H
14 #define TOR_CRYPTO_RAND_H
39 const char *prefix,
const char *suffix);
60 #define CRYPTO_FAST_RNG_SEED_LEN 48
64 #define crypto_fast_rng_free(c) \
65 FREE_AND_NULL(crypto_fast_rng_t, crypto_fast_rng_free_, (c))
71 uint64_t min, uint64_t max);
80 #define crypto_fast_rng_one_in_n(rng, n) \
81 (0 == (crypto_fast_rng_get_uint((rng), (n))))
92 #if defined(TOR_UNIT_TESTS)
94 size_t crypto_fast_rng_get_bytes_used_per_stream(
void);
101 #ifdef CRYPTO_RAND_PRIVATE
105 #ifdef TOR_UNIT_TESTS
106 extern int break_strongest_rng_syscall;
107 extern int break_strongest_rng_fallback;
Utility macros to handle different features and behavior in different compilers.
STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len)
void * smartlist_choose(const smartlist_t *sl)
uint64_t crypto_fast_rng_uint64_range(crypto_fast_rng_t *rng, uint64_t min, uint64_t max)
int crypto_seed_rng(void) ATTR_WUR
crypto_fast_rng_t * get_thread_fast_rng(void)
void smartlist_shuffle(struct smartlist_t *sl)
crypto_fast_rng_t * crypto_fast_rng_new(void)
time_t crypto_rand_time_range(time_t min, time_t max)
crypto_fast_rng_t * crypto_fast_rng_new_from_seed(const uint8_t *seed)
void crypto_strongest_rand_(uint8_t *out, size_t out_len)
char * crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix, const char *suffix)
void crypto_rand(char *to, size_t n)
uint64_t crypto_rand_uint64_range(uint64_t min, uint64_t max)
double crypto_fast_rng_get_double(crypto_fast_rng_t *rng)
uint32_t crypto_fast_rng_get_u32(crypto_fast_rng_t *rng)
uint64_t crypto_fast_rng_get_uint64(crypto_fast_rng_t *rng, uint64_t limit)
uint32_t crypto_rand_u32(void)
unsigned crypto_fast_rng_get_uint(crypto_fast_rng_t *rng, unsigned limit)
unsigned crypto_rand_uint(unsigned limit)
void crypto_rand_unmocked(char *to, size_t n)
void crypto_seed_weak_rng(struct tor_weak_rng_t *rng)
void crypto_fast_rng_free_(crypto_fast_rng_t *)
int crypto_force_rand_ssleay(void)
double crypto_rand_double(void)
int crypto_rand_int_range(unsigned int min, unsigned int max)
void crypto_fast_rng_getbytes(crypto_fast_rng_t *rng, uint8_t *out, size_t n)
uint64_t crypto_rand_uint64(uint64_t max)
void crypto_strongest_rand(uint8_t *out, size_t out_len)
int crypto_rand_int(unsigned int max)
void destroy_thread_fast_rng(void)
void crypto_rand_fast_init(void)
void crypto_rand_fast_shutdown(void)
Headers for util_malloc.c.
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Integer definitions used throughout Tor.