1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie...

22
1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

Transcript of 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie...

Page 1: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

1

Chapter 12: Hash and MAC Algorithms

Fourth Editionby William Stallings

Lecture slides by Lawrie Brown(modified by Prof. M. Singhal, U of

Kentucky)

Page 2: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

2

Hash and MAC Algorithms

• Hash Functions– condense arbitrary size message to fixed size– by processing message in blocks– through some compression function– either custom or block cipher based

• Message Authentication Code (MAC)– fixed sized authenticator for some message– to provide authentication for message– by using block cipher mode or hash function

Page 3: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

3

Hash Algorithm Structure

Page 4: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

4

Secure Hash Algorithm (SHA)

• SHA originally designed by NIST & NSA in 1993• was revised in 1995 as SHA-1• US standard• based on design of MD4• produces 160-bit hash values • recent 2005 results on security of SHA-1 have

raised concerns on its use in future applications

Page 5: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

5

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 is similar• but security levels are rather higher

Page 6: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

6

SHA-512 Overview

Page 7: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

7

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 Kt that represents the

first 64 bits of the fractional parts of the cube root of first 80 prime numbers

Page 8: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

8

SHA-512 Round Function

Page 9: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

9

SHA-512 Round Function

Page 10: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

10

Whirlpool

• Whirlpool is a hash function• endorsed by European NESSIE project• 512 bit hash code• uses modified AES internals as compression

function• Addresses the concerns on use of block ciphers

seen previously• with performance comparable to dedicated

algorithms like SHA

Page 11: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

11

Whirlpool Overview

Page 12: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

12

Whirlpool Block Cipher W

• designed specifically for hash function use• with security and efficiency of AES• 512-bit block size• similar structure & functions as AES but

– Matrix orientation: input is mapped row-wise (rather than column-wise)

– has 10 rounds (not 10, 12, or 14)– a different primitive polynomial for GF(2^8)– uses different S-box design & values

Page 13: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

13

Whirlpool Block Cipher W

Page 14: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

14

Whirlpool Block Cipher

• Substitute Bytes: a simple table lookup that provides a non-linear mapping.

• Shift Columns: causes a circular downwards shift of each column. (ensures that 8 bytes of a row are spread into eight different rows.)

• Mix rows: Each byte in a row is mapped into a new value that is a function of all 8 bytes in that row. (achieves diffusion).

Page 15: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

15

Whirlpool Performance & Security

• Whirlpool is a very new proposal

• hence little experience with use

• but many AES findings should apply

• does seem to need more h/w than SHA, but with better resulting performance (in terms of throughput).

Page 16: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

16

Keyed Hash Functions as MACs

• want a MAC based on a hash function – because hash functions are generally faster– code for crypto hash functions widely

available

• hash includes a key along with message

• original proposal:KeyedHash = Hash(Key|Message) – some weaknesses were found with this

• eventually led to development of HMAC

Page 17: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

17

HMAC

• specified as Internet standard RFC2104 • uses hash function on the message:

HMACK = Hash[(K+ XOR opad) || Hash[(K+ XOR ipad)||M)]]

• where K+ is the key padded out to size • and opad, ipad are specified padding constants -ipad =00110110 (36 in hex) repeated b/8 times -apad=01011100 (5C in hex) repeated b/8 times(b is number of bits in a block)• any hash function can be used

– E.g., MD5, SHA-1, RIPEMD-160, Whirlpool

Page 18: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

18

HMAC Overview

Page 19: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

19

HMAC Security

• The security of HMAC relates to that of the underlying hash algorithm

• attacking HMAC requires either:– brute force attack on key used

• choose hash function used based on speed versus security constraints

Page 20: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

20

CMAC

• previously saw the DAA (CBC-MAC)

• widely used in govt & industry

• but has message size limitation

• can overcome using 3 keys & padding

• thus forming the Cipher-based Message Authentication Code (CMAC)

• adopted by NIST SP800-38B

Page 21: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

21

CMAC Overview

Page 22: 1 Chapter 12: Hash and MAC Algorithms Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal, U of Kentucky)

22

Summary

• have considered:– some current hash algorithms

• SHA-512 & Whirlpool

– HMAC authentication using hash function– CMAC authentication using a block cipher