1. Birthday Attack on 80-bit Hash Function

  • Second Pre-image Resistance: As defined on pages 4 and 5 (property 5), second pre-image resistance means: given an input and its hash , it should be computationally infeasible to find a different input such that .

    • A brute-force attack to find a second pre-image involves taking the known hash and trying many different inputs until one produces the same hash value.
    • For an -bit hash function, there are possible output values. On average, you would expect to try different inputs to find one that hashes to the specific target value .
    • Therefore, for an 80-bit hash function (), finding a second pre-image requires checking approximately messages.
  • Collision Resistance & Birthday Attack: As defined on pages 4 and 5 (property 6), collision resistance means it should be computationally infeasible to find any pair of distinct inputs such that . Finding such a pair is generally easier than finding a second pre-image due to the Birthday Attack (explained on pages 6-9).

  • Proof using Birthday Attack:

    1. Goal: Find any two distinct messages that hash to the same value.
    2. Method: The attacker generates a sequence of distinct messages and computes their corresponding hash values .
    3. Collision Check: After computing each new hash , the attacker checks if this value matches any of the previously computed hash values ( to ).
    4. Probability: The probability of finding a collision increases as more messages are hashed. The Birthday Paradox shows that a surprisingly small number of messages are needed to have a high probability of collision.
    5. Calculation: For an -bit hash function, there are possible hash outputs. The number of messages needed to find a collision with a certain probability (e.g., or 50%) is approximated by the formula derived on page 9: For a probability of 50% (), . The most important consequence (page 9) is that is roughly proportional to the square root of the number of possible outputs: .
    6. Applying to n=80: For an 80-bit hash function, . The number of messages needed to find a collision via the birthday attack is approximately: (Page 9 gives a slightly more precise estimate of for 50% probability).
  • Conclusion: While finding a second pre-image for an 80-bit hash requires approximately operations (computationally infeasible), finding any collision using the birthday attack only requires approximately operations. This is significantly less effort and demonstrates why collision resistance requires roughly twice the number of bits compared to pre-image resistance for the same security level against brute-force/birthday attacks.

2. Time to Find Second Pre-image for 64-bit Hash

  • Effort Required: As established in Q1, finding a second pre-image for an -bit hash function requires approximately tests (hash computations).

  • Given:

    • Hash output length bits.
    • Attacker speed = tests per second.
  • Calculation:

    • Total tests needed .
    • Time = (Total Tests) / (Tests per Second)
    • Time seconds
    • Time seconds
    • Time seconds
  • Converting to Years (Optional but helpful for scale):

    • Seconds per year = seconds.
    • This is roughly seconds/year (since ).
    • Time in years years
    • Time in years years
    • Time in years years
    • years.
  • Answer: It would require approximately seconds (or roughly half a million years) to find the second pre-image for a 64-bit hash function at the given attacker speed.

3. SHA-512 Padding

  • Context: SHA-512 processes data in 1024-bit blocks. Before hashing, the message is padded to ensure its total length is a multiple of 1024 bits after appending a 128-bit length field.

  • Padding Rule: The total length after padding and adding the length field must satisfy: where is the original message length, is the padding length, and 128 is the length of the length field.

  • The padding consists of a single ‘1’ bit followed by zero or more ‘0’ bits. This means .

  • An equivalent formula for is: The actual value of is the smallest positive integer satisfying this congruence.

  • (i) Number of padding bits for |M| = 2590 bits:

    • To find the positive remainder, we can add multiples of 1024:
    • So, .
    • The smallest positive integer value for is 354.
    • Check: . Since , . The condition holds.
    • Answer (i): The number of padding bits is bits.
  • (ii) Padding needed if |M| is a multiple of 1024 bits:

    • Let for some non-negative integer .
    • Substitute into the congruence:
    • Since , this simplifies to:
    • The smallest positive integer value for is 896.
    • Since must be at least 1 (padding always starts with a ‘1’ bit) and the calculation yields , padding is indeed required.
    • Reasoning: Even if the original message length aligns perfectly with the block boundary (like ), we still need to append the 128-bit length field. To make the total length (Message + Padding + Length Field) a multiple of 1024, padding is necessary. In this specific case, 896 bits of padding (a ‘1’ followed by 895 ‘0’s) are added.
    • Answer (ii): Yes, padding is always needed. If the original message length is a multiple of 1024, 896 bits of padding are required.