Introduction To Computer Security Part 2
Introduction To Computer Security Part 2
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 1
AUP - CS 335
Chapter 11 – Message
Authentication and Hash
Functions
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 2
AUP - CS 335
Message Authentication
• message authentication is concerned with:
– protecting the integrity of a message
– validating identity of originator
– non-repudiation of origin (dispute resolution)
• will consider the security requirements
• then three alternative functions used:
– message encryption
– message authentication code (MAC)
– hash function
AUP - CS 335
Security Requirements
• disclosure
• traffic analysis
• masquerade
• content modification
• sequence modification
• timing modification
• source repudiation
• destination repudiation
AUP - CS 335
Message Encryption
• message encryption by itself also provides a measure
of authentication
• if symmetric encryption is used then:
– receiver know sender must have created it
– since only sender and receiver know key used
– know content cannot have been altered
– if message has suitable structure, redundancy or a checksum
to detect any changes
AUP - CS 335
Message Encryption with public key
• Case 1 : authentication only
– sender A signs message using its private-key
C= EKRA[M]
– Only A is able to create this message.
– Everyone is able to read it using A public key
M = EKUA[C]
– encryption provides no confidentiality since anyone potentially knows public-
key
M0 M1 Mi-1
f f f
IV= CV0 CV1 CVi-1 H = CVi
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 19
AUP - CS 335
Block Ciphers as Hash Functions
• can use block ciphers as hash functions
– using H0=0 and zero-pad of final block
– compute: Hi = EMi [Hi-1]
– and use final block as the hash value
– similar to CBC but without keys
• resulting hash is too small (64-bit)
– both due to direct birthday attack
– and to “meet-in-the-middle” attack
• other variants also susceptible to attack
AUP - CS 335
How Hash Codes are Attacked
• Birthday Attacks
• might think a (m=64) 64-bit hash is secure
• but by Birthday Paradox is not
– birthday attack works as follows:
• opponent generates 2m/2 variations of a valid message all with
essentially the same meaning
• opponent also generates 2m/2 variations of a desired fraudulent
message
• two sets of messages are compared to find pair with same hash
(probability > 0.5 by birthday paradox)
• have user sign the valid message, then substitute the forgery
which will have a valid signature
• conclusion is that need to use larger hash fields
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 21
AUP - CS 335
Hash Functions & MAC Security
• like block ciphers have:
• brute-force attacks exploiting
m/
– strong collision resistance hash have cost 2 2
M0 M1 Mi-1
f f f
IV= CV0 CV1 CVi-1 CVi
AUP - CS 335
Summary
• have considered:
– message authentication using message encryption
– MACs
– hash functions
– general approach & security
AUP - CS 335
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 25
AUP - CS 335
MD5
• designed by Ronald Rivest (the R in RSA)
• latest in a series of MD2, MD4
• produces a 128-bit hash value
• until recently was the most widely used hash algorithm
– in recent times have both brute-force & cryptanalytic concerns
• specified as Internet standard RFC1321
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 29
AUP - CS 335
MD5 Compression Function
AUP - CS 335
Other Details
• In each round, we have 16 steps
– In step 1 : g(b,c,d) = (b AND c) OR (NOT b AND d)
– In step 2 : g(b,c,d) = (b AND d) OR (c AND NOT d)
– In step 3 : g(b,c,d) = b + c + d
– In step 4 : g(b,c,d) = c + (b OR NOT d)
• X[k] is the input from the message (16 elements of 32 bits = 512 bits)
• CVi (128 bits) is structured into 4 words A, B, C, D
• T[i] = integer part (232 abs(sin(i)). i is ranging from 1 to 64
AUP - CS 335
Strength of MD5
• MD5 hash is dependent on all message bits
• Rivest claims security is good as can be
• known attacks are:
– Berson 92 attacked any 1 round using differential
cryptanalysis (but can’t extend)
– Boer & Bosselaers 93 found a pseudo collision
(again unable to extend)
– Dobbertin 96 created collisions on MD compression
function (but initial constants prevent exploit)
• conclusion is that MD5 is no longer usable
AUP - CS 335
Secure Hash Algorithm (SHA-1)
• SHA was designed by NIST & NSA in 1993
– 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
160 bits
digest
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 34
AUP - CS 335
SHA Overview
1. pad message so its length is 448 mod 512
2. append a 64-bit length value to message
3. initialise 5-word (160-bit) buffer (A,B,C,D,E) to
(67452301,efcdab89,98badcfe,10325476,c3d2e1f0)
4. process message in 16-word (512-bit) chunks:
– expand 16 words (Yq) into 80 words (Wt) by mixing &
shifting
– use 4 rounds of 20 bit operations on message block &
buffer
– add output to input to form new buffer value
5. output hash value is the final buffer value
AUP - CS 335
SHA-1 Compression Function
• each round has 20 steps which replaces the 5 buffer words thus:
(A,B,C,D,E) <-
(E+f(t,B,C,D)+(A<<5)+Wt+Kt),A,(B<<30),C,D)
• A, B, C, D, E refer to the 5 words of the buffer
• t is the step number
• f(t,B,C,D) is a nonlinear function for each round
• Wt is derived from the message block
• Kt is a constant value derived from square root calculation
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 36
AUP - CS 335
SHA-1 Compression Function
AUP - CS 335
Details
• In each round, we have 80 steps
– 0 to 19 : f(t,b,c,d) = (b and c) or (not b and d)
– 20 to 39 : f(t,b,c,d) = b + c + d
– 40 to 59 : f(t,b,c,d) = (b and d) or (b and d) or (c and d)
– 60 to 79 : f(t,b,c,d) = b + c + d
• Wt is a sequence of 80 words derived from Yq, the input
sequence of 16 words
– Wt = Yt from 0 to 15
– Wt=S1(Wi-16 xor Wi-14 xor Wi-8 xor Wi-3) when t >15
• CVi (160 bits) is structured into 4 words A, B, C, D, E
• Kt =
– 0 to 19 : integer part (230+square root (2))
– 20 to 39 : integer part (230+square root (3))
– 40 to 59 : integer part (230+square root (5))
– 60 to 79 : integer part (230+square root (10))
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 38
AUP - CS 335
SHA-1 versus MD5
• brute force attack is harder (160 vs 128 bits for MD5)
• vulnerable to known attacks
• a little slower than MD5 (80 vs 64 steps)
• both designed as simple and compact
• optimised for big endian CPU's (vs MD5 which is optimised for
little endian CPU’s)
AUP - CS 335
Revised Secure Hash Standard
• NIST have issued a revision FIPS 180-2
• adds 3 additional hash algorithms
• 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
AUP - CS 335
Keyed Hash Functions as MACs
• have desire to create a MAC using a hash function rather than a block
cipher
– because hash functions are generally faster
– not limited by export controls unlike block ciphers
• hash includes a key along with the message
• original proposal:
– KeyedHash = Hash(Key|Message)
– some weaknesses were found with this
• eventually led to development of HMAC
AUP - CS 335
HMAC
• specified as Internet standard RFC2104
• uses hash function on the message:
HMACK = Hash[(K+ XOR opad) ||
Hash[(K+ XOR ipad)||M)]]
• K+ : key padded out to size
• opad, ipad : padding constants
• overhead is just 3 more hash calculations
than the message needs alone
• any hash function can be used MD5, SHA-1,...
AUP - CS 335
HMAC Overview
AUP - CS 335
HMAC Security
• know that the 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 versus security
constraints
AUP - CS 335
Summary
• have considered:
– some current hash algorithms: MD5, SHA-1
– HMAC authentication using hash function
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 47
AUP - CS 335
Digital Signatures
• have looked at message authentication
– but does not address issues of lack of trust
• digital signatures provide the ability to:
– verify author, date & time of signature
– authenticate message contents
– be verified by third parties to resolve disputes
• hence include authentication function with additional
capabilities
AUP - CS 335
Digital Signature Properties
• must depend on the message signed
• must use information unique to sender
– to prevent both forgery and denial
• must be relatively easy to produce
• must be relatively easy to recognize & verify
• be computationally infeasible to forge
– with new message for existing digital signature
– with fraudulent digital signature for given message
• be practical save digital signature in storage
AUP - CS 335
Direct Digital Signatures
• involve only sender & receiver
• assumed receiver has sender’s public-key
• digital signature made by sender signing entire message or
hash with private-key
• can encrypt using receivers public-key
• important that sign first then encrypt message & signature
• security depends on sender’s private-key
AUP - CS 335
Arbitrated Digital Signatures
• involves use of arbiter A
– validates any signed message
– then dated and sent to recipient
• requires suitable level of trust in arbiter
• can be implemented with either symmetric or assymetric
algorithms
• arbiter may or may not see message
AUP - CS 335
Arbitrated Digital Signature Techniques
• X sends a digitally signed message to Y using A as an Arbiter
• Case 1 :
– Symmetric Encryption
– A sees message
– T is a timestamp
• Protection against replay attacks
– IDx identifies X
X → A: M || S where S = EKXA [IDx || H(M)]
A → Y: EKAY[IDX || M || S || T]
American University in Paris Spring 2009 Note that slides are from Larry Brown slide 59
AUP - CS 335
Needham-Schroeder Protocol
• used to securely distribute a new session key for
communications between A & B
• but is vulnerable to a replay attack if an old session key has
been compromised
– then message 3 can be resent convincing B that is communicating
with A
• modifications to address this require:
– timestamps (Denning 81)
– using an extra nonce (Neuman 93)
AUP - CS 335
Using Public-Key Encryption
• have a range of approaches based on the use of public-key
encryption
• need to ensure have correct public keys for other parties
• using a central Authentication Server (AS)
• various protocols exist using timestamps or nonces
AUP - CS 335
Denning AS Protocol
• Denning 81 presented the following:
1. A→AS: IDA || IDB