Dan Boneh Collision resistance Introduction Online Cryptography Course Dan Boneh.

Slides:



Advertisements
Similar presentations
Dan Boneh Message integrity Message Auth. Codes Online Cryptography Course Dan Boneh.
Advertisements

Online Cryptography Course Dan Boneh
Hash Function. What are hash functions? Just a method of compressing strings – E.g., H : {0,1}*  {0,1} 160 – Input is called “message”, output is “digest”
Message Authentication Codes (MACs) and Hashes David Brumley Carnegie Mellon University Credits: Many slides from Dan Boneh’s June 2012.
Cryptographic Hash Functions Rocky K. C. Chang, February
Dan Boneh Message Integrity A Parallel MAC Online Cryptography Course Dan Boneh.
Notation Intro. Number Theory Online Cryptography Course Dan Boneh
Session 5 Hash functions and digital signatures. Contents Hash functions – Definition – Requirements – Construction – Security – Applications 2/44.
1 Chapter 5 Hashes and Message Digests Instructor: 孫宏民 Room: EECS 6402, Tel: , Fax :
1 Message Integrity CS255 Winter ‘06. 2 Message Integrity Goal: provide message integrity. No confidentiality. –ex: Protecting public binaries on disk.
Hash functions a hash function produces a fingerprint of some file/message/data h = H(M)  condenses a variable-length message M  to a fixed-sized fingerprint.
Foundations of Network and Computer Security J J ohn Black Lecture #10 Sep 19 th 2007 CSCI 6268/TLEN 5831, Fall 2007.
Chapter 4  Hash Functions 1 Overview  Cryptographic hash functions are functions that: o Map an arbitrary-length (but finite) input to a fixed-size output.
CMSC 414 Computer and Network Security Lecture 5 Jonathan Katz.
CMSC 414 Computer and Network Security Lecture 9 Jonathan Katz.
Foundations of Network and Computer Security J J ohn Black Lecture #5 Sep 7 th 2004 CSCI 6268/TLEN 5831, Fall 2004.
Foundations of Network and Computer Security J J ohn Black Lecture #7 Sep 11 th 2009 CSCI 6268/TLEN 5550, Fall 2009.
1 CS 255 Lecture 6 Hash Functions Brent Waters. 2 Recap-Notions of Security What attacker can do Random plaintext attack Chosen plaintext attack Chosen.
Hash Functions Nathanael Paul Oct. 9, Hash Functions: Introduction Cryptographic hash functions –Input – any length –Output – fixed length –H(x)
CS526Topic 5: Hash Functions and Message Authentication 1 Computer Security CS 526 Topic 5 Cryptography: Cryptographic Hash Functions And Message Authentication.
Cryptographic Hashing: Blockcipher-Based Constructions, Revisited Tom Shrimpton Portland State University.
Cryptography1 CPSC 3730 Cryptography Chapter 11, 12 Message Authentication and Hash Functions.
Foundations of Network and Computer Security J J ohn Black Lecture #9 Sep 17 th 2007 CSCI 6268/TLEN 5831, Fall 2007.
Dan Boneh Collision resistance Generic birthday attack Online Cryptography Course Dan Boneh.
Dan Boneh Intro. Number Theory Intractable problems Online Cryptography Course Dan Boneh.
Cryptography and Network Security Chapter 11 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Dan Boneh Odds and ends Key Derivation Online Cryptography Course Dan Boneh.
CMSC 414 Computer and Network Security Lecture 6 Jonathan Katz.
Hash Functions A hash function H accepts a variable-length block of data M as input and produces a fixed-size hash value h = H(M) Principal object is.
Dan Boneh Block ciphers More attacks on block ciphers Online Cryptography Course Dan Boneh.
Message Authentication Code July Message Authentication Problem  Message Authentication is concerned with:  protecting the integrity of a message.
Lecture 4.1: Hash Functions, and Message Authentication Codes CS 436/636/736 Spring 2015 Nitesh Saxena.
Dan Boneh Using block ciphers Modes of operation: many time key (CTR) Online Cryptography Course Dan Boneh Example applications: 1. File systems: Same.
Hash and MAC Functions CS427 – Computer Security
Theory of Computation II Topic presented by: Alberto Aguilar Gonzalez.
Dan Boneh Using block ciphers Modes of operation: many time key (CBC) Online Cryptography Course Dan Boneh Example applications: 1. File systems: Same.
Dan Boneh Message Integrity CBC-MAC and NMAC Online Cryptography Course Dan Boneh.
Cryptography and Network Security (CS435) Part Nine (Message Authentication)
Giuseppe Bianchi Message Authentication: hash functions and hash-based constructions.
Hash Functions Ramki Thurimella. 2 What is a hash function? Also known as message digest or fingerprint Compression: A function that maps arbitrarily.
Message Authentication Codes (MACs) and Hashes David Brumley Carnegie Mellon University Credits: Many slides from Dan Boneh’s June 2012.
Lecture 4.1: Hash Functions, and Message Authentication Codes CS 436/636/736 Spring 2014 Nitesh Saxena.
Cryptographic Hash Functions
Ryan Henry I 538 /B 609 : Introduction to Cryptography.
CS426Fall 2010/Lecture 51 Computer Security CS 426 Lecture 5 Cryptography: Cryptographic Hash Function.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Dan Boneh Collision resistance The Merkle-Damgard Paradigm Online Cryptography Course Dan Boneh.
Dan Boneh Stream ciphers PRG Security Defs Online Cryptography Course Dan Boneh.
Hashes Lesson Introduction ●The birthday paradox and length of hash ●Secure hash function ●HMAC.
Dan Boneh Introduction Discrete Probability (crash course, cont.) Online Cryptography Course Dan Boneh See also:
Dan Boneh Authenticated Encryption CBC paddings attacks Online Cryptography Course Dan Boneh.
CS555Spring 2012/Topic 151 Cryptography CS 555 Topic 15: HMAC, Combining Encryption & Authentication.
Dan Boneh Authenticated Encryption Constructions from ciphers and MACs Online Cryptography Course Dan Boneh.
Dan Boneh Collision resistance Timing attacks on MAC verification Online Cryptography Course Dan Boneh.
CS480 Cryptography and Information Security Huiping Guo Department of Computer Science California State University, Los Angeles 13.Message Authentication.
Data Integrity / Data Authentication. Definition Authentication (Signature) algorithm - A Verification algorithm - V Authentication key – k Verification.
CS555Spring 2012/Topic 141 Cryptography CS 555 Topic 14: CBC-MAC & Hash Functions.
Cryptographic Hash Functions
Cryptographic Hash Functions
Message Authentication Codes (MACs) and Hashes
Cryptographic Hash Functions Part I
Cryptography Lecture 13.
Introduction to Symmetric-key and Public-key Cryptography
Cryptographic Hash Functions Part I
Topic 13: Message Authentication Code
Cryptography Lecture 14.
Cryptography Lecture 13.
Cryptography Lecture 13.
Presentation transcript:

Dan Boneh Collision resistance Introduction Online Cryptography Course Dan Boneh

Dan Boneh Recap: message integrity So far, four MAC constructions: ECBC-MAC, CMAC : commonly used with AES (e.g i) NMAC : basis of HMAC (this segment) PMAC: a parallel MAC Carter-Wegman MAC: built from a fast one-time MAC PRFs This module: MACs from collision resistance. randomized MAC

Dan Boneh Collision Resistance Let H: M  T be a hash function ( |M| >> |T| ) A collision for H is a pair m 0, m 1  M such that: H(m 0 ) = H(m 1 ) and m 0  m 1 A function H is collision resistant if for all (explicit) “ eff ” algs. A: Adv CR [A,H] = Pr[ A outputs collision for H] is “ neg ”. Example: SHA-256 (outputs 256 bits)

Dan Boneh MACs from Collision Resistance Let I = (S,V) be a MAC for short messages over (K,M,T) (e.g. AES) Let H: M big  M Def: I big = (S big, V big ) over (K, M big, T) as: S big (k,m) = S(k,H(m)) ; V big (k,m,t) = V(k,H(m),t) Thm: If I is a secure MAC and H is collision resistant then I big is a secure MAC. Example: S(k,m) = AES 2-block-cbc (k, SHA-256(m)) is a secure MAC.

Dan Boneh MACs from Collision Resistance Collision resistance is necessary for security: Suppose adversary can find m 0  m 1 s.t. H(m 0 ) = H(m 1 ). Then: S big is insecure under a 1-chosen msg attack step 1: adversary asks for t S(k, m 0 ) step 2: output (m 1, t) as forgery S big (k, m) = S(k, H(m)) ; V big (k, m, t) = V(k, H(m), t)

Dan Boneh Protecting file integrity using C.R. hash When user downloads package, can verify that contents are valid H collision resistant ⇒ attacker cannot modify package without detection no key needed (public verifiability), but requires read-only space F1F1 F1F1 F2F2 F2F2 FnFn FnFn ⋯ package name read-only public space H(F 1 ) H(F 2 ) H(F n ) Software packages: package name

Dan Boneh End of Segment

Dan Boneh Collision resistance Generic birthday attack Online Cryptography Course Dan Boneh

Dan Boneh Generic attack on C.R. functions Let H: M  {0,1} n be a hash function ( |M| >> 2 n ) Generic alg. to find a collision in time O(2 n/2 ) hashes Algorithm: 1.Choose 2 n/2 random messages in M: m 1, …, m 2 n/ 2 (distinct w.h.p ) 2.For i = 1, …, 2 n/2 compute t i = H(m i ) ∈ {0,1} n 3.Look for a collision (t i = t j ). If not found, got back to step 1. How well will this work?

Dan Boneh The birthday paradox Let r 1, …, r n ∈ {1,…,B} be indep. identically distributed integers. Thm: when n = 1.2 × B 1/2 then Pr [ ∃ i≠j: r i = r j ] ≥ ½ Proof: (for uniform indep. r 1, …, r n )

Dan Boneh B=10 6 # samples n

Dan Boneh Generic attack H: M  {0,1} n. Collision finding algorithm: 1.Choose 2 n/2 random elements in M: m 1, …, m 2 n/2 2.For i = 1, …, 2 n/2 compute t i = H(m i ) ∈ {0,1} n 3.Look for a collision (t i = t j ). If not found, got back to step 1. Expected number of iteration ≈ 2 Running time: O(2 n/2 ) (space O(2 n/2 ) )

Dan Boneh Sample C.R. hash functions: Crypto [ Wei Dai ] AMD Opteron, 2.2 GHz ( Linux) digest generic functionsize (bits)Speed (MB/sec)attack time SHA SHA SHA Whirlpool NIST standards * best known collision finder for SHA-1 requires 2 51 hash evaluations

Dan Boneh Quantum Collision Finder Classical algorithms Quantum algorithms Block cipher E: K × X X exhaustive search O( |K| )O( |K| 1/2 ) Hash function H: M T collision finder O( |T| 1/2 )O( |T| 1/3 )

Dan Boneh End of Segment

Dan Boneh Collision resistance The Merkle-Damgard Paradigm Online Cryptography Course Dan Boneh

Dan Boneh Collision resistance: review Let H: M  T be a hash function ( |M| >> |T| ) A collision for H is a pair m 0, m 1  M such that: H(m 0 ) = H(m 1 ) and m 0  m 1 Goal: collision resistant (C.R.) hash functions Step 1: given C.R. function for short messages, construct C.R. function for long messages

Dan Boneh The Merkle-Damgard iterated construction Given h: T × X T (compression function) we obtain H: X ≤L T. H i - chaining variables PB: padding block hhh m[0]m[1]m[2]m[3] ll PB h IV (fixed) H(m) H0H0 H1H1 H2H2 H3H3 H4H4 1000…0 ll msg len 64 bits If no space for PB add another block

Dan Boneh MD collision resistance Thm: if h is collision resistant then so is H. Proof: collision on H ⇒ collision on h Suppose H(M) = H(M’). We build collision for h. IV = H 0, H 1, …, H t, H t+1 = H(M) IV = H 0 ’, H 1 ’, …, H’ r, H’ r+1 = H(M’) h( H t, M t ll PB) = H t+1 = H’ r+1 = h(H’ r, M’ r ll PB’)

Dan Boneh Suppose H t = H’ r and M t = M’ r and PB = PB’ Then: h( H t-1, M t-1 ) = H t = H’ t = h(H’ t-1, M’ t-1 )

Dan Boneh End of Segment ⇒ To construct C.R. function, suffices to construct compression function

Dan Boneh Collision resistance Constructing Compression Functions Online Cryptography Course Dan Boneh

Dan Boneh The Merkle-Damgard iterated construction Thm: h collision resistant ⇒ H collision resistant Goal: construct compression function h: T × X T hhh m[0]m[1]m[2]m[3] ll PB h IV (fixed) H(m)

Dan Boneh Compr. func. from a block cipher E: K× {0,1} n {0,1} n a block cipher. The Davies-Meyer compression function: h(H, m) = E(m, H)H Thm: Suppose E is an ideal cipher (collection of |K| random perms.). Finding a collision h(H,m)=h(H’,m’) takes O(2 n/2 ) evaluations of (E,D). E > mimi HiHi Best possible !!

Template vertLeftWhite2 Suppose we define h(H, m) = E(m, H) Then the resulting h(.,.) is not collision resistant: to build a collision (H,m) and (H’,m’) choose random (H,m,m’) and construct H’ as follows: H’=D(m’, E(m,H)) H’=E(m’, D(m,H)) H’=E(m’, E(m,H)) H’=D(m’, D(m,H))

Dan Boneh Other block cipher constructions Miyaguchi-Preneel: h(H, m) = E(m, H)Hm (Whirlpool) h(H, m) = E(Hm, m)m total of 12 variants like this Other natural variants are insecure: h(H, m) = E(m, H)m (HW) Let E: {0,1} n × {0,1} n {0,1} n for simplicity

Dan Boneh Case study: SHA-256 Merkle-Damgard function Davies-Meyer compression function Block cipher: SHACAL bit key SHACAL-2 > 256-bit block

Dan Boneh Provable compression functions Choose a random 2000-bit prime p and random 1 ≤ u, v ≤ p. For m,h ∈ {0,…,p-1} define h(H,m) = u H ⋅ v m (mod p) Fact: finding collision for h(.,.) is as hard as solving “discrete-log” modulo p. Problem: slow.

Dan Boneh End of Segment

Dan Boneh Collision resistance HMAC: a MAC from SHA-256 Online Cryptography Course Dan Boneh

Dan Boneh The Merkle-Damgard iterated construction Thm: h collision resistant ⇒ H collision resistant Can we use H(.) to directly build a MAC? hhh m[0]m[1]m[2]m[3] ll PB h IV (fixed) H(m)

Template vertLeftWhite2 MAC from a Merkle-Damgard Hash Function H: X ≤L T a C.R. Merkle-Damgard Hash Function Attempt #1: S(k, m) = H( k ll m) This MAC is insecure because: Given H( k ll m) can compute H( k ll m ll PB ll w ) for any w. Given H( k ll m) can compute H( k ll m ll w ) for any w. Given H( k ll m) can compute H( w ll k ll m ll PB) for any w. Anyone can compute H( k ll m ) for any m.

Dan Boneh Standardized method: HMAC (Hash-MAC) Most widely used MAC on the Internet. H: hash function. example: SHA-256 ; output is 256 bits Building a MAC out of a hash function: HMAC: S( k, m ) = H ( k  opad ll H( k  ipad ll m ) )

Dan Boneh HMAC in pictures Similar to the NMAC PRF. main difference: the two keys k 1, k 2 are dependent hh m[0]m[1]m[2] ll PB h h tag > > > h kipad IV (fixed) > > IV (fixed) h > kopad

Dan Boneh HMAC properties Built from a black-box implementation of SHA-256. HMAC is assumed to be a secure PRF Can be proven under certain PRF assumptions about h(.,.) Security bounds similar to NMAC – Need q 2 /|T| to be negligible ( q << |T| ½ ) In TLS: must support HMAC-SHA1-96

Dan Boneh End of Segment

Dan Boneh Collision resistance Timing attacks on MAC verification Online Cryptography Course Dan Boneh

Dan Boneh Warning: verification timing attacks [L’09] Example: Keyczar crypto library (Python) [simplified] def Verify(key, msg, sig_bytes): return HMAC(key, msg) == sig_bytes The problem: ‘==‘ implemented as a byte-by-byte comparison Comparator returns false when first inequality found

Dan Boneh Warning: verification timing attacks [L’09] Timing attack: to compute tag for target message m do: Step 1: Query server with random tag Step 2: Loop over all possible first bytes and query server. stop when verification takes a little longer than in step 1 Step 3: repeat for all tag bytes until valid tag found m, tag k accept or reject target msg m

Dan Boneh Defense #1 Make string comparator always take same time (Python) : return false if sig_bytes has wrong length result = 0 for x, y in zip( HMAC(key,msg), sig_bytes): result |= ord(x) ^ ord(y) return result == 0 Can be difficult to ensure due to optimizing compiler.

Dan Boneh Defense #2 Make string comparator always take same time (Python) : def Verify(key, msg, sig_bytes): mac = HMAC(key, msg) return HMAC(key, mac) == HMAC(key, sig_bytes) Attacker doesn’t know values being compared

Dan Boneh Lesson Don’t implement crypto yourself !

Dan Boneh End of Segment