summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-02-13 08:47:06 -0500
committerNick Mathewson <nickm@torproject.org>2018-02-13 08:47:06 -0500
commitef164346d4c6ee1b315e73917f3ec007b714a355 (patch)
treee7f06b88bcc8e570ab4730afc0733a9450fd33ef
parent4f98ec9fd370205f809c00180ea03f84cdb61dd1 (diff)
parent1555946e202fef523b35e169c90892b57caea766 (diff)
downloadtor-ef164346d4c6ee1b315e73917f3ec007b714a355.tar.gz
tor-ef164346d4c6ee1b315e73917f3ec007b714a355.zip
Merge remote-tracking branch 'dgoulet/ticket24902_029_05'
-rw-r--r--src/common/address.c7
-rw-r--r--src/common/address_set.c2
2 files changed, 6 insertions, 3 deletions
diff --git a/src/common/address.c b/src/common/address.c
index 1946a5f503..a2f4c93b91 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1185,6 +1185,9 @@ tor_addr_compare_masked(const tor_addr_t *addr1, const tor_addr_t *addr2,
}
}
+/** Input for siphash, to produce some output for an unspec value. */
+static const uint32_t unspec_hash_input[] = { 0x4e4df09f, 0x92985342 };
+
/** Return a hash code based on the address addr. DOCDOC extra */
uint64_t
tor_addr_hash(const tor_addr_t *addr)
@@ -1193,7 +1196,7 @@ tor_addr_hash(const tor_addr_t *addr)
case AF_INET:
return siphash24g(&addr->addr.in_addr.s_addr, 4);
case AF_UNSPEC:
- return 0x4e4d5342;
+ return siphash24g(unspec_hash_input, sizeof(unspec_hash_input));
case AF_INET6:
return siphash24g(&addr->addr.in6_addr.s6_addr, 16);
/* LCOV_EXCL_START */
@@ -1215,7 +1218,7 @@ tor_addr_keyed_hash(const struct sipkey *key, const tor_addr_t *addr)
case AF_INET:
return siphash24(&addr->addr.in_addr.s_addr, 4, key);
case AF_UNSPEC:
- return 0x4e4d5342;
+ return siphash24(unspec_hash_input, sizeof(unspec_hash_input), key);
case AF_INET6:
return siphash24(&addr->addr.in6_addr.s6_addr, 16, key);
default:
diff --git a/src/common/address_set.c b/src/common/address_set.c
index ea48c1638e..f61fa294e0 100644
--- a/src/common/address_set.c
+++ b/src/common/address_set.c
@@ -22,7 +22,7 @@
/** How many 64-bit siphash values to extract per address */
#define N_HASHES 2
/** How many bloom-filter bits we set per address. This is twice the N_HASHES
- * value, since we split the siphash outcome two 32-bit values. */
+ * value, since we split the siphash output into two 32-bit values. */
#define N_BITS_PER_ITEM (N_HASHES * 2)
/* XXXX This code is largely duplicated with digestset_t. We should merge