mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 06:13:31 +01:00
Merge remote-tracking branch 'dgoulet/ticket24902_029_05'
This commit is contained in:
commit
ef164346d4
@ -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 */
|
/** Return a hash code based on the address addr. DOCDOC extra */
|
||||||
uint64_t
|
uint64_t
|
||||||
tor_addr_hash(const tor_addr_t *addr)
|
tor_addr_hash(const tor_addr_t *addr)
|
||||||
@ -1193,7 +1196,7 @@ tor_addr_hash(const tor_addr_t *addr)
|
|||||||
case AF_INET:
|
case AF_INET:
|
||||||
return siphash24g(&addr->addr.in_addr.s_addr, 4);
|
return siphash24g(&addr->addr.in_addr.s_addr, 4);
|
||||||
case AF_UNSPEC:
|
case AF_UNSPEC:
|
||||||
return 0x4e4d5342;
|
return siphash24g(unspec_hash_input, sizeof(unspec_hash_input));
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return siphash24g(&addr->addr.in6_addr.s6_addr, 16);
|
return siphash24g(&addr->addr.in6_addr.s6_addr, 16);
|
||||||
/* LCOV_EXCL_START */
|
/* LCOV_EXCL_START */
|
||||||
@ -1215,7 +1218,7 @@ tor_addr_keyed_hash(const struct sipkey *key, const tor_addr_t *addr)
|
|||||||
case AF_INET:
|
case AF_INET:
|
||||||
return siphash24(&addr->addr.in_addr.s_addr, 4, key);
|
return siphash24(&addr->addr.in_addr.s_addr, 4, key);
|
||||||
case AF_UNSPEC:
|
case AF_UNSPEC:
|
||||||
return 0x4e4d5342;
|
return siphash24(unspec_hash_input, sizeof(unspec_hash_input), key);
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
return siphash24(&addr->addr.in6_addr.s6_addr, 16, key);
|
return siphash24(&addr->addr.in6_addr.s6_addr, 16, key);
|
||||||
default:
|
default:
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/** How many 64-bit siphash values to extract per address */
|
/** How many 64-bit siphash values to extract per address */
|
||||||
#define N_HASHES 2
|
#define N_HASHES 2
|
||||||
/** How many bloom-filter bits we set per address. This is twice the N_HASHES
|
/** 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)
|
#define N_BITS_PER_ITEM (N_HASHES * 2)
|
||||||
|
|
||||||
/* XXXX This code is largely duplicated with digestset_t. We should merge
|
/* XXXX This code is largely duplicated with digestset_t. We should merge
|
||||||
|
Loading…
Reference in New Issue
Block a user