Hash functions: weaknesses and attacks
MD5 and SHA-1 collisions, chosen-prefix attacks, length extension and precomputed tables for passwords.
- MD5 collisions
- Since 2004 they can be found in seconds. In 2012 the Flame malware used an MD5 collision to forge a code-signing certificate.
- SHA-1 collisions
- The first practical collision in 2017; in 2020 a “chosen-prefix” attack made it possible to create two different documents with attacker-chosen beginnings and the same value.
- Length extension
- With Merkle-Damgård constructions, knowing the value of a secret message lets you compute another for the extended message. It breaks naively built authentication codes.
- Precomputed tables
- Against unprotected password hashes, huge tables of precomputed values or dictionary attempts are used.
- Quantum computers
- Grover’s algorithm would speed up the search for preimages, but 256-bit values are still considered adequate.
Hash functions today
Where hash functions are used every day: digital signatures, certificates, downloads, passwords, blockchain, version control and digital evidence.
The pages of this topic
Back to the overviewHash functions: how they work
How a hash function compresses data of any length into a fixed value: blocks, internal state, the Merkle-Damgård construction and the sponge construction.
Hash functions: history
From the first cryptographic hash functions to the SHA family, from MD5’s success to collisions, to the competition that produced SHA-3.
Hash functions: the maths
The birthday paradox and why security against collisions is half the length of the value, with the pigeonhole principle.
Hash functions: worked example
SHA-256 values of similar words and phrases, to see the avalanche effect, and the official test vectors.
Hash functions: try it yourself
Hands-on exercises to compute hash values, observe the avalanche effect and estimate the birthday paradox.
Hash functions: frequently asked questions
Short answers to the most common doubts about cryptographic hash functions.