tor  0.4.2.0-alpha-dev
weakrng.h
Go to the documentation of this file.
1 /* Copyright (c) 2003, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
12 #ifndef TOR_WEAKRNG_H
13 #define TOR_WEAKRNG_H
14 
15 #include "lib/cc/torint.h"
16 
17 /* ===== Insecure rng */
18 typedef struct tor_weak_rng_t {
19  uint32_t state;
21 
22 #define TOR_WEAK_RNG_INIT {383745623}
23 #define TOR_WEAK_RANDOM_MAX (INT_MAX)
24 void tor_init_weak_random(tor_weak_rng_t *weak_rng, unsigned seed);
25 int32_t tor_weak_random(tor_weak_rng_t *weak_rng);
26 int32_t tor_weak_random_range(tor_weak_rng_t *rng, int32_t top);
29 #define tor_weak_random_one_in_n(rng, n) (0==tor_weak_random_range((rng),(n)))
30 
31 #endif /* !defined(TOR_WEAKRNG_H) */
int32_t tor_weak_random(tor_weak_rng_t *weak_rng)
Definition: weakrng.c:32
int32_t tor_weak_random_range(tor_weak_rng_t *rng, int32_t top)
Definition: weakrng.c:48
Integer definitions used throughout Tor.
void tor_init_weak_random(tor_weak_rng_t *weak_rng, unsigned seed)
Definition: weakrng.c:22