3 ms·
The spectrum of hash functions can be outlined in a fairly straightforward manner: A) Perceptual (fast, similar inputs result in similar hashes - by design) B
by criticaltinker 5y ago
The spectrum of hash functions can be outlined in a fairly straightforward manner:
A) Perceptual (fast, similar inputs result in similar hashes - by design)
B) Checksum (fast, hash collisions from different inputs should be expected - by chance)
C) Cryptographic (slow, similar inputs results in very different hashes - by design)
Many security vulnerabilities involving hash functions come from using A or B when C should have been used. More subtle vulnerabilities come from not using a cryptographically strong algorithm for C (eg SHA1, and more recently SHA2), or not appending a unique and random "salt" to every input of C - so when your database is compromised attackers can pre-compute hashes for common passwords (if the attacker also has access to the secret key supplied to the hash function).
As the OP notes, these are fairly well known hazards which are easy to find more information on. I enjoyed reading about the more nuanced scenarios brought up by OP since they aren't as commonly discussed.
- CodesInChaos 5y agoIn cryptographic context there are very different hash functions: * Password hashes including password based key derivation functions. These are salted and deliberately expensive to compute. For example bcrypt, scrypt or argon2. Salted sha2 is not suitable for this purpose. * collision resistant hash functions like SHA2/3. They're designed to be fast, but can't keep up with non cryptographic hashes/checksums * keyed hashes. This includes pseudo-random-functions (like HMAC) and MACs (weaker requirements than PRFs) Plus people sometimes use plain collision resistant hashes when they actually need a MAC or digital signature