CS 683 - Security and Privacy Fall 2019
Instructor: Karim Eldefrawy
University of San Francisco
http://www.cs.usfca.edu/~keldefrawy/teaching /fall2019/cs683/cs683_main.htm
1
CS 683 - Security and Privacy Fall 2019 Instructor: Karim Eldefrawy - - PowerPoint PPT Presentation
CS 683 - Security and Privacy Fall 2019 Instructor: Karim Eldefrawy University of San Francisco http://www.cs.usfca.edu/~keldefrawy/teaching /fall2019/cs683/cs683_main.htm 1 CBC Mode Cipher-Block Chaining (CBC) Mode Input to encryption
Instructor: Karim Eldefrawy
University of San Francisco
http://www.cs.usfca.edu/~keldefrawy/teaching /fall2019/cs683/cs683_main.htm
1
Cipher-Block Chaining (CBC) Mode
Ø Input to encryption algorithm is the XOR of current plaintext block and preceding ciphertext block:
Ci = E ( K, Pi XOR Ci-1 ) C0=IV Pi = D ( K, Ci ) XOR Ci-1
Ø Duplicate plaintext blocks (patterns) NOT exposed Ø Block rearrangement is detectable Ø No parallel encryption
v How about parallel decryption?
Ø Error in one ciphertext block è two-block loss Ø One-block ciphertext loss?
2
3
4
Why is it a bad idea to reuse both the key and IV in CBC mode of operation? (HINT: given two CBC ciphertexts produced by the same key and IV, what can an adversary learn about the corresponding plaintexts relative to each other?)
5
Why is it a bad idea to reuse both the key and IV in CBC mode of operation? (HINT: given two CBC ciphertexts produced by the same key and IV, what can an adversary learn about the corresponding plaintexts relative to each other?) In CBC mode encryption, if we use the same key and IV to encrypt a plaintext twice, it would obviously result in the same ciphertext for both encryptions. We will use this fact to answer this question. Suppose we have two plain-/cipher-text pairs, [P, C] and [P0, C0], where C and C0 are produced by CBC mode encryption with the same key and IV. By comparing C with C0, an adversary can tell whether P = P0. Specifically, if C = C0, an adversary learns for sure that P = P0. Otherwise, he also learns that P 6= P0. To be more precise, an adversary can tell if the first ith blocks of the corresponding plaintexts are equal to each other or not, using the same argument.
6
important tools in modern cryptography and security
integrity applications
communications
7
8
long input data
1. Takes on input of any size 2. Produces fixed-length output 3. Easy to compute (efficient) 4. Given any h, computationally infeasible to find any x such that H(x) = h 5. For a given x, computationally infeasible to find y such that H(y) = H(x) and y≠x 6. Computationally infeasible to find any (x, y) such that H(x) = H(y) and x ≠ y
9
HASH function
10
f() that works on fixed-size input blocks (Mi)
and (2) hash value for the previous block
unpredictable changes in output
f IV M1 f f h1 h M2 Mn h2 hn-1 …
11
always zero
append one block that would set the hash code as needed
header's 16-bit words
12
13
So, what’s the point?
the range of H()
Y?
14
15
a collision (with ≥ 0.5 probability)
(doable in very little time)
trials
16
SHA-1 (weak) MD5 (defunct) RIPEMD-160 (unloved) J Digest length 160 bits 128 bits 160 bits Block size 512 bits 512 bits 512 bits # of steps 80 (4 rounds of 20) 64 (4 rounds of 16) 160 (5 paired rounds
Max msg size 264-1 bits
Other (stronger) variants of SHA are SHA-256 and SHA-512 See: http://en.wikipedia.org/wiki/SHA_hash_functions
17
18
Input Message
Output: 128-bit Digest
19
20
resulting length is 64 bits less than a multiple of 512 bits.
21
Input Message Output: 128-bit Digest Padding 512 bit Block Initial Value 1 2 3 4 Final Output MD5 Transformation Block by Block
22
MD5 MD5 MD5 MD5 512: B1 512:B2 512: B3 512: B4 Result
23
Initial 128-bit vector 512-bit message chunks (16 32-bit words) 128-bit result F(x,y,z) = (x Ù y) Ú (~x Ù z) G(x,y,z) = (x Ù z) Ú (y Ù~ z) H(x,y,z) = x Å y Å z I(x,y,z) = y Å (x Ù ~z) x¿y: x left rotate y bits
24
final padded message
m0|m1|m2 …|m15
A=01234567,B=89abcdef,C=fedcba98, D=76543210
modifying MD; each pass involves different operation
25
ABCD=fF(ABCD,mi,T[1..16]) ABCD=fG(ABCD,mi,T[17..32]) ABCD=fH(ABCD,mi,T[33..48]) ABCD=fI(ABCD,mi,T[49..64]) mi + + + + A B C D MDi MD i+1
Convention: A – d0 ; B – d1 C – d2 ; D – d3 Ti :diff. constant
26
27
28
padding attack
linear function
Ø SHA-0 was published by NIST in 1993
29
30
31
sequentially
stronger
32
Step1: Padding Step2: Appending length as 64-bit unsigned Step3: Initialize MD buffer: 5 32-bit words: A|B|C|D|E
A = 67452301 B = efcdab89 C = 98badcfe D = 10325476 E = c3d2e1f0
33
blocks: 4 rounds, 20 steps each
34
Kt = 6ED9EBA1
Kt = 8F1BBCDC
Kt = CA62C1D6
35
A E B C D A E B C D + + + + ft CLS30 CLS5 Wt Kt
36
Only 3 different functions
Round Function ft(B,C,D) 0 <=t<= 19 (BÙC)Ú(~B ÙD) 20<=t<=39 BÅCÅD 40<=t<=59 (BÙC)Ú(BÙD)Ú(CÙD) 60<=t<=79 BÅCÅD
37
512-bit block
multilevel shifting, it produces very extensive and random mixing!
38
(vs. 128) - involves more computation
39
40
Use symmetric encryption such as AES or 3-DES
H(DK(C)) =?= H(M’)
Collision è MAC forgery!
41
Alice and Bob share a secret key KAB
Only need to compare H() results
42
that H(m)=H(m’)?
43
function
MAC
encryption algorithms such as DES
in SET
44
concatenation of M and K1
block” attack, compute again H2= H() of the concatenation
bits of K
45