Cryptography and
Cryptography and
Network Security
Network Security
Chapter 11
Chapter 11
Fourth Edition
Fourth Edition
by William Stallings
by William Stallings
Chapter 11 –
Chapter 11 –
Message
Message
Authentication and Hash
Authentication and Hash
Functions
Functions
At cats' green on the Sunday he took the message from At cats' green on the Sunday he took the message from the inside of the pillar and added Peter Moran's name to
the inside of the pillar and added Peter Moran's name to
the two names already printed there in the "Brontosaur"
the two names already printed there in the "Brontosaur"
code. The message now read: “Leviathan to Dragon:
code. The message now read: “Leviathan to Dragon:
Martin Hillman, Trevor Allan, Peter Moran: observe and
Martin Hillman, Trevor Allan, Peter Moran: observe and
tail.” What was the good of it John hardly knew. He felt
tail.” What was the good of it John hardly knew. He felt
better, he felt that at last he had made an attack on Peter
better, he felt that at last he had made an attack on Peter
Moran instead of waiting passively and effecting no
Moran instead of waiting passively and effecting no
retaliation. Besides, what was the use of being in
retaliation. Besides, what was the use of being in
possession of the key to the codes if he never took
possession of the key to the codes if he never took
advantage of it?
advantage of it?
Message Authentication
Message Authentication
message authentication is concerned with: message authentication is concerned with: protecting the integrity of a message protecting the integrity of a message
validating identity of originator validating identity of originator
non-repudiation of origin (dispute resolution)non-repudiation of origin (dispute resolution) will consider the security requirementswill consider the security requirements then three alternative functions used:then three alternative functions used:
message encryptionmessage encryption
Security Requirements
Security Requirements
disclosure
disclosure
traffic analysis
traffic analysis
masquerade
masquerade
content modification
content modification
sequence modification
sequence modification
timing modification
timing modification
source repudiation
source repudiation
Message Encryption
Message Encryption
message encryption by itself also provides
message encryption by itself also provides
a measure of authentication
a measure of authentication
if symmetric encryption is used then:
if symmetric encryption is used then:
receiver know sender must have created itreceiver know sender must have created it since only sender and receiver now key usedsince only sender and receiver now key used know content cannot of been alteredknow content cannot of been altered
if message has if message has suitable structure, redundancy suitable structure, redundancy
Message Encryption
Message Encryption
if public-key encryption is used:
if public-key encryption is used:
encryption provides no confidence of senderencryption provides no confidence of sender since anyone potentially knows public-keysince anyone potentially knows public-key however if however if
• sender sender signssigns message using their private-key message using their private-key
• then encrypts with recipients public keythen encrypts with recipients public key
• have both secrecy and authenticationhave both secrecy and authentication
Message Authentication Code
Message Authentication Code
(MAC)
(MAC)
generated by an algorithm that creates a
generated by an algorithm that creates a
small fixed-sized block
small fixed-sized block
depending on both message and some keydepending on both message and some key like encryption though need not be reversiblelike encryption though need not be reversible
appended to message as a
appended to message as a
signature
signature
receiver performs same computation on
receiver performs same computation on
message and checks it matches the MAC
message and checks it matches the MAC
provides assurance that message is
provides assurance that message is
Message Authentication Code
Message Authentication
Message Authentication
Codes
Codes
as shown the MAC provides authenticationas shown the MAC provides authentication can also use encryption for secrecycan also use encryption for secrecy
generally use separate keys for eachgenerally use separate keys for each
can compute MAC either before or after encryptioncan compute MAC either before or after encryption is generally regarded as better done beforeis generally regarded as better done before
why use a MAC?why use a MAC?
sometimes only authentication is neededsometimes only authentication is needed
sometimes need authentication to persist longer than sometimes need authentication to persist longer than the encryption (eg. archival use)
the encryption (eg. archival use)
MAC Properties
MAC Properties
a MAC is a cryptographic checksum
a MAC is a cryptographic checksum
MAC = C
MAC = CKK(M)(M)
condenses a variable-length message Mcondenses a variable-length message M using a secret key Kusing a secret key K
to a fixed-sized authenticatorto a fixed-sized authenticator
is a many-to-one function
is a many-to-one function
Requirements for MACs
Requirements for MACs
taking into account the types of attacks
taking into account the types of attacks
need the MAC to satisfy the following:
need the MAC to satisfy the following:
1.
1. knowing a message and MAC, is infeasible knowing a message and MAC, is infeasible
to find another message with same MAC to find another message with same MAC
2.
2. MACs should be uniformly distributedMACs should be uniformly distributed
3.
3. MAC should depend equally on all bits of the MAC should depend equally on all bits of the
Using Symmetric Ciphers for
Using Symmetric Ciphers for
MACs
MACs
can use any block cipher chaining mode
can use any block cipher chaining mode
and use final block as a MAC
and use final block as a MAC
Data Authentication Algorithm (DAA)
Data Authentication Algorithm (DAA)
is
is
a widely used MAC based on DES-CBC
a widely used MAC based on DES-CBC
using IV=0 and zero-pad of final blockusing IV=0 and zero-pad of final block
encrypt message using DES in CBC modeencrypt message using DES in CBC mode and send just the final block as the MACand send just the final block as the MAC
• or the leftmost M bits (16or the leftmost M bits (16≤M≤64) of final block≤M≤64) of final block
Hash Functions
Hash Functions
condenses arbitrary message to fixed size
condenses arbitrary message to fixed size
h = H(M)
h = H(M)
usually assume that the hash function is
usually assume that the hash function is
public and not keyed
public and not keyed
cf. MAC which is keyedcf. MAC which is keyed
hash used to detect changes to message
hash used to detect changes to message
can use in various ways with message
can use in various ways with message
Hash Functions & Digital
Hash Functions & Digital
Requirements for Hash
Requirements for Hash
Functions
Functions
1.
1. can be applied to any sized message can be applied to any sized message MM
2.
2. produces fixed-length output produces fixed-length output hh
3.
3. is easy to compute is easy to compute h=H(M)h=H(M) for any message for any message MM
4.
4. given given hh is infeasible to find is infeasible to find xx s.t. s.t. H(x)=hH(x)=h
• one-way propertyone-way property
5.
5. given given xx is infeasible to find is infeasible to find yy s.t s.t. H(y)=H(x). H(y)=H(x)
• weak collision resistanceweak collision resistance
6.
6. is infeasible to find any is infeasible to find any x,yx,y s.t s.t. H(y)=H(x). H(y)=H(x)
Simple Hash Functions
Simple Hash Functions
are several proposals for simple functions
are several proposals for simple functions
based on XOR of message blocks
based on XOR of message blocks
not secure since can manipulate any
not secure since can manipulate any
message and either not change hash or
message and either not change hash or
change hash also
change hash also
need a stronger cryptographic function
need a stronger cryptographic function
Birthday Attacks
Birthday Attacks
might think a 64-bit hash is securemight think a 64-bit hash is secure but by but by Birthday ParadoxBirthday Paradox is not is not
birthday attack birthday attack works thus:works thus:
opponent generates 2opponent generates 2mm//22variations of a valid message variations of a valid message all with essentially the same meaning
all with essentially the same meaning
opponent also generates 2opponent also generates 2mm//22 variations of a desired variations of a desired fraudulent message
fraudulent message
two sets of messages are compared to find pair with two sets of messages are compared to find pair with same hash (probability > 0.5 by birthday paradox) same hash (probability > 0.5 by birthday paradox)
have user sign the valid message, then substitute the have user sign the valid message, then substitute the forgery which will have a valid signature
forgery which will have a valid signature
Block Ciphers as Hash
Block Ciphers as Hash
Functions
Functions
can use block ciphers as hash functions
can use block ciphers as hash functions
using Husing H
0
0=0 and zero-pad of final block=0 and zero-pad of final block
compute: Hcompute: H
i
i = E = EMMii [H [Hi-1i-1]]
and use final block as the hash valueand use final block as the hash value
similar to CBC but without a keysimilar to CBC but without a key
resulting hash is too small (64-bit)
resulting hash is too small (64-bit)
both due to direct birthday attackboth due to direct birthday attack
and to “meet-in-the-middle” attackand to “meet-in-the-middle” attack
Hash Functions & MAC
Hash Functions & MAC
Security
Security
like block ciphers have:
like block ciphers have:
brute-force
brute-force
attacks exploiting
attacks exploiting
strong collision resistance hash have cost 2strong collision resistance hash have cost 2mm//22 • have proposal for h/w MD5 crackerhave proposal for h/w MD5 cracker
• 128-bit hash looks vulnerable, 160-bits better128-bit hash looks vulnerable, 160-bits better
MACs with known message-MAC pairsMACs with known message-MAC pairs
• can either attack keyspace (cf key search) or MACcan either attack keyspace (cf key search) or MAC
Hash Functions & MAC
Hash Functions & MAC
Security
Security
cryptanalytic attackscryptanalytic attacks exploit structure exploit structure
like block ciphers want brute-force attacks to be the like block ciphers want brute-force attacks to be the best alternative
best alternative
have a number of analytic attacks on iterated have a number of analytic attacks on iterated
hash functions hash functions
CVCV
i
i = f[CV = f[CVi-1i-1, M, Mii]; H(M)=CV]; H(M)=CVNN
typically focus on collisions in function ftypically focus on collisions in function f
Summary
Summary
have considered:
have considered:
message authentication usingmessage authentication using message encryptionmessage encryption
MACsMACs
hash functionshash functions