diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-02-07 17:38:16 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-02-12 11:32:10 -0500 |
commit | 0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2 (patch) | |
tree | a9d0e1914c9bf8e136486ca02658029273e86be5 /src/or/fp_pair.c | |
parent | f05820531a1e4bc5935609900f0067b2643f0529 (diff) | |
download | tor-0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2.tar.gz tor-0e97c8e23e2572c14dd0f4f4fbfca77ee8a48be2.zip |
Siphash-2-4 is now our hash in nearly all cases.
I've made an exception for cases where I'm sure that users can't
influence the inputs. This is likely to cause a slowdown somewhere,
but it's safer to siphash everything and *then* look for cases to
optimize.
This patch doesn't actually get us any _benefit_ from siphash yet,
since we don't really randomize the key at any point.
Diffstat (limited to 'src/or/fp_pair.c')
-rw-r--r-- | src/or/fp_pair.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/or/fp_pair.c b/src/or/fp_pair.c index 4d8a835c83..55e4c89a42 100644 --- a/src/or/fp_pair.c +++ b/src/or/fp_pair.c @@ -32,17 +32,8 @@ fp_pair_map_entries_eq(const fp_pair_map_entry_t *a, static INLINE unsigned int fp_pair_map_entry_hash(const fp_pair_map_entry_t *a) { - const uint32_t *p; - unsigned int hash; - - p = (const uint32_t *)(a->key.first); - /* Hashes are 20 bytes long, so 5 times uint32_t */ - hash = p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4]; - /* Now XOR in the second fingerprint */ - p = (const uint32_t *)(a->key.second); - hash ^= p[0] ^ p[1] ^ p[2] ^ p[3] ^ p[4]; - - return hash; + tor_assert(sizeof(a->key) == DIGEST_LEN*2); + return (unsigned) siphash24g(&a->key, DIGEST_LEN*2); } /* |