Hash Function
Hash Function
30 September, 2024
Motivation
H:D→R
H:D→R
I A generic attack on a hash function H : {0, 1}∗ → {0, 1}n does not
take into account concrete properties of a particular hash function,
say SHA-256.
I Here we treat H as a random function.
I For each new x ∈ {0, 1}∗ , y = H(x) is “computed” by selecting y
uniformly at random from {0, 1}n .
Generic Attacks
I A generic attack on a hash function H : {0, 1}∗ → {0, 1}n does not
take into account concrete properties of a particular hash function,
say SHA-256.
I Here we treat H as a random function.
I For each new x ∈ {0, 1}∗ , y = H(x) is “computed” by selecting y
uniformly at random from {0, 1}n .
I From security point of view such a random function is an ideal hash
function.
I From implementation point of view such a function cannot be realized
efficiently. [Why?]
I Generic attacks provide an upper bound on security for any hash
function.
I A concrete hash function achieves ideal security if the best attack
against it matches the generic attack.
Generic Attack: Find-Preimage
I Given some y ∈ {0, 1}n , select arbitrary x ∈ {0, 1}∗ and compute
H(x).
I If H(x) = y then STOP and return x.
I Else, continue with a different value of x.
I Expected number of steps (hash function evaluation):
Generic Attack: Find-Preimage
I Given some y ∈ {0, 1}n , select arbitrary x ∈ {0, 1}∗ and compute
H(x).
I If H(x) = y then STOP and return x.
I Else, continue with a different value of x.
I Expected number of steps (hash function evaluation):
I 2n .
I Exercise: Devise a generic attack to find second preimage and analyse
its cost in terms of number of hash compuations.
Generic Attack: Collision
I Components:
I A compression function: f : {0, 1}n+r → {0, 1}n .
I An initial vector IV ∈ {0, 1}n .
Merkle’s Meta Construction
I Components:
I A compression function: f : {0, 1}n+r → {0, 1}n .
I An initial vector IV ∈ {0, 1}n .
I Computing H(x) (bit-length of x is b < 2r )
Preprocessing:
1. Break-up x into r -bit blocks: x̄ = x1 , x2 , . . . , xt (pad the last block
with 0 bits if necessary).
2. Add the length-block xt+1 to hold the right-justified representation of
b.
Merkle’s Meta Construction
I Components:
I A compression function: f : {0, 1}n+r → {0, 1}n .
I An initial vector IV ∈ {0, 1}n .
I Computing H(x) (bit-length of x is b < 2r )
Preprocessing:
1. Break-up x into r -bit blocks: x̄ = x1 , x2 , . . . , xt (pad the last block
with 0 bits if necessary).
2. Add the length-block xt+1 to hold the right-justified representation of
b.
I Processing:
1. Set H0 = IV.
2. Compute chaining variables Hi = f (xi , Hi−1 ) for 1 ≤ i ≤ t + 1.
3. Output H(x) = Ht+1 .
Iterated Hash Function
Iterated Hash Function