Docsity

Introduction to Cryptography: Cryptographic Hash Functions, Lecture notes of Cryptography and System Security

Partial preview of the text

Download Introduction to Cryptography: Cryptographic Hash Functions and more Lecture notes Cryptography and System Security in PDF only on Docsity!

Introduction to Cryptography

CS 355

Lecture 27

Cryptographic Hash Functions

Lecture Outline

  • Hash functions
  • Security properties
  • MD5 & SHA

Cryptographic Hash Functions

  • A hash function maps a message of an

arbitrary length to a m-bit output

  • output known as the fingerprint or the message digest
  • if the message digest is transmitted securely, then changes to the message can be detected
  • A hash is a many-to-one function, so collisions

can happen.

Security Requirements for

Cryptographic Hash Functions

Given a function h:X →Y, then we say that h is:

  • preimage resistant (one-way): if given y ∈Y it is computationally infeasible to find a value x ∈X s.t. h(x) = y
  • 2-nd preimage resistant (weak collision resistant): if given x ∈ X it is computationally infeasible to find a value x’ ∈ X, s.t. x’≠x and h(x’) = h(x)
  • collision resistant (strong collision resistant): if it is computationally infeasible to find two distinct values x’,x ∈ X, s.t. h(x’) = h(x)

Bruteforce Attacks on Hash Functions

  • Attacking one-wayness
    • Goal: given h:X→Y, y∈Y, find x such that h(x)=y
    • Algorithm: pick a random set X 0 of q values in X, for each x∈X 0 , return x if h(x)=y, after all q values have been evaluated, return fail
    • When h is a random instance of all functions mapping X to Y, the average-case success probability is
    • Let |Y|=2m, to get ε to be close to 0.5, q ≈ 2 m-
Y

q Y

q ^ ≈ 

ε = − ^ −

Bruteforce Attacks on Hash Functions

  • Attacking collision resistance
    • Goal: given h, find x, x’ such that h(x)=h(x’)
    • Algorithm: pick a random set X 0 of q values in X for each x∈X 0 , computes yx=h(x) if yx=yx’ for some x’≠x then return (x,x’) else fail
    • The average success probability is
    • Let |Y|=2m, to get ε to be close to 0.5, q ≈ 2 m/
    • This is known as the birthday attack.

1 2 | |

( 1 ) Y

q q e

−^ − −

Iterative Construction of Hash

Functions

  • A hash function needs to map a message of an

arbitrary length to a m-bit output

  • h: {0,1}*→{0,1}m
  • The iterative construction
  • use a compression function that takes a fixed-length input string and output a shorter string
  • f:{0,1}m+t^ →{0,1}m
  • a message is divided into fixed length blocks and

processed block by block

MD2, MD4 and MD

  • Family of cryptographic hash functions designed by Ron Rivest
  • MD2: produces a 128-bit hash value, perceived as slower and less secure than MD4 and MD
  • MD4: produces a 128-bit hash of the message, using bit operations on 32-bit operands for fast implementation, specified as Internet standard RFC
  • MD5: produces a 128-bit output, specified as Internet standard in RFC1321; till relatively recently was widely used.

MD5 Details

  • The message is padded (1 followed by 0s) such that its length ≡ 448 mod 512
  • Append a 64-bit (treated as unsigned int) representing the length of the message (before padding)
  • Initialize the 4-word (128-bit) buffer (A,B,C,D) A = 01 23 45 67 B = 89 AB CD EF C = FE DC BA 98 D = 76 54 32 10
  • The message is processed in 16-word (512-bit) chunks, using 4 rounds of 16 steps each

MD5 Compression Function

(Single Step)

MD5 Cryptanalysis

  • Known attacks:
    • Berson (1992): for a single-round MD5, he used differential cryptanalysis to find two messages producing the same hash. Attack does not work for 4-round MD5.
    • Boer & Bosselaers(1993): found a pseudo collision (same message, two different IV’s)
    • Dobbertin (1996) created collisions on MD5 compression function with a chosen IV
    • Wang, Feng, Lai, Yu (2004) found collisions of MD
      • works on any IV
      • easy to find multiple collisions

SHA1 (Secure Hash Algorithm)

  • SHA was designed by NIST and is the US federal standard for hash functions, specified in FIPS-180 (1993).
  • SHA-1, revised version of SHA, specified in FIPS-180-1 (1995) use with Secure Hash Algorithm).
  • It produces 160-bit hash values.
  • NIST have issued a revision FIPS 180-2 that adds 3 additional hash algorithms: SHA-256, SHA-384, SHA-512, designed for compatibility with increased security provided by AES.

SHA-1 Compression Function

(Single Step)

SHA-1 Compression Function

  • Each round consists of 20 steps, updates the buffer as follows: (A,B,C,D,E) <- (E+f(t,B,C,D)+(A<<5)+Wt+Kt),A,(B<<30),C,D)
  • t is the step number
  • f(t,B,C,D) is a non-linear function for round
  • Wt is derived from the message block
    • Wt=S^1 (W (^) t-16⊕Wt-14⊕Wt-8⊕Wt-3)
  • Kt is a constant value derived from the sin function
  • Sk^ is circular left shift by k bits