tor  master
crypto_rand.h
Go to the documentation of this file.
1 /* Copyright (c) 2001, Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2018, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
13 #ifndef TOR_CRYPTO_RAND_H
14 #define TOR_CRYPTO_RAND_H
15 
16 #include "torint.h"
17 #include "util.h"
18 
19 /* random numbers */
20 int crypto_seed_rng(void) ATTR_WUR;
21 MOCK_DECL(void,crypto_rand,(char *to, size_t n));
22 void crypto_rand_unmocked(char *to, size_t n);
23 void crypto_strongest_rand(uint8_t *out, size_t out_len);
24 int crypto_rand_int(unsigned int max);
25 int crypto_rand_int_range(unsigned int min, unsigned int max);
26 uint64_t crypto_rand_uint64_range(uint64_t min, uint64_t max);
27 time_t crypto_rand_time_range(time_t min, time_t max);
28 uint64_t crypto_rand_uint64(uint64_t max);
29 double crypto_rand_double(void);
30 struct tor_weak_rng_t;
31 void crypto_seed_weak_rng(struct tor_weak_rng_t *rng);
32 
33 char *crypto_random_hostname(int min_rand_len, int max_rand_len,
34  const char *prefix, const char *suffix);
35 
36 struct smartlist_t;
37 void *smartlist_choose(const struct smartlist_t *sl);
38 void smartlist_shuffle(struct smartlist_t *sl);
39 int crypto_force_rand_ssleay(void);
40 
41 #ifdef CRYPTO_RAND_PRIVATE
42 
43 STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len);
44 
45 #ifdef TOR_UNIT_TESTS
46 extern int break_strongest_rng_syscall;
47 extern int break_strongest_rng_fallback;
48 #endif
49 #endif /* defined(CRYPTO_RAND_PRIVATE) */
50 
51 #endif /* !defined(TOR_CRYPTO_RAND_H) */
52 
char * crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix, const char *suffix)
Definition: crypto_rand.c:534
int crypto_force_rand_ssleay(void)
Definition: crypto_rand.c:600
uint64_t crypto_rand_uint64_range(uint64_t min, uint64_t max)
Definition: crypto_rand.c:464
int crypto_rand_int_range(unsigned int min, unsigned int max)
Definition: crypto_rand.c:450
MOCK_DECL(int, router_have_minimum_dir_info,(void))
double crypto_rand_double(void)
Definition: crypto_rand.c:509
Definition: container.h:18
Header file to define uint32_t and friends.
void smartlist_shuffle(struct smartlist_t *sl)
Definition: crypto_rand.c:584
STATIC int crypto_strongest_rand_raw(uint8_t *out, size_t out_len)
Definition: crypto_rand.c:266
int crypto_rand_int(unsigned int max)
Definition: crypto_rand.c:423
uint64_t crypto_rand_uint64(uint64_t max)
Definition: crypto_rand.c:485
Headers for util.c.
void crypto_seed_weak_rng(struct tor_weak_rng_t *rng)
Definition: crypto_rand.c:87
Definition: util.h:536
int crypto_seed_rng(void) ATTR_WUR
Definition: crypto_rand.c:356
void crypto_strongest_rand(uint8_t *out, size_t out_len)
Definition: crypto_rand.c:317
time_t crypto_rand_time_range(time_t min, time_t max)
Definition: crypto_rand.c:474
void crypto_rand_unmocked(char *to, size_t n)
Definition: crypto_rand.c:402
void * smartlist_choose(const smartlist_t *sl)
Definition: crypto_rand.c:572