Cryptographic Hash Function Menagerie
Learn more about the most popular cryptographic hash functions.
Join the DZone community and get the full member experience.Join For Free
Here's an oversimplified survey of cryptographic hash functions: everyone used to use MD5, now they use some variation on SHA.
There's some truth to that. MD5 was very popular and remains popular years after it was proven insecure. And now, variations on SHA like SHA1 and SHA256 are commonly used. But there are a lot more cryptographic hash functions in common use.
hashlib is a reliable guide, the most common hashing algorithms are:
Because these are the six algorithms guaranteed to be supported on every platform, as listed in the output of the
algorithms_guaranteed method in
algorithms_available methods in hashlib include additional algorithms available in a particular installation. On the computer I'm using at the moment, it lists 18 hash algorithms in addition to those on the guaranteed list.
Mathematica supports the hash functions on
hashlib 's guaranteed list, and a few more:
The first two hashes, Adler32 and CRC32, were never intended to be secure. They were designed simply as error detection codes and weren't designed to be tamper-resistant. As the names imply, MD3 and MD4 were predecessors to MD5.
The hash that Mathematica calls RIPEMD160SHA256 is SHA 256 followed by the RIPEMD160. The reason this combination gets a name of its own is because it is used in Bitcoin. Finally, SHA256SHA256 is simply SHA256 applied twice.
The Long Tail
The hash functions mentioned above are the most commonly used, but there are hundreds of others in common use. The hashcat password cracking tool lists 260 kinds of hash functions it can attack.
Some of these hash functions are fundamental algorithms, such as Whirlpool and variations of GOST. Some are combinations of primitive functions, such as salted or iterated variations. Many of them are vendor and product specific. For example, hashcat lists nine different hashing algorithms associated with various versions of Microsoft Office, six algorithms for Cisco products, five algorithms for SAP, etc.
It's interesting to speculate on why there are so many custom hash functions: hashing technology progress, differing emphases on security and speed, not-invented-here syndrome, etc.
Security by Variety
There's something going on that isn't exactly security-by-obscurity, i.e. relying on keeping your encryption algorithm a secret. The hashing algorithms for all the products mentioned above are well known, but there may be some small advantage to being a little bit off the beaten path.
People have built special hardware and software for attacking popular hashing algorithms, and doing something a little different could prevent this from working on your hash. Of course, doing something a little different could also introduce a weakness you didn't anticipate. Creating your own encryption algorithm is a bad idea unless you're an expert, and often even if you are an expert, making a new hash function by combining secure primitives is not as dangerous as creating your own encryption algorithm.
Published at DZone with permission of John Cook, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.