Cryptographic Hash Functions Applications of Cryptographic Hash Functions

  • Slides: 52
Download presentation
Cryptographic Hash Functions Applications of Cryptographic Hash Functions 2. Secure Hash Algorithm 3. Message

Cryptographic Hash Functions Applications of Cryptographic Hash Functions 2. Secure Hash Algorithm 3. Message Authentication Codes: Message Authentication Requirements and Functions, HMAC, 4. Digital signatures, 1. • Digital Signature Schemes, • Authentication Protocols, • Digital Signature Standards.

Hash Functions �condenses arbitrary message to fixed size h = H(M) �usually assume hash

Hash Functions �condenses arbitrary message to fixed size h = H(M) �usually assume hash function is public �hash used to detect changes to message �want a cryptographic hash function ◦ computationally infeasible to find data mapping to specific hash (one-way property) ◦ computationally infeasible to find two data to

Cryptographic Hash Function

Cryptographic Hash Function

Hash Functions & Message Authentication

Hash Functions & Message Authentication

Hash Functions & Digital Signatures

Hash Functions & Digital Signatures

Other Hash Function Uses �to create a one-way password file ◦ store hash of

Other Hash Function Uses �to create a one-way password file ◦ store hash of password not actual password �for intrusion detection and virus detection ◦ keep & check hash of files on system �pseudorandom function (PRF) or pseudorandom number generator (PRNG)

Two Simple Insecure Hash Functions �consider two simple insecure hash functions �bit-by-bit exclusive-OR (XOR)

Two Simple Insecure Hash Functions �consider two simple insecure hash functions �bit-by-bit exclusive-OR (XOR) of every block ◦ Ci = bi 1 xor bi 2 xor. . . xor bim ◦ a longitudinal redundancy check ◦ reasonably effective as data integrity check �one-bit circular shift on hash value ◦ for each successive n-bit block �rotate current hash value to left by 1 bit and XOR

Hash Function Requirements

Hash Function Requirements

Attacks on Hash Functions �have brute-force attacks and cryptanalysis �a preimage or second preimage

Attacks on Hash Functions �have brute-force attacks and cryptanalysis �a preimage or second preimage attack ◦ find y s. t. H(y) equals a given hash value �collision resistance ◦ find two messages x & y with same hash so H(x) = H(y) �hence value 2 m/2 determines strength of hash code against brute-force attacks ◦ 128 -bits inadequate, 160 -bits suspect

Birthday Attacks �might think a 64 -bit hash is secure �but by Birthday Paradox

Birthday Attacks �might think a 64 -bit hash is secure �but by Birthday Paradox is not �birthday attack works thus: ◦ given user prepared to sign a valid message x m/ ◦ opponent generates 2 2 variations x’ of x, all with essentially the same meaning, and saves them m/ ◦ opponent generates 2 2 variations y’ of a desired fraudulent message y ◦ two sets of messages are compared to find pair with same hash (probability > 0. 5 by birthday paradox) ◦ have user sign the valid message, then substitute the forgery which will have a valid signature �conclusion is that need to use larger

Hash Function Cryptanalysis �cryptanalytic attacks exploit some property of alg so faster than exhaustive

Hash Function Cryptanalysis �cryptanalytic attacks exploit some property of alg so faster than exhaustive search �hash functions use iterative structure ◦ process message in blocks (incl length) �attacks focus on collisions in function f

Block Ciphers as Hash Functions �can use block ciphers as hash functions ◦ using

Block Ciphers as Hash Functions �can use block ciphers as hash functions ◦ using H 0=0 and zero-pad of final block ◦ compute: Hi = EMi [Hi-1] ◦ and use final block as the hash value ◦ similar to CBC but without a key �resulting hash is too small (64 -bit) ◦ both due to direct birthday attack ◦ and to “meet-in-the-middle” attack �other variants also susceptible to attack

Secure Hash Algorithm �SHA originally designed by NIST & NSA in 1993 �was revised

Secure Hash Algorithm �SHA originally designed by NIST & NSA in 1993 �was revised in 1995 as SHA-1 �US standard for use with DSA signature scheme ◦ standard is FIPS 180 -1 1995, also Internet RFC 3174 ◦ nb. the algorithm is SHA, the standard is SHS �based on design of MD 4 with key differences �produces 160 -bit hash values

Revised Secure Hash Standard �NIST issued revision FIPS 180 -2 in 2002 �adds 3

Revised Secure Hash Standard �NIST issued revision FIPS 180 -2 in 2002 �adds 3 additional versions of SHA ◦ SHA-256, SHA-384, SHA-512 �designed for compatibility with increased security provided by the AES cipher �structure & detail is similar to SHA-1 �hence analysis should be similar �but security levels are rather higher

SHA Versions SHA-1 Message digest size SHA-224 SHA-256 SHA-384 SHA-512 160 224 256 384

SHA Versions SHA-1 Message digest size SHA-224 SHA-256 SHA-384 SHA-512 160 224 256 384 512 < 264 < 2128 Block size 512 512 1024 Word size 32 32 32 64 64 Number of steps 80 64 64 80 80 Message size

SHA-512 Overview

SHA-512 Overview

SHA-512 Compression Function �heart of the algorithm �processing message in 1024 -bit blocks �consists

SHA-512 Compression Function �heart of the algorithm �processing message in 1024 -bit blocks �consists of 80 rounds ◦ updating a 512 -bit buffer ◦ using a 64 -bit value Wt derived from the current message block ◦ and a round constant based on cube root of first 80 prime numbers

SHA-512 Round Function

SHA-512 Round Function

SHA-512 Round Function

SHA-512 Round Function

SHA-3 �SHA-1 not yet "broken” ◦ but similar to broken MD 5 & SHA-0

SHA-3 �SHA-1 not yet "broken” ◦ but similar to broken MD 5 & SHA-0 ◦ so considered insecure �SHA-2 (esp. SHA-512) seems secure ◦ shares same structure and mathematical operations as predecessors so have concern �NIST announced in 2007 a competition for the SHA-3 next gen NIST hash function ◦ goal to have in place by 2012 but not fixed

Message Authentication Code (MAC) �generated by an algorithm that creates a small fixed-sized block

Message Authentication Code (MAC) �generated by an algorithm that creates a small fixed-sized block ◦ depending on both message and some key ◦ like encryption though need not be reversible �appended to message as a signature �receiver performs same computation on message and checks it matches the MAC �provides assurance that message is unaltered and comes from sender

Message Authentication Code

Message Authentication Code

Authentication Functions Basic Uses of MAC 23

Authentication Functions Basic Uses of MAC 23

Message Authentication Codes �as shown the MAC provides confidentiality �can also use encryption for

Message Authentication Codes �as shown the MAC provides confidentiality �can also use encryption for secrecy ◦ generally use separate keys for each ◦ can compute MAC either before or after encryption ◦ is generally regarded as better done before �why use a MAC? ◦ sometimes only authentication is needed ◦ sometimes need authentication to persist longer than the encryption (eg. archival use) �note that a MAC is not a digital signature

MAC Properties �a MAC is a cryptographic checksum MAC = CK(M) ◦ condenses a

MAC Properties �a MAC is a cryptographic checksum MAC = CK(M) ◦ condenses a variable-length message M ◦ using a secret key K ◦ to a fixed-sized authenticator �is a many-to-one function ◦ potentially many messages have same MAC ◦ but finding these needs to be very difficult

Requirements for MACs taking into account the types of attacks � need the MAC

Requirements for MACs taking into account the types of attacks � need the MAC to satisfy the following: � 1. knowing a message and MAC, is infeasible to find another message with same MAC 2. MACs should be uniformly distributed 3. MAC should depend equally on all bits of the message

Using Symmetric Ciphers for MACs �can use any block cipher chaining mode and use

Using Symmetric Ciphers for MACs �can use any block cipher chaining mode and use final block as a MAC �Data Authentication Algorithm (DAA) is a widely used MAC based on DES-CBC ◦ using IV=0 and zero-pad of final block ◦ encrypt message using DES in CBC mode ◦ and send just the final block as the MAC �or the leftmost M bits (16≤M≤ 64) of final block �but final MAC is now too small for security

HMAC Design Objectives Ø use, without modifications, hash functions Ø allow for easy replaceability

HMAC Design Objectives Ø use, without modifications, hash functions Ø allow for easy replaceability of embedded hash function Ø preserve original performance of hash function without significant degradation Ø use and handle keys in a simple way. Ø have well understood cryptographic analysis of authentication mechanism strength

HMAC �specified as Internet standard RFC 2104 �uses hash function on the message: HMACK(M)=

HMAC �specified as Internet standard RFC 2104 �uses hash function on the message: HMACK(M)= Hash[(K+ XOR opad) || Hash[(K+ XOR ipad) || M)] ] ◦ where K+ is the key padded out to size ◦ opad, ipad are specified padding constants �overhead is just 3 more hash calculations than the message needs alone �any hash function can be used ◦ eg. MD 5, SHA-1, RIPEMD-160, Whirlpool

HMAC Overview

HMAC Overview

HMAC Security �proved security of HMAC relates to that of the underlying hash algorithm

HMAC Security �proved security of HMAC relates to that of the underlying hash algorithm �attacking HMAC requires either: ◦ brute force attack on key used ◦ birthday attack (but since keyed would need to observe a very large number of messages) �choose hash function used based on speed verses security constraints

Hash Functions �condenses arbitrary message to fixed size �usually assume that the hash function

Hash Functions �condenses arbitrary message to fixed size �usually assume that the hash function is public and not keyed ◦ cf. MAC which is keyed �hash used to detect changes to message �can use in various ways with message �most often to create a digital signature

Hash Functions & Digital Signatures

Hash Functions & Digital Signatures

Digital Signatures �have looked at message authentication ◦ but does not address issues of

Digital Signatures �have looked at message authentication ◦ but does not address issues of lack of trust �digital signatures provide the ability to: ◦ verify author, date & time of signature ◦ authenticate message contents ◦ be verified by third parties to resolve disputes �hence include authentication function with additional capabilities

Digital Signature Model

Digital Signature Model

Digital Signature Model

Digital Signature Model

Attacks and Forgeries �attacks ◦ key-only attack ◦ known message attack ◦ generic chosen

Attacks and Forgeries �attacks ◦ key-only attack ◦ known message attack ◦ generic chosen message attack ◦ directed chosen message attack ◦ adaptive chosen message attack �break success levels ◦ total break ◦ selective forgery ◦ existential forgery

Digital Signature Requirements Ø must depend on the message signed Ø must use information

Digital Signature Requirements Ø must depend on the message signed Ø must use information unique to sender lto prevent both forgery and denial Ø must be relatively easy to produce Ø must be relatively easy to recognize & verify Ø be computationally infeasible to forge lwith new message for existing digital signature lwith fraudulent digital signature for given message Ø be practical save digital signature in storage

Direct Digital Signatures �involve only sender & receiver �assumed receiver has sender’s publickey �digital

Direct Digital Signatures �involve only sender & receiver �assumed receiver has sender’s publickey �digital signature made by sender signing entire message or hash with private-key �can encrypt using receivers public-key �important that sign first then encrypt message & signature �security depends on sender’s privatekey

El. Gamal Digital Signatures �signature variant of El. Gamal, related to D-H ◦ so

El. Gamal Digital Signatures �signature variant of El. Gamal, related to D-H ◦ so uses exponentiation in a finite (Galois) ◦ with security based difficulty of computing discrete logarithms, as in D-H �use private key for encryption (signing) �uses public key for decryption (verification) �each user (eg. A) generates their key ◦ chooses a secret key (number): 1 < x. A < q-1 x. A ◦ compute their public key: y. A = a mod q

El. Gamal Digital Signature �Alice signs a message M to Bob by computing ◦

El. Gamal Digital Signature �Alice signs a message M to Bob by computing ◦ the hash m = H(M), 0 <= m <= (q-1) ◦ chose random integer K with 1 <= K <= (q-1) and gcd(K, q-1)=1 k ◦ compute temporary key: S 1 = a mod q ◦ compute K-1 the inverse of K mod (q-1) ◦ compute the value: S 2 = K-1(m-x. AS 1) mod (q-1) ◦ signature is: (S 1, S 2) �any user B can verify the signature m ◦ V 1 = a mod q ◦ V 2 = y. AS 1 S 1 S 2 mod q ◦ signature is valid if V 1 = V 2 by computing

El. Gamal Signature Example �use field GF(19) q=19 and a=10 �Alice computes her key:

El. Gamal Signature Example �use field GF(19) q=19 and a=10 �Alice computes her key: ◦ A chooses x. A=16 & computes y. A=10 16 mod 19 = 4 �Alice signs message with hash m=14 as (3, 4): ◦ choosing random K=5 which has gcd(18, 5)=1 5 ◦ computing S 1 = 10 mod 19 = 3 ◦ finding K-1 mod (q-1) = 5 -1 mod 18 = 11 ◦ computing S 2 = 11(14 -16. 3) mod 18 = 4 �any user B can verify the signature 14 ◦ V 1 = 10 mod 19 = 16 ◦ V 2 = 43. 34 = 5184 = 16 mod 19 ◦ since 16 = 16 signature is valid by computing

Schnorr Digital Signatures �also uses exponentiation in a finite (Galois) ◦ security based on

Schnorr Digital Signatures �also uses exponentiation in a finite (Galois) ◦ security based on discrete logarithms, as in D-H �minimizes message dependent computatio ◦ multiplying a 2 n-bit integer with an n-bit integer �main work can be done in idle time �have using a prime modulus p ◦ p– 1 has a prime factor q of appropriate size ◦ typically p 1024 -bit and q 160 -bit numbers

Schnorr Key Setup �choose suitable primes p , q q �choose a such that

Schnorr Key Setup �choose suitable primes p , q q �choose a such that a = 1 mod p �(a, p, q) are global parameters for all �each user (eg. A) generates a key ◦ chooses a secret key (number): 0 < s. A < q -s. A ◦ compute their public key: v. A = a mod q

Schnorr Signature �user signs message by ◦ choosing random r with 0<r<q and computing

Schnorr Signature �user signs message by ◦ choosing random r with 0<r<q and computing = ar mod p ◦ concatenate message with x and hash result to computing: e = H(M || x) ◦ computing: y = (r + se) mod q ◦ signature is pair (e, y) �any other user can verify the signature as follows ◦ computing: x' = ayve mod p ◦ verifying that: e = H(M || x’)

Digital Signature Standard (DSS) �US Govt approved signature scheme �designed by NIST & NSA

Digital Signature Standard (DSS) �US Govt approved signature scheme �designed by NIST & NSA in early 90's �published as FIPS-186 in 1991 �revised in 1993, 1996 & then 2000 �uses the SHA hash algorithm �DSS is the standard, DSA is the algorithm �FIPS 186 -2 (2000) includes alternative RSA & elliptic curve signature variants �DSA is digital signature only unlike RSA �is a public-key technique

DSS vs RSA Signatures

DSS vs RSA Signatures

Digital Signature Algorithm (DSA) Ø creates a 320 bit signature Ø with 512 -1024

Digital Signature Algorithm (DSA) Ø creates a 320 bit signature Ø with 512 -1024 bit security Ø smaller and faster than RSA Ø a digital signature scheme only Ø security depends on difficulty of computing discrete logarithms Ø variant of El. Gamal & Schnorr schemes

DSA Key Generation �have shared global public key values (p, q, g): ◦ choose

DSA Key Generation �have shared global public key values (p, q, g): ◦ choose 160 -bit prime number q ◦ choose a large prime p with 2 L-1 < p < 2 L �where L= 512 to 1024 bits and is a multiple of 64 �such that q is a 160 bit prime divisor of (p-1) ◦ choose g = h(p-1)/q �where 1<h<p-1 and h(p-1)/q mod p > 1 �users choose private & compute public ◦ choose random private key: x<q ◦ compute public key: y = gx mod p key:

DSA Signature Creation Ø to sign a message M the sender: lgenerates a random

DSA Signature Creation Ø to sign a message M the sender: lgenerates a random signature key k, k<q lnb. k must be random, be destroyed after use, and never be reused Ø then computes signature pair: r = (gk mod p)mod q s = [k-1(H(M)+ xr)] mod q Ø sends M signature (r, s) with message

DSA Signature Verification �having received M & signature (r, s) �to verify a signature,

DSA Signature Verification �having received M & signature (r, s) �to verify a signature, recipient computes: w = u 1= u 2= v = �if s-1 mod q [H(M)w ]mod q (rw)mod q [(gu 1 yu 2)mod p ]mod q v=r then signature is verified �see Appendix A for details of proof why

DSS Overview

DSS Overview