CS CS 683 683 - Security y and Privacy Fa Fall 2019
In Instructor
- r: Ka
Karim El Elde defrawy
Un University ty of
- f Sa
San Francisco
http://www.cs.usfca.edu/~keldefrawy/teaching/f all2019/cs683/cs683_main.htm
1
CS CS 683 683 - Security y and Privacy Fa Fall 2019 In - - PowerPoint PPT Presentation
CS CS 683 683 - Security y and Privacy Fa Fall 2019 In Instructor or: Ka Karim El Elde defrawy Un University ty of of Sa San Francisco http://www.cs.usfca.edu/~keldefrawy/teaching/f all2019/cs683/cs683_main.htm 1 Lectures 3 and 4
Un University ty of
San Francisco
http://www.cs.usfca.edu/~keldefrawy/teaching/f all2019/cs683/cs683_main.htm
1
2
3
The word cryptography comes from the Greek words κρυπτός (hidden or secret) and γράφειν (writing). So historically cryptography has been the “art of secret writing.” Most
cryptography is currently well grounded in mathematics and it can be debated whether there’s still an “art” aspect to it.
Cr Cryptography
3
Hi Histor
(Primiti tive) ) Ciphers
k (x) = x+k mod 26
k1,k2 (x) = k1 *x + k2 mod 26
perm (x) = perm(x)
K (x) = ( X[0]+K[0], X[1]+K[1], … )
4
Som Some Hi Histor
5
Sh Shift t (Caesar) Cipher
Example:
W E W I L L M E E T A T M I D N I G H T 22 4 22 8 11 11 12 4 4 19 19 12 8 3 13 8 6 7 19 7 15 7 19 22 22 23 15 15 4 11 4 23 19 14 24 19 17 18 4 H P H T W W X P P E L E X T O Y T R S E
K = 11
6
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.082 0.015 0.028 0.043 0.127 0.022 0.02 0.061 0.07 0.002 0.008 0.04 0.024 0.067 0.075 0.019 0.001 0.06 0.063 0.091 0.028 0.01 0.023 0.001 0.02 0.001
Pr Probability of Occurrence of Lette ters in English
7
8
– Plaintext – Secret Key – Ciphertext – Encryption Algorithm – Decryption Algorithm
9
10
Key Size (bits) Number of Alternative Keys Time required at 106 Decryption/µs 32 232 = 4.3 x 109 2.15 milliseconds 56 256 = 7.2 x 1016 10 hours 128 2128 = 3.4 x 1038 5.4 x 1018 years 168 2168 = 3.7 x 1050 5.9 x 1030 years
11
is evident free of any (computational/hardness) assumptions
some common (often unproven) assumptions, e.g., the conjectured difficulty of factoring large integers
Take a look at:
http://www.ciphersbyritter.com/GLOSSARY.HTM
12
– Cost of breaking it (via brute force) exceeds the value of the encrypted information; or – Time required to break it exceeds useful lifetime of the encrypted information
secure
– Usually rely on very large key-space, impregnable to brute force
algorithms for certain hard problems, not on a proven inexistence
– Such as: factoring, discrete logarithms, etc.
13
WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
PELCGBTENCUL VF ABG NF RNFL NF VG ZNL FRRZ
15
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.082 0.015 0.028 0.043 0.127 0.022 0.02 0.061 0.07 0.002 0.008 0.04 0.024 0.067 0.075 0.019 0.001 0.06 0.063 0.091 0.028 0.01 0.023 0.001 0.02 0.001
Pr Probability of Occurrence of Lette ters in English
14
WKH TXLFN EURZQ IRA MXPSV RYHU WKH ODCB GRJ
THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
PELCGBTENCUL VF ABG NF RNFL NF VG ZNL FRRZ
CRYPTOGRAPHY IS NOT AS EASY AS IT MAY SEEM
16
17
18
Classified along three dimensions:
ciphertext
upon (how?)
plaintext ciphertext
K AB
encryption algorithm decryption algorithm
K AB
plaintext m K (m)
AB
K (m)
AB
m = K (
)
AB
19
without revealing it:
secret key cryptography
20
21
K AB
challenge
K AB
challenge reply
challenge challenge reply
22
Ø Advantages
l high data throughput l relatively short key size l primitives to construct various cryptographic
mechanisms
Ø Disadvantages
l key must remain secret at both ends l key must be distributed securely and efficiently l relatively short key lifetime
“encrypt” message digest/hash -- h(m) -- with private key
23
24
25
plaintext message, m ciphertext encryption algorithm decryption algorithm
Bob’s public key
plaintext message PK (m)
B
PK
B
Bob’s private key
SK
B
m = SK (PK (m))
B B
SKb.
decrypt with own private key
person one communicates with
repudiation)
26
27
Ø Advantages
l only the private key must be kept secret l relatively long life time of the key l more security services l relatively efficient digital signatures mechanisms
Ø Disadvantages
l low data throughput l much larger key sizes l distribution/revocation of public keys l security based on conjectured hardness of certain
computational problems
28
Ø Public Key
l Encryption, signatures (esp., non-repudiation) and key
management
Ø Conventional
l Encryption and some data integrity applications
Ø Key Sizes
l Keys in public key crypto must be larger (e.g., 2048 bits for RSA)
than those in conventional crypto (e.g., 112 bits for 3-DES or 256
bits for AES)
search (brute force)
factoring large numbers in RSA)
30
including DES, have a structure first described by Horst Feistel of IBM in 1973
choice of the following parameters and features:
31
security
lead to greater difficulty of cryptanalysis
the algorithm becomes a concern
32
33
“Round Keys” are generated from
subkey generation algorithm
34
banking security systems
bit key and block size
to be reversible
greater the security (to a point)
35
36
37
38
64 Bit Plaintext Initial Permutation 32 Bit L0 32 Bit R0 F(R0,K1) + 32 Bit L1 32 Bit R1 32 Bit L15 32 Bit R15 F(R15,K16) + 32 Bit L16 32 Bit R16 Final Permutation 64 Bit Ciphertext
Encryption Process
64 Bit Key Permutation Choice 1 56 Bit Key 28 Bit C0 28 Bit D0 Left Shift Right Shift C1 D1 Building Blocks Permuted Choice 2 K1(48 bits) C16 D16 Permuted Choice 2
Key Schedule
K16(48 bits)
39
Li-1 32 bits Ri-1 32 bits
S-Box Substitution choses 32 bits
P-box Permutation Li 32 bits Ri 32 bits 56 bits Key Permuted Choice 48 bits
Expansion (E) Permutation 48 bits
40
41
41
42
42
43 43
44 44
DES Key size = 56 bits
8 * ~5-bit chars = 40 bits
45
Differential Cryptanalysis
Linear Cryptanalysis
Related-key Cryptanalysis
input/output Differential cryptanalysis discovered in 1990; virtually all block ciphers from before that time are vulnerable... ... except DES. IBM (and the NSA) knew about it 15 years earlier
46
ENCRYPTION
http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
47
Electronic Code-Book (ECB) Mode
Ci = E ( K, Pi ) Pi = D ( K, Ci )
48
Cipher-Block Chaining (CBC) Mode
preceding ciphertext block:
Ci = E ( K, Pi XOR Ci-1 ) C0=IV Pi = D ( K, Ci ) XOR Ci-1
49
50
Output Feedback (OFB) Mode
Ci = E ( K, Vi-1 ) XOR Pi V0=IV Pi = E ( K, Vi-1 ) XOR Ci
51
Cipher Feedback (CFB) Mode
Ci = Pi XOR E (K, Ci-1) C0=IV Pi = E ( K, Ci-1 ) XOR Ci
52
Counter (CTR) Mode
Ci = E ( K, CTRi ) XOR Pi CTRi = CTRi-1 + 1 Pi = E ( K, CTRi ) XOR Ci
53
Message Authentication Code (MAC) Mode
Ci = E ( K, Pi XOR Ci-1 ) C0=IV What is sent or stored: P1, . . ., Pn, Cn = MAC Receiver recomputes Cn with K and compares
54
Meet-in-the-middle (or Rendesvouz) ATTACK:
I. For each possible K’i (where 0 < i < 256) 1. Compute C’i= DES ( K’i , P ) 2. Store: [ K’i, C’i ] in table T (sorted by C’i) II. For each possible K”i (where 0 < i < 256) 1. Compute C”i = DES-1 ( K”i , C ) 2. Lookup C”i in T ç not expensive! 3. If lookup succeeds, output: K1=K’i, K2=K”i TOTAL COST: O(256) operations + O(256) storage
55
NOTE: The same variants can be constructed out of any cipher
56
Why does 3-DES (or generally n-DES) work? Because, as a function, DES is not a group…
A “group” is an algebraic structure. One of its properties is that, taking any 2 elements of the group (a,b) and applying an operator F() yields another element c in the group. Suppose: C = DES(K1,DES(K2,P)) There is no K, such that: for each possible plaintext P, DES(K,P) = C
57
58
Skipjack
sponsored Clipper chip
GOST
59
60
61
x=y=0; while( length-- ) { /* state[0-255] contains key bytes */ sx = state[ ++x & 0xFF ]; y += sx & 0xFF; sy = state[ y ]; state[ y ] = sx; state[ x ] = sy; *data++ ^= state[ ( sx+sy ) & 0xFF ]; } Takes about a minute to implement from memory
62
63
64
65
standardization in the US
strong commercial-grade encryption
selecting a new encryption algorithm suitable for encrypting (non-classified non-military) government documents
66
RC4/RC5 algorithm and “R” in RSA
67
The Winner: Rijndael
Katholieke Universiteit Leuven).
combinations of key-block length possible.
implementations
68
P
r1
Key
r2 Rn-1 rn r3
C
Rn-2 k1 k2 Kn-1 kn k3 Kn-2
K KE Key Expansion Round Keys Encryption Rounds r1 … rn
state) of round i from round i+1 without the round key.
69
Detailed view of round n
key
ByteSub ShiftRow MixColumn AddRoundKey
Kn
Result from round n-1 Pass to round n+1 70
cryptographic attacks: Rijndael provides “full diffusion” after
round keys in common
71
Each byte at the input of a round undergoes a non-linear byte substitution according to the following transform: Substitution (“S”)-box
72
Depending on the block length, each “row” of the block is cyclically shifted according to the above table
73
Each column is multiplied by a fixed polynomial C(x) = ’03’*X3 + ’01’*X2 + ’01’*X + ’02’ This corresponds to matrix multiplication b(x) = c(x) Ä a(x):
Not XOR
74
Each word is simply XOR’ed with the expanded round key
KeyExpansion(int* Key[4*Nk], int* EKey[Nb*(Nr+1)]) { for(i = 0; i < Nk; i++) EKey[i] = (Key[4*i],Key[4*i+1],Key[4*i+2],Key[4*i+3]); for(i = Nk; i < Nb * (Nr + 1); i++) { temp = EKey[i - 1]; if (i % Nk == 0) temp = SubByte(RotByte(temp)) ^ Rcon[i / Nk]; EKey[i] = EKey[i - Nk] ^ temp; } }
Key Expansion algorithm:
75
(important for “Smart Cards”)
in ROM (e.g., < 256 bytes).
rotates
machines with 32-bit or higher word lengths
state, all four component transforms act on individual parts of the block
parallelism, it only needs to be performed once until the two parties switch keys.
76
performance is required (e.g., server and VPN applications).
implemented efficiently in hardware when absolute speed is required
straightforward inverse and the operations simply need to be undone in the reverse order.
encrypts a block can also decrypt the same block simply by changing certain tables and polynomials for each layer. The rest of the operation remains identical.
77
secure algorithm
and sw; requires no special instructions to obtain good performance on any computing platform
is expected to be common for the foreseeable future.
78
79
For each character:
0 1 1 1 0 0 1 0 1 1 0
(key)
1 0 1 1 0 1 0 1 1 0 0
ciphertext
(encrypted msg)
1 1 0 0 0 1 1 1 0 1 0
(plaintext)
80
so sending the pad is just as hard as sending the msg
81