Tor
0.4.7.0-alpha-dev
|
Functions for retrieving uniformly distributed numbers from our PRNGs. More...
Go to the source code of this file.
Macros | |
#define | IMPLEMENT_RAND_UNSIGNED(type, maxval, limit, fill_stmt) |
Functions | |
unsigned | crypto_rand_uint (unsigned limit) |
int | crypto_rand_int (unsigned int max) |
int | crypto_rand_int_range (unsigned int min, unsigned int max) |
uint64_t | crypto_rand_uint64_range (uint64_t min, uint64_t max) |
time_t | crypto_rand_time_range (time_t min, time_t max) |
uint64_t | crypto_rand_uint64 (uint64_t max) |
double | crypto_rand_double (void) |
unsigned | crypto_fast_rng_get_uint (crypto_fast_rng_t *rng, unsigned limit) |
uint64_t | crypto_fast_rng_get_uint64 (crypto_fast_rng_t *rng, uint64_t limit) |
uint32_t | crypto_fast_rng_get_u32 (crypto_fast_rng_t *rng) |
uint64_t | crypto_fast_rng_uint64_range (crypto_fast_rng_t *rng, uint64_t min, uint64_t max) |
double | crypto_fast_rng_get_double (crypto_fast_rng_t *rng) |
Functions for retrieving uniformly distributed numbers from our PRNGs.
Definition in file crypto_rand_numeric.c.
#define IMPLEMENT_RAND_UNSIGNED | ( | type, | |
maxval, | |||
limit, | |||
fill_stmt | |||
) |
Implementation macro: yields code that returns a uniform unbiased random number between 0 and limit. "type" is the type of the number to return; "maxval" is the largest possible value of "type"; and "fill_stmt" is a code snippet that fills an object named "val" with random bits.
Definition at line 17 of file crypto_rand_numeric.c.
double crypto_fast_rng_get_double | ( | crypto_fast_rng_t * | rng | ) |
As crypto_rand_get_double() but extract the result from a crypto_fast_rng_t.
Definition at line 188 of file crypto_rand_numeric.c.
uint32_t crypto_fast_rng_get_u32 | ( | crypto_fast_rng_t * | rng | ) |
As crypto_rand_u32, but extract the result from a crypto_fast_rng_t.
Definition at line 161 of file crypto_rand_numeric.c.
Referenced by genpareto_sample(), geometric_sample(), log_logistic_sample(), logistic_sample(), random_uniform_01(), and weibull_sample().
unsigned crypto_fast_rng_get_uint | ( | crypto_fast_rng_t * | rng, |
unsigned | limit | ||
) |
As crypto_rand_uint, but extract the result from a crypto_fast_rng_t
Definition at line 139 of file crypto_rand_numeric.c.
Referenced by circuit_reset_sendme_randomness(), and extend_info_pick_orport().
uint64_t crypto_fast_rng_get_uint64 | ( | crypto_fast_rng_t * | rng, |
uint64_t | limit | ||
) |
As crypto_rand_uint64, but extract the result from a crypto_fast_rng_t.
Definition at line 150 of file crypto_rand_numeric.c.
uint64_t crypto_fast_rng_uint64_range | ( | crypto_fast_rng_t * | rng, |
uint64_t | min, | ||
uint64_t | max | ||
) |
As crypto_rand_uint64_range(), but extract the result from a crypto_fast_rng_t.
Definition at line 173 of file crypto_rand_numeric.c.
double crypto_rand_double | ( | void | ) |
Return a pseudorandom double d, chosen uniformly from the range 0.0 <= d < 1.0.
Definition at line 126 of file crypto_rand_numeric.c.
int crypto_rand_int | ( | unsigned int | max | ) |
Return a pseudorandom integer, chosen uniformly from the values between 0 and max-1 inclusive. max must be between 1 and INT_MAX+1, inclusive.
Definition at line 52 of file crypto_rand_numeric.c.
Referenced by channelpadding_get_circuits_available_timeout(), channelpadding_get_netflow_inactive_timeout_ms(), choose_array_element_by_weight(), and crypto_rand_int_range().
int crypto_rand_int_range | ( | unsigned int | min, |
unsigned int | max | ||
) |
Return a pseudorandom integer, chosen uniformly from the values i such that min <= i < max.
min MUST be in range [0, max). max MUST be in range (min, INT_MAX].
Definition at line 71 of file crypto_rand_numeric.c.
Referenced by crypto_random_hostname().
time_t crypto_rand_time_range | ( | time_t | min, |
time_t | max | ||
) |
As crypto_rand_int_range, but supports time_t.
Definition at line 95 of file crypto_rand_numeric.c.
Referenced by randomize_time().
unsigned crypto_rand_uint | ( | unsigned | limit | ) |
Return a pseudorandom integer chosen uniformly from the values between 0 and limit-1 inclusive. limit must be strictly greater than 0, and less than UINT_MAX.
Definition at line 39 of file crypto_rand_numeric.c.
Referenced by crypto_rand_int().
uint64_t crypto_rand_uint64 | ( | uint64_t | max | ) |
Return a pseudorandom 64-bit integer, chosen uniformly from the values between 0 and max-1 inclusive.
Definition at line 106 of file crypto_rand_numeric.c.
Referenced by choose_array_element_by_weight(), crypto_rand_time_range(), and crypto_rand_uint64_range().
uint64_t crypto_rand_uint64_range | ( | uint64_t | min, |
uint64_t | max | ||
) |
As crypto_rand_int_range, but supports uint64_t.
Definition at line 85 of file crypto_rand_numeric.c.