diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-02-12 11:46:58 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-02-12 12:12:58 -0500 |
commit | c1e98c8afe2973286f9bef28e760cbf95a2738fd (patch) | |
tree | 11cc4f29d43fc020204cde717733cc4bc1b791c8 /src/ext | |
parent | d3fb846d8c98c13d349762682e714e8312f20270 (diff) | |
download | tor-c1e98c8afe2973286f9bef28e760cbf95a2738fd.tar.gz tor-c1e98c8afe2973286f9bef28e760cbf95a2738fd.zip |
Randomize the global siphash key at startup
This completes our conversion to using siphash for our hash functions.
Diffstat (limited to 'src/ext')
-rw-r--r-- | src/ext/csiphash.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c index 9a8833d104..30be40b518 100644 --- a/src/ext/csiphash.c +++ b/src/ext/csiphash.c @@ -31,6 +31,9 @@ #include "torint.h" #include "siphash.h" +/* for tor_assert */ +#include "util.h" +/* for memcpy */ #include <string.h> #if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \ @@ -137,11 +140,13 @@ static int the_siphash_key_is_set = 0; static struct sipkey the_siphash_key; uint64_t siphash24g(const void *src, unsigned long src_sz) { + tor_assert(the_siphash_key_is_set); return siphash24(src, src_sz, &the_siphash_key); } void siphash_set_global_key(const struct sipkey *key) { + tor_assert(! the_siphash_key_is_set); the_siphash_key.k0 = key->k0; the_siphash_key.k1 = key->k1; the_siphash_key_is_set = 1; |