3 ms·
Why the hell would a HashMap use a cryptographically secure hash?
by Traubenfuchs 3y ago
Why the hell would a HashMap use a cryptographically secure hash?
- kaba0 3y agoI believe rust’s hashmap does have an implementation that is immune to timing-based attacks and that does have a performance cost. Maybe that’s what parent mixed it up with.
- Twirrim 3y agoI was trying to use the specific phrasing the fxhash crate authors used, but screwed it up. Brain was half asleep when I wrote my comment, I think. > It is not a cryptographically secure hash, so it is strongly recommended that you do not use this hash for cryptographic purproses. Furthermore, this hashing algorithm was not designed to prevent any attacks for determining collisions which could be used to potentially cause quadratic behavior in HashMaps. So it is not recommended to expose this hash in places where collissions or DDOS attacks may be a concern.
- kzrdude 3y agoHashMap uses SipHash. To call it cryptographically secure is not a clear way of summarizing what it provides. See Wikipedia for more info. Blurb: > It was designed to be efficient even for short inputs, with performance comparable to non-cryptographic hash functions, such as CityHash, this can be used to prevent denial-of-service attacks against hash tables ("hash flooding") [...]
- Traubenfuchs 3y ago> "hash flooding" I did not know this was a thing. What a massive amount of engineering effort is being wasted on protecting against outlandish attacks!