pub struct ClientHashBuilder { /* private fields */ }Expand description
A fast, seeded hasher for short keys.
The default HashMap hasher is SipHash-1-3, chosen for resistance to
collision floods. That resistance is not optional here — the key is a
client’s source address, which an attacker picks — but SipHash’s cost is
out of proportion to a 4-to-17-byte key: with everything else in the client
table fixed, callgrind still attributed ~32% of the server’s per-request
instructions to hashing one address once.
So this keeps the property and drops the price. The seed is drawn from the
OS once per process via RandomState, exactly as SipHash’s keys are, so an
attacker cannot compute which addresses collide without first learning a
secret they never see. What is given up is SipHash’s proof against an
adversary who somehow does learn the seed; what is kept is the practical
defence, on a table that is additionally bounded to a fixed capacity with
LRU eviction, so even a successful collision attack cannot grow a chain
without bound.
Trait Implementations§
Source§impl BuildHasher for ClientHashBuilder
impl BuildHasher for ClientHashBuilder
Source§impl Clone for ClientHashBuilder
impl Clone for ClientHashBuilder
Source§fn clone(&self) -> ClientHashBuilder
fn clone(&self) -> ClientHashBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more