Lecture #9 Hashing-1
Lecture #9 Hashing-1
Introduction
You, in you daily life make use of Hash Functions that maintain Data Integrity
without even realizing. The biggest example of this is your Windows passwords
Message authentication assures that data received are exactly as sent (i.e., contain
no modification, insertion, deletion, or replay)
MAC
Symmetric Message Encryption
Well ! Encryption can also provide authentication
Since only sender and receiver know the shared key, this implies
that the message would have only been sent by the legitimate sender
However if the sender signs the message using his private-key, then encrypts with
the recipients public key, then this approach can provide both secrecy and
authentication
If there is a mismatch, the receiver knows that the message (or possibly the hash
value) has been altered
..contd
M = input message
H = Hash function
h = H(M)
(H)
(H)Hash
Hash
function
function
Hash (h)
Hash Verification
generation
Message M h
HH
message h
verification
HH
compare
compare
yes/no
Man in the Middle Attack
The hash function must be transmitted in a secure fashion
For instance
Alice transmits a data block and attaches a hash value
Darth intercepts the message, alters or replaces the data block, and calculates
and attaches a new hash value
Bob receives the altered data with the new hash value and does not detect the
change.
MiTM Attack
Hash Function Properties
Variable Input Size: H can be applied to a block of data of any size.
Fixed output: H produces a fixed length output.
Efficient: H(x) is easy to compute for any given x making both hardware and
software implementations practical.
Preimage Resistant (One way property): For any given value h, it is
computationally infeasible to find x such that H(x) = h.
Second Preimage Resistant (weak collision resistant): For any given block x, it
is computationally infeasible to find any y with H(y) = H(x), y ≠ x.
Pseudorandomness: Output of H meets standard tests for pseudorandomness
Applications of Hash Functions
There are a variety of ways in which a hash code can be used to provide
message authentication
When confidentiality is not required, Case-2 has an advantage over Case-1 and
Case-4
Because it does not encrypt the entire message but only the hash, in that less
computation is required
Nevertheless, there has been growing interest in techniques that avoid encryption
like Case-3
Why not Encryption?
Encryption software is relatively slow. Even though the amount of data to be
encrypted per message is small, there may be a steady stream of messages into
and out of a system
Encryption hardware is optimized toward large data sizes. For small blocks of
data, a high proportion of the time is spent in initialization/invocation overhead
Message Authentication Code
Message authentication is achieved using a message authentication code
(MAC), also known as a keyed hash function. Its also called a tag
Typically, MACs are used between two parties that share a secret key to
authenticate information exchanged between those parties
A MAC function takes as input a secret key and a data block and produces a hash
value, referred to as the MAC, which is associated with the protected message
If the integrity of the message needs to be checked, the MAC function can be
applied to the message and the result compared with the associated MAC value
An attacker who alters the message will be unable to alter the associated MAC
value without knowledge of the secret key
Message Authentication Code
MAC = F(K, M)
MAC
MAC
M = input message function
secret key K
function
F = MAC function
K = shared secret key
fixed length MAC
MAC Generation and Verification
Secret Key K
generation Message M MAC
FF
message MAC
verification
FF
compare
compare
Secret Key
yes/no
Digital Signatures
Another important application, which is similar to the message authentication
application, is the digital signature
The operation of the digital signature is similar to that of the MAC. In the case of
the digital signature, the hash value of a message is encrypted with a user’s
private key
Anyone who knows the user’s public key can verify the integrity of the message
that is associated with the digital signature
In this case, an attacker who wishes to alter the message would need to know the
user’s private key
Digital Signature (contd)
MAC vs. DS
MAC differs from DS because MAC values are both generated and
verified using same secret key
This implies the sender and receiver both have to agree on the same
key before initiating communications, as with symmetric encryption
MACs don’t provide non-repudiation, DS does