Module 4
Module 4
Module 4
Network Security
Module 4
Message Digest and Hash Functions
1
Module Outline
Hash function - Introduction
Requirements and security
Secure Hash Function (SHA)
Message Authentication Code (MAC)
Message Digest (MD5)
HMAC
Birthday Attack
2
Hash functions
Objective - Data integrity
3
Hash function
Cryptographic hash function is an algorithm
for which it is computationally infeasible to
find either
4
Applications of Cryptographic hash
function
Message authentication
Digital signatures
Other applications
used to create a one-way password file
used for intrusion detection and virus detection
used to construct a pseudorandom function
(PRF) or a pseudorandom number generator
(PRNG).
5
Use of a Hash Function for Message
Authentication
6
Use of a Hash Function for Message
Authentication
7
Simplified examples of Digital
Signature
8
Simple Hash function
The input is viewed as a sequence of n -bit blocks
The input is processed one block at a time in an
iterative fashion to produce an n-bit hash function
One of the simplest hash functions is the bit-by-bit
exclusive-OR (XOR) of every block. This can be
expressed as
12
Requirements for a Cryptographic
Hash Function H
13
Hash functions based on Cipher
Block Chaining
Divide a message M into fixed-size blocks M1, M2, …,MN
and use a symmetric encryption system such as DES to
compute the hash code G as
H0 = initial value
Hi = E(Mi, Hi-1)
G = HN
Prone to meet-in-the-middle-attack
Davies and Price [DAVI89] describe the variation:
Hi = E(Mi, Hi-1) ⊕Hi-1
Another variation, proposed in [MEYE88], is
Hi = E(Hi-1, Mi) ⊕Mi
14
Secure Hash Algorithm (SHA)
Most widely used hash function
Developed by by the National Institute of
Standards and Technology (NIST)
SHA is based on the hash function MD4
SHA-1 produces a hash value of 160 bits
NIST produced a revised version of the
standard (SHA-2), with hash value lengths of
256, 384, and 512 bits, known as SHA-256,
SHA-384, and SHA-512, respectively
15
16
SHA-512
The algorithm takes as input a message with a
maximum length of less than 2128 bits and
produces as output a 512-bit message digest
17
18
Steps involved in SHA-512
range of 1 to 1024
The padding consists of a single 1 bit
19
Steps involved in SHA-512
2. Append length bits
A block of 128 bits is appended to the
message.
This block is treated as an unsigned 128-bit
20
Steps involved in SHA-512
3. Initialize hash buffer
A 512-bit buffer is used to hold intermediate and
registers (a, b, c, d, e, f, g, h)
These registers are initialized to the following 64-
21
Steps involved in SHA-512
4. Process message in 1024-bit (128-byte) blocks
The heart of the algorithm is a module that consists
5. Output
After all N 1024-bit blocks have been
summarized as follows:
H0 = IV
Hi = SUM64 (Hi-1, abcdefghi)
MD = HN
24
SHA-512 Round Function
Each round is defined by the following set of
equations:
25
SHA-512 Round Function contd…
26
SHA-512 Round Function contd…
27
SHA-512 Round Function contd…
Wt = a 64-bit word derived from the current
1024-bit input block
Kt = a 64-bit additive constant
+ = addition modulo 264
28
Steps to derive Wt
29
MD5 Algorithm
used for the purpose of data verification
produces 128bit hash value (message digest)
rest 0’s.
30
MD5 Algorithm
2. Append length bits
add the length bits (64bits) to the message
3.Initialize MD buffer
It uses 4 buffers of 32 bits each and it is
32
MD5 Algorithm F is a nonlinear function;
one function is used in
each round (G, H,I)
Ki denotes a 32-bit
constant, different for
each operation
denotes addition
modulo 232.
33
MD5 Algorithm
5. Output Message Digest
The output of the last 512 bit block is ultimately
34
Message Authentication Code
(MAC)
It involves the use of a secret key to generate a small
fixed-size block of data, known as a cryptographic
checksum or MAC
This technique assumes that two communicating parties,
35
MAC
The message plus MAC are transmitted to the
intended recipient
The recipient performs the same calculation on
the received message, using the same secret
key, to generate a new MAC
If the received MAC matches the calculated
MAC, then
The receiver is assured that the message has not
been altered
The receiver is assured that the message is from
the alleged sender
36
Basic Uses of MAC
37
Basic Uses of MAC
38
Requirements of MAC
1. If an opponent observes M and MAC(K,M), it should be
computationally infeasible for the opponent to
construct a message such that MAC(K,M’) = MAC(K,M)
39
Security of MAC
40
MAC based on block Ciphers: Data
Authentication Algorithm (DAA)
41
MACS BASED ON BLOCK CIPHERS: Cipher
based Message Authentication
Code(CMAC)
42
MACs based on Hash Function:
HMAC
The motivations behind developing a MAC
derived from a Cryptographic hash function
are
1. Cryptographic hash functions such as
43
HMAC Algorithm
H = embedded hash function (e.g., MD5, SHA-
1, RIPEMD-160)
IV = initial value input to hash function
M = message input to HMAC (including the
padding specified in the embedded hash
function)
Yi = i th block of M, 0 … i … (L - 1)
L = number of blocks in M
44
HMAC Algorithm
b = number of bits in a block
n = length of hash code produced by
embedded hash function
K = secret key; recommended length is >= n;
if key length is greater than b, the key is input
to the hash function to produce an n-bit key
K+ = K padded with zeros on the left so that
the result is b bits in length
45
46
HMAC Algorithm
ipad = 00110110 (36 in hexadecimal)
repeated b/8 times
opad = 01011100 (5C in hexadecimal)
47
HMAC Algorithm
1. Append zeros to the left end of K to create a b-bit string
K+ (e.g., if K is of length 160 bits and b = 512, then K
will be appended with 44 zeroes(44*8=352 bits of 0)).
2. XOR (bitwise exclusive-OR) K+ with ipad to produce the
b-bit block Si.
3. Append M to Si.
4. Apply H to the stream generated in step 3.
5. XOR K+ with opad to produce the b-bit block S0.
6. Append the hash result from step 4 to S0.
7. Apply H to the stream generated in step 6 and output
the result
48
49
Birthday Attack
It belongs to a class of brute force attacks
It exploits the mathematics behind the
birthday problem in probability theory
The success of this attack largely depends
upon the higher likelihood of collisions found
between random attack attempts and a fixed
degree of permutations
With a birthday attack, it is possible to find a
collosion of a hash function with 50% chance
in 2n/2
50
Birthday Attack
1.The source, A, is prepared to sign a legitimate
message x by appending the appropriate m-bit
hash code and encrypting that hash code with
A’s private key
2.The opponent generates 2m/2 variations x′ of x,
53
Thank you
54