liveBook · Manning

Birthday attack

As explained in Hacking Cryptography

A birthday attack is a collision-finding method that generates approximately the square root of the hash output space to obtain a substantial probability of matching digests for distinct inputs.

A birthday attack finds two distinct inputs with the same hash digest by exploiting the birthday paradox. For an ideal N-bit hash, about 2^(N/2) hashes give a collision probability above 50%. section 6.2

A naive birthday attack proceeds as follows:

  • Generate roughly 2^(N/2) random messages. section 6.4.1
  • Hash each message and store its digest with the original input in a sorted table. section 6.2
  • Locate equal digests paired with different inputs; the large storage requirement is the practical constraint. section 6.4.1

MD5 and structured file collisions

A 128-bit MD5 digest would require about 2^64 steps for a generic collision, although advanced attacks reduce this dramatically. Collision blocks can also be embedded in formats such as PNG, JPG, or ZIP so two files share a digest while exposing different active data. section 6.2 section 6.4.1

Equation 6.1
\[\begin{aligned} \begin{aligned} H(A) &= H(B) \\ H(A || X) &= H(B || X) \end{aligned} \label{equation:extend-collision} \end{aligned}\]

The collision-extension equation shows why H(A) = H(B) implies H(A || X) = H(B || X). section 6.4.1

How Hacking Cryptography covers it

How deep it goes
Explains the probability threshold, table-based procedure, storage burden, and collision exploitation, but defers advanced attack construction.
Examples
Uses MD5 collision estimates, sorted digest tables, and paired PNG, JPG, or ZIP files with differing active data.
What it assumes
Assumes hash digests and collision terminology while establishing the birthday-paradox threshold from the collision-search procedure.
What you can do after
Evaluate a hash function's collision resistance against the generic 2^(N/2) baseline and recognize storage and format-exploitation risks.
How it connects
Connects hash functions, collision resistance, digest size, MD5, collision attacks, and structured file formats.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.