Lecture 3 Message Authentication Modified version based on
Lecture 3 Message Authentication Modified version based on lecture slides by Lawrie Brown
Message Authentication • message authentication is concerned with: • protecting the integrity of a message • validating identity of originator • non-repudiation of origin (dispute resolution) • message’s timeliness may be important (why? ) • artificially delayed and replayed
Message Authentication (2) • Authentication without encryption, the three alternative functions are used: • message encryption • message authentication code (MAC) • hash function • Is symmetric encryption a suitable tool for data authentication? • Consider order of block messages
Message Authentication Code Principles • use a secret key to generate a small block of data, called message authentication code (MAC) • assume two parties share a common secret key • MAC process • • • A wants to send a message to B calculate MAC as a function of message and secret key MAC is appended B does the same and compares MAC If matched, the following statements apply • B is assured that the message is not altered. (Altering the message results in a change of MAC) • B is assured that the message is from A • If the message includes a seq. no. , B is assured that the proper sequence
Message Authen. Using MAC
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 lcomputationally infeasible to find data mapping to specific hash (one-way property) lcomputationally infeasible to find two data to same hash (collision-free property)
Approaches to Msg. Auth. Using Hash Function
Approaches to Msg. Auth. Using Hash Function
Approaches to Msg. Auth. Using Hash Function
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 block • good for data integrity but useless for security
Hash Function Requirements
Attacks on Hash Functions Øhave brute-force attacks and cryptanalysis Øa preimage or second preimage attack lfind y s. t. H(y) equals a given hash value Øcollision resistance lfind 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 l 128 -bits inadequate, 160 -bits suspect
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 lstandard is FIPS 180 -1 1995, also Internet RFC 3174 lnb. the algorithm is SHA, the standard is SHS Øbased on design of MD 4 with key differences Øproduces 160 -bit hash values Ørecent 2005 results on security of SHA-1 have raised concerns on its use in future applications
Revised Secure Hash Standard ØNIST issued revision FIPS 180 -2 in 2002 Øadds 3 additional versions of SHA l. 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 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 Core Function Øheart of the algorithm Øprocessing message in 1024 -bit blocks Øconsists of 80 rounds lupdating a 512 -bit buffer lusing a 64 -bit value Wt derived from the current message block land a round constant based on cube root of first 80 prime numbers
Keyed Hash Functions as MACs Øwant a MAC based on a hash function lbecause hash functions are generally faster lcrypto hash function code is widely available Øhash includes a key along with message Øoriginal proposal: Keyed. Hash = Hash(Key|Message) lsome weaknesses were found with this Øeventually led to development of HMAC
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)= 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 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 (not in the scope of this course) • choose hash function used based on speed verses security constraints
CMAC • previously saw the DAA (CBC-MAC) • widely used in govt & industry • but has message size limitation • can overcome using 2 keys & padding • thus forming the Cipher-based Message Authentication Code (CMAC) • adopted by NIST SP 800 -38 B
CMAC Overview
Authenticated Encryption Øsimultaneously protect confidentiality and authenticity of communications loften required but usually separate Øapproaches l. Hash-then-encrypt: E(K, (M || H(M)) l. MAC-then-encrypt: E(K 2, (M || MAC(K 1, M)) l. Encrypt-then-MAC: (C=E(K 2, M), T=MAC(K 1, C) l. Encrypt-and-MAC: (C=E(K 2, M), T=MAC(K 1, M) Ø decryption /verification straightforward Øbut security vulnerabilities with all these
Counter with Cipher Block Chaining-Message Authentication Code (CCM) • NIST standard SP 800 -38 C for Wi. Fi • variation of encrypt-and-MAC approach • algorithmic ingredients • AES encryption algorithm • CTR mode of operation • CMAC authentication algorithm • single key used for both encryption & MAC
CCM Operation
Private-Key Cryptography Øtraditional private/secret/single key cryptography uses one key Øshared by both sender and receiver Øif this key is disclosed communications are compromised Øalso is symmetric, parties are equal Øhence does not protect sender from receiver forging a message & claiming is sent by sender
Public-Key Cryptography • probably most significant advance in the 3000 year history of cryptography • uses two keys – a public & a private key • asymmetric since parties are not equal • uses clever application of number theoretic concepts to function • complements rather than replaces private key crypto
Why Public-Key Cryptography? • developed to address two key issues: • key distribution – how to have secure communications in general without having to trust a KDC with your key • digital signatures – how to verify a message comes intact from the claimed sender • public invention due to Whitfield Diffie & Martin Hellman at Stanford Uni in 1976 • known earlier in classified community
Public-Key Cryptography • public-key/two-key/asymmetric cryptography involves the use of two keys: • a public-key, which may be known by anybody, and can be used to encrypt messages, and verify signatures • a related private-key, known only to the recipient, used to decrypt messages, and sign (create) signatures • infeasible to determine private key from public • is asymmetric because • those who encrypt messages or verify signatures cannot decrypt messages or create signatures
Public-Key Cryptography
Symmetric vs Public-Key
Applications for Public-Key Cryptosystems • 3 categories of public-key cryptosystem • Encryption/decryption • Digital signature • Key exchange
Public-key Cryptography Requirements
RSA Øby Rivest, Shamir & Adleman of MIT in 1977 Øbest known & widely used public-key scheme Øbased on exponentiation in a finite (Galois) field over integers modulo a prime lnb. exponentiation takes O((log n)3) operations (easy) Øuses large integers (eg. 1024 bits) Øsecurity due to cost of factoring large numbers lnb. factorization takes O(e log n) operations (hard)
RSA En/decryption • to encrypt a message M the sender: • obtains public key of recipient PU={e, n} • computes: C = Me mod n, where 0≤M<n • to decrypt the ciphertext C the owner: • uses their private key PR={d, n} • computes: M = Cd mod n • note that the message M must be smaller than the modulus n (block if needed)
RSA Key Setup • each user generates a public/private key pair by: • selecting two large primes at random: p, q • computing their system modulus n=p. q • note ø(n)=(p-1)(q-1) • selecting at random the encryption key e • where 1<e<ø(n), gcd(e, ø(n))=1 • solve following equation to find decryption key d • e. d=1 mod ø(n) and 0≤d≤n • publish their public encryption key: PU={e, n} • keep secret private decryption key: PR={d, n}
Why RSA Works • because of Euler's Theorem: • aø(n)mod n = 1 where gcd(a, n)=1 • in RSA have: • n=p. q • ø(n)=(p-1)(q-1) • carefully chose e & d to be inverses mod ø(n) • hence e. d=1+k. ø(n) for some k • hence : Cd = Me. d = M 1+k. ø(n) = M 1. (Mø(n))k = M 1. (1)k = M 1 = M mod n
RSA Example - Key Setup 1. 2. 3. 4. 5. Select primes: p=17 & q=11 Calculate n = pq =17 x 11=187 Calculate ø(n)=(p– 1)(q-1)=16 x 10=160 Select e: gcd(e, 160)=1; choose e=7 Determine d: de=1 mod 160 and d < 160 Value is d=23 since 23 x 7=161= 10 x 160+1 6. Publish public key PU={7, 187} 7. Keep secret private key PR={23, 187}
RSA Example - En/Decryption Øsample RSA encryption/decryption is: Øgiven message M = 88 (nb. 88<187) Øencryption: C = 887 mod 187 = 11 Ødecryption: M = 1123 mod 187 = 88
Diffie-Hellman Key Exchange • first public-key type scheme proposed • by Diffie & Hellman in 1976 along with the exposition of public key concepts • note: now know that Williamson (UK CESG) secretly proposed the concept in 1970 • is a practical method for public exchange of a secret key • used in a number of commercial products
Diffie-Hellman Key Exchange • a public-key distribution scheme • cannot be used to exchange an arbitrary message • rather it can establish a common key • known only to the two participants • value of key depends on the participants (and their private and public key information) • based on exponentiation in a finite (Galois) field (modulo a prime or a polynomial) - easy • security relies on the difficulty of computing discrete logarithms (similar to factoring) – hard
Diffie-Hellman Setup • all users agree on global parameters: • large prime integer or polynomial q • a being a primitive root mod q • each user (eg. A) generates their key • chooses a secret key (number): x. A < q x • compute their public key: y. A = a A mod q • each user makes public that key y. A
Diffie-Hellman Key Exchange • shared session key for users A & B is KAB: x. A. x. B KAB = a mod q x. B = y. A mod q (which B can compute) x = y. B A mod q (which A can compute) • KAB is used as session key in private-key encryption scheme between Alice and Bob • if Alice and Bob subsequently communicate, they will have the same key as before, unless they choose new public-keys • attacker needs an x, must solve discrete log
Diffie-Hellman Example • users Alice & Bob who wish to swap keys: • agree on prime q=353 and a=3 • select random secret keys: • A chooses x. A=97, B chooses x. B=233 • compute respective public keys: 97 • y. A=3 mod 353 = 40 (Alice) 233 • y. B=3 mod 353 = 248 (Bob) • compute shared session key as: x. A 97 • KAB= y. B mod 353 = 248 = 160 x. B 233 • KAB= y. A mod 353 = 40 = 160 (Alice) (Bob)
Key Exchange Protocols • users could create random private/public D-H keys each time they communicate • users could create a known private/public D-H key and publish in a directory, then consulted and used to securely communicate with them • both of these are vulnerable to a meet-in-the-Middle Attack • authentication of the keys is needed
Man-in-the-Middle Attack 1. Darth prepares by creating two private / public keys 2. Alice transmits her public key to Bob 3. Darth intercepts this and transmits his first public key to Bob. Darth also calculates a shared key with Alice 4. Bob receives the public key and calculates the shared key (with Darth instead of Alice) 5. Bob transmits his public key to Alice 6. Darth intercepts this and transmits his second public key to Alice. Darth calculates a shared key with Bob 7. Alice receives the key and calculates the shared key (with Darth instead of Bob) Ø Darth can then intercept, decrypt, re-encrypt, forward all messages between Alice & Bob
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
- Slides: 53