diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-11-25 10:30:58 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-11-25 22:29:59 -0500 |
commit | dedea28c2ef59eb86f5d9704e5609ae13fa8b3c2 (patch) | |
tree | 92ddba2410a8a80aad28734be47c78c460bbd6e6 /src/common/crypto.h | |
parent | 232ccc18c40f0d0302b2e21b0f67885c548f8e63 (diff) | |
download | tor-dedea28c2ef59eb86f5d9704e5609ae13fa8b3c2.tar.gz tor-dedea28c2ef59eb86f5d9704e5609ae13fa8b3c2.zip |
Make crypto_seed_rng() and crypto_rand() less scary.
These functions must really never fail; so have crypto_rand() assert
that it's working okay, and have crypto_seed_rng() demand that
callers check its return value. Also have crypto_seed_rng() check
RAND_status() before returning.
Diffstat (limited to 'src/common/crypto.h')
-rw-r--r-- | src/common/crypto.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/crypto.h b/src/common/crypto.h index 6256f7346b..d2ced63bd5 100644 --- a/src/common/crypto.h +++ b/src/common/crypto.h @@ -16,6 +16,7 @@ #include <stdio.h> #include "torint.h" #include "testsupport.h" +#include "compat.h" /* Macro to create an arbitrary OpenSSL version number as used by @@ -258,7 +259,7 @@ int crypto_expand_key_material_rfc5869_sha256( uint8_t *key_out, size_t key_out_len); /* random numbers */ -int crypto_seed_rng(void); +int crypto_seed_rng(void) ATTR_WUR; MOCK_DECL(int,crypto_rand,(char *to, size_t n)); int crypto_rand_unmocked(char *to, size_t n); int crypto_strongest_rand(uint8_t *out, size_t out_len); |