diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-11-25 10:42:00 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-11-25 22:29:59 -0500 |
commit | ddcbe264745a0c10d80d8ad74125d23eb251662d (patch) | |
tree | b522f4302d71982a38ad0caf34b77b6c675103c2 /src/common/crypto.c | |
parent | 10fdee628552bca65ddb86b17e0b057628ad3703 (diff) | |
download | tor-ddcbe264745a0c10d80d8ad74125d23eb251662d.tar.gz tor-ddcbe264745a0c10d80d8ad74125d23eb251662d.zip |
Now that crypto_rand() cannot fail, it should return void.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 1ca86ea8f3..9e27ad30c4 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -270,8 +270,7 @@ crypto_init_siphash_key(void) if (have_seeded_siphash) return 0; - if (crypto_rand((char*) &key, sizeof(key)) < 0) - return -1; + crypto_rand((char*) &key, sizeof(key)); siphash_set_global_key(&key); have_seeded_siphash = 1; return 0; @@ -2368,27 +2367,26 @@ crypto_seed_rng(void) /** Write <b>n</b> bytes of strong random data to <b>to</b>. Return 0 on * success, -1 on failure, with support for mocking for unit tests. */ -MOCK_IMPL(int, +MOCK_IMPL(void, crypto_rand, (char *to, size_t n)) { - return crypto_rand_unmocked(to, n); + crypto_rand_unmocked(to, n); } /** Write <b>n</b> bytes of strong random data to <b>to</b>. Return 0 on * success, -1 on failure. Most callers will want crypto_rand instead. */ -int +void crypto_rand_unmocked(char *to, size_t n) { int r; if (n == 0) - return 0; + return; tor_assert(n < INT_MAX); tor_assert(to); r = RAND_bytes((unsigned char*)to, (int)n); tor_assert(r >= 0); - return 0; } /** Return a pseudorandom integer, chosen uniformly from the values |