From c1e98c8afe2973286f9bef28e760cbf95a2738fd Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 12 Feb 2014 11:46:58 -0500 Subject: Randomize the global siphash key at startup This completes our conversion to using siphash for our hash functions. --- src/ext/csiphash.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ext') diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c index 9a8833d10..30be40b51 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 #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; -- cgit v1.2.3