+ All Categories
Home > Documents > Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and...

Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and...

Date post: 16-Mar-2020
Category:
Upload: others
View: 13 times
Download: 0 times
Share this document with a friend
33
Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms
Transcript
Page 1: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Cryptography and Network Security

Chapter 12

Hash Algorithms and MAC Algorithms

Page 2: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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 (CMAC) or hash

function (HMAC)

Page 3: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Hash Algorithm Structure

Page 4: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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 RFC3174– nb. the algorithm is SHA, the standard is SHS

• based on design of MD4 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

Page 5: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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

Page 6: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

SHA-512 Overview

Page 7: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Steps in the Algorithm

1. Append the padding bits2. Append the length3. Initialize the hash buffer4. Process message in 1024-bit blocks5. Output the message digest (512 bits)

Page 8: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Initialize the Hash Buffer

Page 9: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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

Page 10: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Processing a Single 1024 bit

Block

Page 11: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

SHA-512 Round Function

Page 12: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Some of the Terms

Page 13: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Round Constants

Page 14: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

SHA-512 Round Function

σ0 := (w[i-15] rightrotate 7) xor(w[i-15] rightrotate 18) xor(w[i-15] rightshift 3)

σ1 := (w[i-2] rightrotate 17) xor(w[i-2] rightrotate 19) xor(w[i-2] rightshift 10)

Page 15: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Message Digest Output

Page 16: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

SHA-512Logic

Summary

σ0 := (w[i-15] rightrotate 7) xor(w[i-15] rightrotate 18) xor(w[i-15] rightshift 3)

σ1 := (w[i-2] rightrotate 17) xor(w[i-2] rightrotate 19) xor(w[i-2] rightshift 10)

Page 17: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Whirlpool

• now examine the Whirlpool hash function• endorsed by European NESSIE project• uses modified AES internals as

compression function• addressing concerns on use of block

ciphers seen previously• with performance comparable to dedicated

algorithms like SHA

Page 18: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Whirlpool Overview

Page 19: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Whirlpool Block Cipher W

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

– input is mapped row wise– has 10 rounds– a different primitive polynomial for GF(2^8)– uses different S-box design & values

Page 20: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Whirlpool Block

Cipher W

Page 21: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Whirlpool Matrix Structure

Page 22: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

WhirlpoolSBox

Page 23: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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 hardware than

SHA, but with better resulting performance

Page 24: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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 25: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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 • overhead is just 3 more hash calculations than

the message needs alone• any hash function can be used

– eg. MD5, SHA-1, RIPEMD-160, Whirlpool

Page 26: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

HMAC Overview

Page 27: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

HMAC Implementation

Page 28: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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

Page 29: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

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 SP800-38B

Page 30: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

CMAC Overview

Page 31: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

The Algorithm (from Wikipedia)To generate an ℓ-bit CMAC tag t of message m using a

b-bit block cipher E and secret key k, one first generates two b-bit sub-keys k1 and k2 using the following algorithm (this is equivalent to multiplication by x and x2 in a finite field GF(2b)). Let signify a standard left-shift operator:

1.Calculate a temporary value k0 = Ek(0).2. If msb(k0) = 0 then k1 = k0 1 else k1 = (k0 1) C,

where C is a certain constant that depends only on b. (Specifically, C is the non-leading coefficients of the lexicographically first irreducible degree-b binary polynomial with the minimal number of ones.)

3. If msb(k1) = 0 then k2 = k1 1 else k2 = (k1 1) C

Page 32: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

An Example (from Wikipedia)Suppose b = 4, C = 00112, and k0 = Ek(0) = 01012. Then k1 =

10102 and k2 = 0100 0011 = 01112

The CMAC tag generation process is as follows:1. Divide message into b-bit blocks m = m1 … mn−1 mn′ where

m1, …, mn−1 are complete blocks.2. If mn′ is a complete block then mn = k1 mn′ else mn = k2

(mn′ 10…02).3. Let c0 = 00…02.4. For i = 1,…, n, calculate ci = Ek(ci−1 mi).5. Output t = msbℓ(cn).The verification process is as follows:1. Use the above algorithm to generate the tag.2. Check that the generated tag is equal to the received tag.

Page 33: Cryptography and Network Security Chapter 12 Hash ...blk/cryptography/ch12.pdf · Cryptography and Network Security Chapter 12 Hash Algorithms and MAC Algorithms. Hash and MAC Algorithms

Summary• Some current hash algorithms

– SHA-512 – Whirlpool

• There is a NIST competition for SHA-3• HMAC authentication using hash function• CMAC authentication using a block cipher


Recommended