Birthday attack
A birthday attack is a brute-force collision attack that exploits the mathematics behind the birthday problem in probability theory.[src] This attack can be used to abuse communication between two or more parties.[src] The attack depends on the higher likelihood of collisions found between random attack attempts and a fixed degree of permutations (pigeonholes).[src] Let H be the number of possible values of a hash function, with H=2^l .[src] With a birthday attack, it is possible to find a collision of a hash function with 50% chance in \sqrt{2^l} = 2^{l / 2}, where l is the bit length of the hash output, and with 2^{l-1} being the classical preimage resistance security with the same probability.[src] There is a general (though disputed ) result that quantum computers can perform birthday attacks, thus breaking collision resistance, in \sqrt[3]{2^l} = 2^{l / 3} .[src] Although there are some digital signature vulnerabilities associated with the birthday attack, it cannot be used to break an encryption scheme any faster than a brute-force attack.[src]
A birthday attack is a brute-force collision attack that exploits the mathematics behind the birthday problem in probability theory.[src] This attack can be used to abuse communication between two or more parties.[src] The attack depends on the higher likelihood of collisions found between random attack attempts and a fixed degree of permutations (pigeonholes).[src] Let H be the number of possible values of a hash function, with H=2^l .[src] With a birthday attack, it is possible to find a collision of a hash function with 50% chance in \sqrt{2^l} = 2^{l / 2}, where l is the bit length of the hash output, and with 2^{l-1} being the classical preimage resistance security with the same probability.[src] There is a general (though disputed ) result that quantum computers can perform birthday attacks, thus breaking collision resistance, in \sqrt[3]{2^l} = 2^{l / 3} .[src] Although there are some digital signature vulnerabilities associated with the birthday attack, it cannot be used to break an encryption scheme any faster than a brute-force attack.[src] ==Understanding the problem== As an example, consider the scenario in which a teacher with a class of 30 students (n = 30) asks for everybody's birthday (for simplicity, ignore leap years) to determine whether any two students have the same birthday (corresponding to a hash collision as described further).[src] Intuitively, this chance may seem small.[src] Counter-intuitively, the probability that at least one student has the same birthday as any other student on any day is around 70% (for n = 30), from the formula 1-\frac{365!}{(365-n)!\cdot 365^n} .[src] If the teacher had picked a specific day (say, 16 September), then the chance that at least one student was born on that specific day is 1 - (364/365)^{30} , about 7.9%.[src] In a birthday attack, the attacker prepares many different variants of benign and malicious contracts, each having a digital signature.[src] A pair of benign and malicious contracts with the same signature is sought.[src] In this fictional example, suppose that the digital signature of a string is the first byte of its SHA-256 hash.[src] The pair found is indicated in green – note that finding a pair of benign contracts (blue) or a pair of malicious contracts (red) is useless.[src] After the victim accepts the benign contract, the attacker substitutes it with the malicious one and claims the victim signed it, as proven by the digital signature.[src] ==Mathematics== Given a function f , the goal of the attack is to find two different inputs x_{1}, x_{2} such that f(x_{1}) = f(x_{2}) .[src] Such a pair x_{1}, x_{2} is called a collision.[src] The method used to find a collision is simply to evaluate the function f for different input values that may be chosen randomly or pseudorandomly until the same result is found more than once.[src] Because of the birthday problem, this method can be rather efficient.[src] Specifically, if a function f(x) yields any of H different outputs with equal probability and H is sufficiently large, then we expect to obtain a pair of different arguments x_{1} and x_{2} with f(x_{1}) = f(x_{2}) after evaluating the function for about 1.25\sqrt{H} different arguments on average.[src] We consider the following experiment.[src] From a set of H values we choose n values uniformly at random thereby allowing repetitions.[src] Let p(n; H) be the probability that during this experiment at least one value is chosen more than once.[src] This probability can be approximated as p(n;H) \approx 1 - e^{-n(n-1)/(2H)} \approx 1-e^{-n^2/(2H)} where n is the number of chosen values (inputs) and H is the number of possible outcomes (possible hash outputs).[src] Let n(p; H) be the smallest number of values we have to choose, such that the probability for finding a collision is at least p.[src] By inverting this expression above, we find the following approximation n(p;H)\approx \sqrt{2H\ln\frac{1}{1-p}} and assigning a 0.5 probability of collision we arrive at n(0.5;H) \approx 1.1774 \sqrt H Let Q(H) be the expected number of values we have to choose before finding the first collision.[src] This number can be approximated by Q(H)\approx \sqrt{\frac{\pi}{2}H} As an example, if a 64-bit hash is used, there are approximately different outputs.[src] If these are all equally probable (the best case), then it would take 'only' approximately 5 billion attempts ( ) to generate a collision using brute force.[src] This value is called birthday bound and it could be approximated as 2 l/2 , where l is the number of bits in H.[src] Other examples are as follows: Table shows number of hashes n(p) needed to achieve the given probability of success, assuming all hashes are equally likely.[src] For comparison, to is the uncorrectable bit error rate of a typical hard disk.[src] In theory, MD5 hashes or UUIDs, being roughly 128 bits, should stay within that range until about 820 billion documents, even if its possible outputs are many more.[src] It is easy to see that if the outputs of the function are distributed unevenly, then a collision could be found even faster.[src] The notion of 'balance' of a hash function quantifies the resistance of the function to birthday attacks (exploiting uneven key distribution).[src] However, determining the balance of a hash function will typically require all possible inputs to be calculated and thus is infeasible for popular hash functions such as the MD and SHA families.[src] The subexpression \ln\frac{1}{1-p} in the equation for n(p;H) is not computed accurately for small p when directly translated into common programming languages as log(1/(1-p)) due to loss of significance.[src] When log1p is available (as it is in C99) for example, the equivalent expression -log1p(-p) should be used instead.[src] If this is not done, the first column of the above table is computed as zero, and several items in the second column do not have even one correct significant digit.[src] ===Simple approximation=== A good rule of thumb which can be used for mental calculation is the relation p(n) \approx {n^2 \over 2H} which can also be written as H \approx {n^2 \over 2p(n)} .[src] or n \approx \sqrt { 2H \times p(n)} .[src] This works well for probabilities less than or equal to 0.5.[src] This approximation scheme is especially easy to use when working with exponents.[src] For instance, suppose you are building 32-bit hashes ( H = 2^{32} ) and want the chance of a collision to be at most one in a million ( p \approx 2^{-20} ), how many documents could we have at the most?[src] n \approx \sqrt { 2 \times 2^{32} \times 2^{-20}} = \sqrt { 2^{1+32-20} } = \sqrt { 2^{13} } = 2^{6.5} \approx 90.5 which is close to the correct answer of 93.[src] ==Digital signature susceptibility== Digital signatures can be susceptible to a birthday attack or more precisely a chosen-prefix collision attack.[src] A message m is typically signed by first computing f(m) , where f is a cryptographic hash function, and then using some secret key to sign f(m) .[src] Suppose Mallory wants to trick Bob into signing a fraudulent contract.[src] Mallory prepares a fair contract m and a fraudulent one m' .[src] She then finds a number of positions where m can be changed without changing the meaning, such as inserting commas, empty lines, one versus two spaces after a sentence, replacing synonyms, etc.[src] By combining these changes, she can create a huge number of variations on m which are all fair contracts.[src] In a similar manner, Mallory also creates a huge number of variations on the fraudulent contract m' .[src] She then applies the hash function to all these variations until she finds a version of the fair contract and a version of the fraudulent contract which have the same hash value, f(m) = f(m') .[src] She presents the fair version to Bob for signing.[src] After Bob has signed, Mallory takes the signature and attaches it to the fraudulent contract.[src] This signature then "proves" that Bob signed the fraudulent contract.[src] The probabilities differ slightly from the original birthday problem, as Mallory gains nothing by finding two fair or two fraudulent contracts with the same hash.[src] Mallory's strategy is to generate pairs of one fair and one fraudulent contract.[src] For a given hash function 2^l is the number of possible hashes, where l is the bit length of the hash output.[src] The birthday problem equations do not exactly apply here.[src] For a 50% chance of a collision, Mallory would need to generate approximately 2^{(l/2) + 1} hashes, which is twice the number required for a simple collision under the classical birthday problem.[src] To avoid this attack, the output length of the hash function used for a signature scheme can be chosen large enough so that the birthday attack becomes computationally infeasible, i.e.[src] about twice as many bits as are needed to prevent an ordinary brute-force attack.[src] Besides using a larger bit length, the signer (Bob) can protect himself by making some random, inoffensive changes to the document before signing it, and by keeping a copy of the contract he signed in his own possession, so that he can at least demonstrate in court that his signature matches that contract, not just the fraudulent one.[src] Pollard's rho algorithm for logarithms is an example for an algorithm using a birthday attack for the computation of discrete logarithms.[src] ===Reverse attack=== The same fraud is possible if the signer is Mallory, not Bob.[src] Bob could suggest a contract to Mallory for a signature.[src] Mallory could find both an inoffensively-modified version of this fair contract that has the same signature as a fraudulent contract, and Mallory could provide the modified fair contract and signature to Bob.[src] Later, Mallory could produce the fraudulent copy.[src] If Bob doesn't have the inoffensively-modified version contract (perhaps only finding their original proposal), Mallory's fraud is perfect.[src] If Bob does have it, Mallory can at least claim that it is Bob who is the fraudster.[src] ==See also== Collision attack Meet-in-the-middle attack BHT Algorithm ==Notes== ==References== Mihir Bellare, Tadayoshi Kohno: Hash Function Balance and Its Impact on Birthday Attacks.[src] EUROCRYPT 2004: pp401–418 Applied Cryptography, 2nd ed.[src] by Bruce Schneier ==External links== "What is a digital signature and what is authentication?" from RSA Security's crypto FAQ.[src] "Birthday Attack" X5 Networks Crypto FAQs de:Kollisionsangriff#Geburtstagsangriff[src]
82 sentences · 82 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Birthday attack." encyclopegia.org, 2026, https://encyclopegia.org/wiki/birthday-attack. Accessed 01 December 2026.
Chicago
"Birthday attack." encyclopegia.org. Accessed December 1, 2026. https://encyclopegia.org/wiki/birthday-attack.
APA
encyclopegia.org. (2026). Birthday attack. Retrieved December 1, 2026, from https://encyclopegia.org/wiki/birthday-attack
Accessed December 1, 2026 · CC BY-SA 4.0 · citation page · JSON
Claims
| Predicate | Value | Source |
|---|---|---|
| students | 30 students | Wikipedia |