In the context of attack, there are two types of preimage resistance:
- preimage resistance: for essentially all pre-specified outputs, it is computationally infeasible to find any input that hashes to that output, i.e., given y, it is difficult to find an x such that h(x) = y.
- second-preimage resistance: it is computationally infeasible to find any second input which has the same output as that of a specified input, i.e., given x, it is difficult to find a second preimage x′ ≠ x such that h(x) = h(x′).
Collision resistance implies second-preimage resistance, but does not guarantee preimage resistance. Conversely, a second-preimage attack implies a collision attack (trivially, since, in addition to x′, x is already known right from the start).
Applied preimage attacks
By definition, an ideal hash function is such that the fastest way to compute a first or second preimage is through a brute-force attack. For an n-bit hash, this attack has a time complexity 2n, which is considered too high for a typical output size of n = 128 bits. If such complexity is the best that can be achieved by an adversary, then the hash function is considered preimage-resistant. However, there is a general result that quantum computers perform a structured preimage attack in √ = 2n/2, which also implies second preimage and thus a collision attack.
Faster preimage attacks can be found by cryptanalysing certain hash functions, and are specific to that function. Some significant preimage attacks have already been discovered, but they are not yet practical. If a practical preimage attack is discovered, it would drastically affect many Internet protocols. In this case, "practical" means that it could be executed by an attacker with a reasonable amount of resources. For example, a preimaging attack that costs trillions of dollars and takes decades to preimage one desired hash value or one message is not practical; one that costs a few thousand dollars and takes a few weeks might be very practical.
All currently known practical or almost-practical attacks on MD5 and SHA-1 are collision attacks. In general, a collision attack is easier to mount than a preimage attack, as it is not restricted by any set value (any two values can be used to collide). The time complexity of the collision attack, in contrast, is 2n/2.
To improve resistance to first preimage attacks, double hashing is a good solution in case someone discovers a preimage attack on the first hash. The Bitcoin system uses double hashed SHA256 that was a common way to slow down hashing searches in the 2000's.
- IETF RFC 4270: Attacks on Cryptographic Hashes in Internet Protocols
- Rogaway, P.; Shrimpton, T. "Cryptographic Hash-Function Basics: Definitions, Implications, and Separations for Preimage Resistance, Second-Preimage Resistance, and Collision Resistance" (PDF). Fast Software Encryption (2004). Springer-Verlag. Retrieved 17 November 2012.
- Bruce Morton, Clayton Smith (30 January 2014). "Why We Need to Move to SHA-2". CA Security Council.
- "MD5 and Perspectives". 1 January 2009.
- "Google Online Security Blog: Announcing the first SHA1 collision". Google. Retrieved 2017-02-23.
|This cryptography-related article is a stub. You can help Wikipedia by expanding it.|