aboutsummaryrefslogtreecommitdiff
path: root/src/common/crypto.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-04-21 10:17:12 -0400
committerDavid Goulet <dgoulet@ev0ke.net>2015-04-21 11:06:12 -0400
commit3f413184728c1d7b441b8e54585c43220665218c (patch)
tree4098cf1f1c596e98a3be1a5c78f3d07aa3d353e8 /src/common/crypto.h
parent6f6881c4324f35d44b997591939de7e847cca7a3 (diff)
downloadtor-3f413184728c1d7b441b8e54585c43220665218c.tar.gz
tor-3f413184728c1d7b441b8e54585c43220665218c.zip
Add crypto_rand_int_range() and use it
Incidently, this fixes a bug where the maximum value was never used when only using crypto_rand_int(). For instance this example below in rendservice.c never gets to INTRO_POINT_LIFETIME_MAX_SECONDS. int intro_point_lifetime_seconds = INTRO_POINT_LIFETIME_MIN_SECONDS + crypto_rand_int(INTRO_POINT_LIFETIME_MAX_SECONDS - INTRO_POINT_LIFETIME_MIN_SECONDS); Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/common/crypto.h')
-rw-r--r--src/common/crypto.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/common/crypto.h b/src/common/crypto.h
index b9c26a4551..3de3c7ea28 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -254,6 +254,7 @@ int crypto_seed_rng(int startup);
MOCK_DECL(int,crypto_rand,(char *to, size_t n));
int crypto_strongest_rand(uint8_t *out, size_t out_len);
int crypto_rand_int(unsigned int max);
+int crypto_rand_int_range(unsigned int min, unsigned int max);
uint64_t crypto_rand_uint64(uint64_t max);
double crypto_rand_double(void);
struct tor_weak_rng_t;