Module3 Week 09 10 11 12
Module3 Week 09 10 11 12
Cryptography and
Network Security
Week 9-11
MESSAGE INTEGRITY
Note
Checking integrity
Cryptographic Hash Function Criteria
Preimage
Example 11.1
Solution
We cannot. A lossless compression method creates a compressed
message that is reversible.
Example 11.2
Second preimage
Collision Resistance
Collision
RANDOM ORACLE MODEL
Assume an oracle with a table and a fair coin. The table has two
columns.
Assume that the messages in a hash function are 6 bits long and
the digests are only 4 bits long. Then the possible number of
digests (pigeonholes) is 24 = 16, and the possible number of
messages (pigeons) is 26 = 64. This means n = 16 and kn + 1 = 64,
so k is larger than 3. The conclusion is that at least one digest
corresponds to four (k + 1) messages.
Attacks on Random Oracle Model
Preimage Attack
Example 11.6
A cryptographic hash function uses a digest of 64 bits. How many
digests does Eve need to create to find the original message with
the probability more than 0.5?
Solution
The number of digests to be created is k ≈ 0.69 × 2n ≈ 0.69 × 264.
This is a large number. Even if Eve can create 230 (almost one
billion) messages per second, it takes 0.69 × 234 seconds or more
than 500 years. This means that a message digest of size 64 bits
is secure with respect to preimage attack, but, as we will see
shortly, is not secured to collision attack.
Second Preimage Attack.
Collision Attack
Example 11.7
A cryptographic hash function uses a digest of 64 bits. How many
digests does Eve need to create to find two messages with the
same digest with the probability more than 0.5?
Solution
The number of digests to be created is k ≈ 1.18 × 2n/2 ≈ 1.18 ×
232. If Eve can test 220 (almost one million) messages per second,
it takes 1.18 × 212 seconds, or less than two hours. This means
that a message digest of size 64 bits is not secure against the
collision attack.
Alternate Collision Attack
Summary of Attacks
Table 11.4 shows the level of difficulty for each attack if the digest is
n bits.
Example 11.8
MD5 which was one of the standard hash functions for a long
time, creates digests of 128 bits. To launch a collision attack, the
adversary needs to test 264 (2128/2) tests in the collision algorithm.
Even if the adversary can perform 230 (more than one billion) tests
in a second, it takes 234 seconds (more than 500 years) to launch
an attack. This type of attack is based on the Random Oracle
Model. It has been proved that MD5 can be attacked on less than
264 tests because of the structure of the algorithm.
Example 11.10
Details of HMAC
a) Message
encrypted
b) Message
unencrypted
Hash Functions & Message
Authentication
Symmetric Key
Keyed Hash
a) Message
unencrypted
d) Message
encrypted
Hash Functions & Digital
Signatures - PKCS
Other Hash Function Uses
➢ pseudorandom function (PRF)
⚫ Generate session keys, nonces
⚫ Produce key from password
⚫ Derive keys from master key cooperatively
➢ pseudorandom number generator
(PRNG)
⚫ Vernam Cipher/OTP
⚫ S/Key, proof of “what you have” via messages
More Hash Function Uses
➢ to create a one-way password file
⚫ store hash of password not actual password
⚫ e.g., Unix, Windows NT, etc.
⚫ salt to deter precomputation attacks
⚫ Rainbow tables
➢ for intrusion detection and virus detection
⚫ keep & check hash of files on system
⚫ e.g., Tripwire
Lamport One-time Passwords
➢ Password safety in distributed system
⚫ server compromise does not compromise P
⚫ interception of authentication exchange does
not compromise password either
➢ Alice picks Password PA
⚫ Hashes password N times, HN(PA)
⚫ Server stores (Alice, N, HN(PA))
⚫ Attacker can’t get PA from HN(PA)
Lamport One-time Passwords
➢ Protocol
⚫ Alice sends “I’m Alice”
⚫ Server sends “N-1”
⚫ Alice sends “X” where X=HN-1(PA)
⚫ Server verifies H(X) = HN(PA)
⚫ Server updates to (Alice, N-1, X)
➢ Attackerstill can’t get PA or
authenticate as Alice
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
Hash Function Requirements
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
m
⚫ opponent generates 2 /2 variations x’ of x, all with
essentially the same meaning, and saves them
m
⚫ opponent generates 2 /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
forgery which will have a valid signature
➢ conclusion is that need to use larger MAC/hash
Birthday Attacks
➢ What are chances we get a match?
➢ N distinct values, k randomly chosen ones
⚫ P(N,i) = prob(i randomly selected values from
1..N have at least one match)
⚫ P(N,2) = 1/N
⚫ P(N,i+1) = P(N,i)+(1-P(N,i))(i/N)
➢ ForP(N,k)>0.5, need k ≈ N1/2
➢ Need double # bits in hash value
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
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
Block Ciphers as Hash
Functions H
0
Block cipher key length B
Pad Message M to multiple of B M1 E
Break padded M into L blocks
L = |M|/B M2 E
M = M1 M2 … ML
Use blocks of M as keys in block
cipher, iteratively encrypt state value
starting with constant H0 resulting in ML E
hash value
H = HL = E(ML,….E(M2,E(M1,H0))…) HL
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
➢ 2005 results on security of SHA-1 raised
concerns on its use in future applications
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
SHA-512 Overview
SHA-512 Compression
Function
➢ heartof the algorithm
➢ processing message in 1024-bit blocks
➢ consists of 80 rounds
⚫ updating a 512-bit buffer
⚫ using a 64-bit value Wt derived from the
current message block
⚫ and a round constant based on cube root of
first 80 prime numbers
SHA-512 Round Function
Structure of each round in SHA-512
Majority Function
Conditional Function
Rotate Functions
Compression Function
There are 80 constants, K0 to K79, each of 64 bits. Similar These values are calculated
from the first 80 prime numbers (2, 3,…, 409). For example, the 80th prime is 409,
with the cubic root (409)1/3 = 7.42291412044. Converting this number to binary with
only 64 bits in the fraction part, we get
Solution
Each word in the range W16 to W79 is made from four
previously-made words. W60 is made as
Message Digest Initialization
Message digest creation SHA-512
12.89
Message Preparation
SHA-512 insists that the length of the original message
be less than 2128 bits.
Note
12.90
Example 12.1
Solution
A communications network that can send 264 bits per second is
not yet available. Even if it were, it would take many years to
send this message. This tells us that we do not need to worry
about the SHA-512 message length restriction.
Example 12.2
Solution
Suppose that a character is 32, or 26, bits. Each page is less than
2048, or approximately 212, characters. So 2128 bits need at least
2128 / 218, or 2110, pages. This again shows that we need not
worry about the message length restriction.
Padding and length field in SHA-512
Example 12.3
Solution
We can calculate the number of padding bits as follows:
Solution
Yes we do, because we need to add the length field. So padding is
needed to make the new block a multiple of 1024 bits.
Example 12.5
Solution
Whirlpool
Iterated Hash Function
Merkle-Damgard Scheme
Rabin Scheme
Davies-Meyer Scheme
Miyaguchi-Preneel Scheme
Secure Hash Algorithm (SHA-1)
106
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)
1. process message in 16-word (512-bit) chunks:
• expand 16 words into 80 words by mixing & shifting
• use 4 rounds of 20 bit operations on message block &
buffer
• add output to input to form new buffer value
2. output hash value is the final buffer value
107
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 nonlinear function for round
• Wt is derived from the message block
• Kt is a constant value derived from sin
108
SHA-1 Compression Function
109
MD5
110
MD5 Overview
1. pad message so its length is 448 mod 512
2. append a 64-bit length value to message
3. initialise 4-word (128-bit) MD buffer (A,B,C,D)
4. process message in 16-word (512-bit) blocks:
• using 4 rounds of 16 bit operations on message
block & buffer
• add output to buffer input to form new buffer value
5. output hash value is the final buffer value
111
MD5 Overview
112
MD5 Compression Function
• each round has 16 steps of the form:
a = b+((a+g(b,c,d)+X[k]+T[i])<<<s)
• a,b,c,d refer to the 4 words of the buffer, but
used in varying permutations
• note this updates 1 word only of the buffer
• after 16 steps each word is updated 4 times
• where g(b,c,d) is a different nonlinear function in
each round (F,G,H,I)
• T[i] is a constant value derived from sin
113
MD5 Compression Function
114
MD4
• precursor to MD5
• also produces a 128-bit hash of message
• has 3 rounds of 16 steps versus 4 in MD5
• design goals:
• collision resistant (hard to find collisions)
• direct security (no dependence on "hard" problems)
• fast, simple, compact
• favors little-endian systems (eg PCs)
115
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 looks vulnerable soon
116
SHA-1 verses MD5
• brute force attack is harder (160 vs 128 bits for MD5)
• SHA-1 is not vulnerable to any known attacks (compared to MD4/5)
• SHA-1 is a little slower than MD5 (80 vs 64 steps)
• both designed as simple and compact
• SHA-1 is optimised for big endian CPU's (vs MD5 which is optimised
for little endian CPU’s)
117
Revised Secure Hash Standard
• NIST has 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
118
WHIRLPOOL
Note
Note
A digital signature provides message authentication.
Message Integrity
Note
Note
Note
Key-Only Attack
Known-Message Attack
Chosen-Message Attack
Forgery Types
Note
In the RSA digital signature scheme, d is private;
e and n are public.
Signing and Verifying
As a trivial example, suppose that Alice chooses p = 823 and q = 953, and calculates n
= 784319. The value of (n) is 782544. Now she chooses e = 313 and calculates d =
160009. At this point key generation is complete. Now imagine that Alice wants to
send a message with the value of M = 19070 to Bob. She uses her private exponent,
160009, to sign the message:
Alice sends the message and the signature to Bob. Bob receives the message and
the signature. He calculates
Note
In ElGamal digital signature scheme, (e1, e2, p) is
Alice’s public key; d is her private key.
Verifying and Signing
ElGamal digital signature scheme
Example 13.2
Alice sends M, S1, and S2 to Bob. Bob uses the public key to calculate V1 and V2.
Example 13.3
Now imagine that Alice wants to send another message, M = 3000, to Ted. She
chooses a new r, 107. Alice sends M, S1, and S2 to Ted. Ted uses the public keys to
calculate V1 and V2.
Schnorr Digital Signature Scheme
Note
In the Schnorr digital signature scheme, Alice’s
public key is (e1, e2, p, q); her private key (d).
Signing and Verifying
Verifying Message
1. Bob calculates V = h (M | e1S2 e2−S1 mod p).
2. If S1 is congruent to V modulo p, the message is
accepted;
Example 13.4
Here is a trivial example. Suppose we choose q = 103 and p = 2267. Note that p = 22 ×
q + 1. We choose e0 = 2, which is a primitive in Z2267*. Then (p −1) / q = 22, so we have
e1 = 222 mod 2267 = 354. We choose d = 30, so e2 = 35430 mod 2267 = 1206. Alice’s
private key is now (d); her public key is (e1, e2, p, q).
Alice wants to send a message M. She chooses r = 11 and calculates e2 r = 35411 = 630
mod 2267. Assume that the message is 1000 and concatenation means 1000630. Also
assume that the hash of this value gives the digest h(1000630) = 200. This means S1 =
200. Alice calculates S2 = r + d × S1 mod q = 11 + 1026 × 200 mod 103 = 35. Alice
sends the message M =1000, S1 = 200, and S2 = 35. The verification is left as an
exercise.
Digital Signature Standard (DSS)
Key Generation.
1. Alice chooses primes p and q.
1. Alice uses <Zp*, × > and <Zq*, ×>.
1. Alice creates e1 to be the qth root of 1 modulo p.
1. Alice chooses d and calculates e2 = e1d.
1. Alice’s public key is (e1, e2, p, q); her private key is
(d).
Verifying and Signing
DSS scheme
Example 13.5
Alice chooses q = 101 and p = 8081. Alice selects e0 = 3 and calculates e1 = e0 (p−1)/q
mod p = 6968. Alice chooses d = 61 as the private key and calculates e2 = e1d mod p =
2038. Now Alice can send a message to Bob. Assume that h(M) = 5000 and Alice
chooses r = 61:
Alice sends M, S1, and S2 to Bob. Bob uses the public keys to calculate V.
DSS Versus RSA
Computation of DSS signatures is faster than
computation of RSA signatures when using the same p.
Blind Signatures
Sometimes we have a document that we want to get
signed without revealing the contents of the
document to the signer.
INTRODUCTION
Something known
Something possessed
Something inherent
PASSWORDS
• Fixed Password
• One-Time Password
Fixed Password
First Approach
User ID and password file
Second Approach
Hashing the password
Third Approach
Salting the password
14.195
Fourth Approach
In the fourth approach, two identification techniques are
combined. A good example of this type of authentication
is the use of an ATM card with a PIN (personal
identification number).
One-Time Password
First Approach
In the first approach, the user and the system agree upon a
list of passwords.
Second Approach
In the second approach, the user and the system agree to
sequentially update the password.
Third Approach
In the third approach, the user and the system create a
sequentially updated password using a hash function.
Lamport one-time password
CHALLENGE-RESPONSE
Note
The challenge is a time-varying value sent by the
verifier; the response is the result
of a function applied on the challenge.
Using a Symmetric-Key Cipher
First Approach
Nonce challenge
Second Approach
Timestamp challenge
Third Approach.
Bidirectional authentication
Using Keyed-Hash Functions
First Approach
First Approach
Digital signature, unidirectional
Second Approach
Digital signature, bidirectional authentication
ZERO-KNOWLEDGE
• Fiat-Shamir Protocol
• Feige-Fiat-Shamir Protocol
• Guillou-Quisquater Protocol
Fiat-Shamir Protocol
Feige-Fiat-Shamir Protocol
Guillou-Quisquater Protocol