L18hash Function
L18hash Function
(CSE348)
1
Lecture # 18
2
Review
have considered:
Diffie-Hellman key exchange
ElGamal cryptography
on Asymmetric Ciphers
3
Chapter 11 – Cryptographic Hash
Functions
4
Each of the messages, like each one he had ever read of
Stern's commands, began with a number and ended
with a number or row of numbers. No efforts on the
part of Mungo or any of his experts had been able to
break Stern's code, nor was there any clue as to what
the preliminary number and those ultimate numbers
signified.
—Talking to Strange Men, Ruth Rendell
5
Hash Functions
• A hash function H accepts a variable-length block of
data M as input
6
Hash Functions
• In general terms, the principal object of a hash function
is data integrity
7
Hash Functions
• A cryptographic hash function is an algorithm for which
it is computationally infeasible
– because no attack is significantly more efficient than brute
force
8
Hash Functions
• Because of these characteristics, hash functions are
often used to determine whether or not data has
changed
9
Hash Functions
• Condenses arbitrary message to fixed size
h = H(M)
• Usually assume hash function is public
• Hash used to detect changes to message
• Want a cryptographic hash function
– computationally infeasible to find data mapping to
specific hash (one-way property)
– computationally infeasible to find two data to same
hash (collision-free property)
10
Cryptographic Hash Function
11
Cryptographic Hash Function
Stallings Figure 11.1 depicts the general operation
of a cryptographic hash function
12
Cryptographic Hash Function
The length field is a security measure to increase
the difficulty for an attacker
13
Hash
Functions &
Message
Authent-
ication
14
Hash Functions & Message
Authentication
Message authentication is a mechanism or service
used to verify the integrity of a message
15
Hash Functions & Message
Authentication
a. The message plus concatenated hash code is
encrypted using symmetric encryption
16
Hash Functions & Message
Authentication
b. Only the hash code is encrypted
17
Hash Functions & Message
Authentication
c. Shows the use of a hash function but no
encryption for message authentication
19
Hash Functions & Message
Authentication
d. Confidentiality can be added
22
Hash Functions & Digital Signatures
Anyone who knows the user's public key can verify
the integrity of the message
that is associated with the digital signature
23
Hash Functions & Digital Signatures
Stallings Figure 11.3 illustrates, in a simplified
fashion
24
Hash Functions & Digital Signatures
a. The hash code is encrypted, using public-key
encryption and using the sender's private key
Figure 11.2 Simplified Examples of the Use of a Hash Function for Message Authentication
26
Hash Functions & Digital Signatures
b. If confidentiality as well as a digital signature is
desired
27
Other Hash Function Uses
Hash functions are commonly used to create a one-
way password file
28
Other Hash Function Uses
In simple terms, when a user enters a password, the
hash of that password is compared to the stored
hash value for verification
29
Other Hash Function Uses
Store H(F) for each file on a system and secure the
hash values (e.g., on a CD-R that is kept secure)
30
Other Hash Function Uses
A cryptographic hash function can be used to
construct a pseudorandom function (PRF)
31
Other Hash Function Uses
• To create a one-way password file
– store hash of password not actual password
32
Two Simple Insecure Hash Functions
• Consider two simple insecure hash functions
• bit-by-bit exclusive-OR (XOR) of every block
– Ci = bi1 xor bi2 xor . . . xor bim
– a longitudinal redundancy check
– reasonably effective as data integrity check
• one-bit circular shift on hash value
– for each successive n-bit block
• rotate current hash value to left by1bit and XOR block
– good for data integrity but useless for security
33
Hash Function Requirements
34
Attacks on Hash Functions
• Have brute-force attacks and cryptanalysis
• A preimage or second preimage attack
– find y s.t. H(y) equals a given hash value
• Collision resistance
– find two messages x & y with same hash so
H(x) = H(y)
• Hence value 2m/2 determines strength of hash code
against brute-force attacks
– 128-bits inadequate, 160-bits suspect
35
Birthday Attacks
• Might think a 64-bit hash is secure
• But by Birthday Paradox is not
• Birthday attack works thus:
– given user prepared to sign a valid message x
– opponent generates 2m/2 variations x’ of x, all with
essentially the same meaning, and saves them
– opponent generates 2m/2 variations y’ of a desired
fraudulent message y
– 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 fake
which will have a valid signature
• Conclusion is that need to use larger MAC/hash
36
Hash Function Cryptanalysis
• As with encryption algorithms, cryptanalytic attacks
on hash functions seek to exploit some property of
the algorithm
37
Hash Function Cryptanalysis
• Must consider the overall structure of a typical
secure hash function
38
Hash Function Cryptanalysis
• If necessary, the final block is padded to b bits
42
Hash Function Cryptanalysis
• The attack on f depends on exploiting its internal
structure
43
Hash Function Cryptanalysis
• Cryptanalytic attacks exploit some property of algo
so faster than exhaustive search
• Hash functions use iterative structure
– process message in blocks (incl length)
• Attacks focus on collisions in function f
44
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 a key
• 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
45
Secure Hash Algorithm
• In recent years, the most widely used hash function
has been the Secure Hash Algorithm (SHA)
46
Secure Hash Algorithm
• A revised version was issued as FIPS 180-1 in 1995
and is generally referred to as SHA-1
47
Secure Hash Algorithm
• In 2005, a research team described an attack in which
two separate messages could be found
48
Secure Hash Algorithm
• SHA originally designed by NIST & NSA in 1993
• was 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
• Based on design of MD4 with key differences
• Produces 160-bit hash values
• Recent 2005 results on security of SHA-1 have raised
concerns on its use in future applications
49
Revised Secure Hash Standard
• NIST issued revision FIPS 180-2 in 2002
• Adds 3 additional versions of SHA
– 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
• But security levels are rather higher
50
SHA Versions
51
SHA-512 Compression Function
• Heart of the algorithm
• Processing message in 1024-bit blocks
• Consists of 80 rounds
– updating a 512-bit buffer
– using a 64-bit value derived from the current
message block
– and a round constant based on cube root of first
80 prime numbers
52
SHA-3
• As yet, SHA-1 has not yet been "broken“
54
SHA-3
• NIST decided to begin the process of developing a
new hash standard
56
SHA-3 Requirements
• The basic requirements that must be satisfied by any
candidate for SHA-3 are:
57
SHA-3 Requirements
2. SHA-3 must preserve the online nature of SHA-2
58
SHA-3 Requirements
• Beyond these basic requirements, NIST has defined a
set of evaluation criteria
59
SHA-3 Requirements
• Security: The strength of SHA-3 should be close to the
theoretical maximum for the different required hash
sizes
60
SHA-3 Requirements
• Cost: be both time and memory efficient over a range
of hardware platforms
62
Summary
• have considered:
– hash functions
• uses, requirements, security
– hash functions based on block ciphers
– SHA-1, SHA-2, SHA-3
63