M4 Cryptographic Hash
M4 Cryptographic Hash
Authentication Protocols
Module 4
HASH Function
• A hash function H
• It accepts a variable-length block of data M as input and produces
a fixed-size hash value
• h = H(M)
• What is the output look like?
• Change in a bit or bits will change the output.
• Hash functions are used to determine whether or not data has changed
• Integrity – (CIA)
• The property a good hash function
• A large set of inputs will produce output
• Evenly distributed
• Apparently random
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
1
25-02-2025
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
2
25-02-2025
Authentication
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
MIM
3
25-02-2025
Secure hash
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
Secure hash
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
4
25-02-2025
Message authentication
• A procedure to verify the received messages has
• Come from the alleged source (masquerade, MIM)
• Not been altered (modification)
• Sequencing (insertion, deletion, and reordering of message)
• Timeliness
• Non-repudiation
• A digital signature is an authentication technique with
• Measures to counter repudiation by the source.
Message authentication
• Hash function
• A function that maps a message of any length into a fixed length
hash value, which serves as the authenticator
• Message encryption
• The ciphertext of the entire message serves as its authenticator
CMAC
• Message authentication code MAC:
• A function of the message and a secret key
• It produces a fixed-length value that serves as the authenticator
5
25-02-2025
6
25-02-2025
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
7
25-02-2025
Digital Signature
• The hash value of a message is encrypted with a user’s
private key.
• Who has the private key?
• Who can decrypt it
• Does it ensure non-repudiation?
• Does is ensure sender?
• Can the attacker use the public key to encrypt the hash value and
do MIM?
• An attacker who wishes to alter the message would need
to know the user’s private key.
Digital
• The Signature
hash value of a message is encrypted with a user’s private key.
• Only the sender could have produced the encrypted hash value
hash code.
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
8
25-02-2025
9
25-02-2025
SHA-3
• NIST announced in 2007 a competition to produce the next
generation NIST hash function
• Called SHA-3.
• The winning design for SHA-3 was announced by NIST in
October 2012.
• SHA-3 is a cryptographic hash function that is intended to
complement SHA-2.
10
25-02-2025
SHA-512
• The processing consists of the following steps:
• Step 1: Append padding bits,
• consists of a single 1-bit followed by the necessary number of 0-bits,
• The length is congruent to 896 modulo 1024
• Step 2: Append length of message as unsigned 128-bit integer
• Big-endian
• Padded with 0
• Step 3: Initialize hash buffer to a set of 64-bit integer constants
• Step 4: Process the message in 1024-bit
• 128-word blocks, which forms the heart of the algorithm.
• Each round takes as input the 512-bit buffer value
• updates the contents of that buffer.
• 80 rounds of processing
• Step 5: Output the final state value as the resulting hash
SHA-512
a = 6A09E667F3BCC908 e = 510E527FADE682D1
b = BB67AE8584CAA73B f = 9B05688C2B3E6C1F
c = 3C6EF372FE94F82B g = 1F83D9ABFB41BD6B
d = A54FF53A5F1D36F1 h = 5BE0CD19137E2179
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
11
25-02-2025
SHA-512
80 rounds of processing
For message and IV
1. 512 bit buffer (IV/Hi-1)
2. wt – 64 bit,
part of message or H0 = IV
Derived – message schedule Hi = SUM64(H i-1, abcdefghi)
3. Kt – Constant value MD = HN
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
SHA-512
One of the 80 round comprise of following
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
12
25-02-2025
SHA-512
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
SHA-512
13
25-02-2025
SHA-512 algorithm
• It has the property that every bit of the hash code is a
• Function of every bit of the input.
• The complex repetition of the basic function F produces results that are well
mixed.
• It is unlikely that two messages chosen at random,
• Even if they exhibit similar regularities, will have the same hash code.
• Unless there is some hidden weakness in SHA-512
• It has not so far been published.
• The difficulty of coming up with two messages having the same MD
• on the order of 2256 operations
• The difficulty of finding a message with a given digest is
• on the order of 2512 operations
SWE 3002 Information & System Security
Prof. Rajesh Kumar VIT Chennai
Password Storage
• Should the admin be allowed to see user’s passwd.
• How can this be prevented?
• What if the hacker gets the passwd file.
• Can this be prevented?
• With given mechanism, is the CIA is ensured for the user
14
25-02-2025
15
25-02-2025
16
25-02-2025
HMAC
• HMACK(M)= Hash[(K+ XOR opad) ||
Hash[(K+ XOR ipad) || M)] ]
• where K+ is the key left padded to size b with
zero
• opad, ipad are specified padding constants
• Any hash function can be used
• eg. MD5, SHA-1, RIPEMD-160, Whirlpool
• ipad = 00110110 (36 in hexadecimal)
repeated b/8 times
opad = 01011100 (5C in hexadecimal)
repeated b/8 times
• How to make HMAC more efficient?
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
17
25-02-2025
HMAC
1. Append zeros to the left end of K to
create a b-bit string
2. XOR (bitwise exclusive-OR) K + with ipad
to produce the b-bit block Si.(Half flip)
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 So (Half flip)
6. Append the hash result from step 4 to So.
7. Apply H to the stream generated in step 6
and output the result
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
HMAC Security
• Designer of HMAC have proved security of HMAC relates to that of the
underlying hash algorithm
• In given time make message – MAC pairs with same key
• Attacking HMAC requires either:
• Brute force attack on key used – 2n
• Birthday attack 2n/2
• HAMC is keyed would need to observe a 2n number of messages with same key
• For a hash code (MD5) length of 128 bits,
• 264 observed blocks (272 bits) generated using the same key.
• On a 1-Gbps link, one would need to observe a continuous stream of messages
with no change in key for about 150,000 years in order to succeed. (MD5)
• Choose hash function based on speed verses security constraints
18
25-02-2025
HMAC - efficient
f(IV, (K + ⊕ ipad))
f(IV, (K + ⊕ opad))
n bits equal to IV
f(cv, block) is the compression function
for the hash function
Input : a chaining variable of n bits and a
block of b bits and produces a chaining
variable of n bits.
SWE 3002 Information & System Security Ref: Cryptography and Network Security Principles and Practice – William Stallings
Prof. Rajesh Kumar VIT Chennai
19