lec4
lec4
Srimanta Bhattacharya
Table of contents
1
Encryption Scheme: Types
Encryption schemes
Encryption Scheme: Types
Encryption schemes
Symmetric / Private-key
Encryption Scheme: Types
Encryption schemes
Encryption schemes
Block ciphers
Encryption Scheme: Types
Encryption schemes
Encryption schemes
Encryption schemes
Encryption schemes
Encryption schemes
Encryption schemes
2
The Setting
Insecure channel
Encryption Decryption
Plaintext(M) E(K, .) Ciphertext Ciphertext D(K, .)
(C) (C) Plaintext(M)
Sender Receiver
tux@linux#
Adversary
3
The Setting
Insecure channel
Encryption Decryption
Plaintext(M) E(K, .) Ciphertext Ciphertext D(K, .)
(C) (C) Plaintext(M)
Sender Receiver
tux@linux#
Adversary
3
The Setting
Insecure channel
Encryption Decryption
Plaintext(M) E(K, .) Ciphertext Ciphertext D(K, .)
(C) (C) Plaintext(M)
Sender Receiver
tux@linux#
Adversary
Encryption scheme
Encryption Scheme(contd..)
Encryption scheme
Gen
Encryption Scheme(contd..)
Enc, Dec
Encryption scheme
Gen
Encryption Scheme(contd..)
Enc, Dec
Cipher
Encryption scheme
Gen
4
Block cipher and Stream cipher
Block Cipher:
5
Block cipher and Stream cipher
Block Cipher:
5
Block cipher and Stream cipher
Block Cipher:
{
{
K IV
k1 k r iv1 ivs
Block Cipher:
z2
z1
m2 m1 c2 c1
zi = E(K, IV)
i
Takes n-bit message M = m1 . . . mn ci = m i zi
{
{
K IV
k1 k r iv1 ivs
Block Cipher:
z2
z1
m2 m1 c2 c1
zi = E(K, IV)
i
Takes n-bit message M = m1 . . . mn ci = m i zi
{
{
K IV
k1 k r iv1 ivs
Block Cipher:
z2
z1
m2 m1 c2 c1
zi = E(K, IV)
i
Takes n-bit message M = m1 . . . mn ci = m i zi
{
{
K IV
k1 k r iv1 ivs
Block Cipher:
z2
z1
m2 m1 c2 c1
zi = E(K, IV)
i
Takes n-bit message M = m1 . . . mn ci = m i zi
{
{
K IV
k1 k r iv1 ivs
Block Cipher:
z2
z1
m2 m1 c2 c1
zi = E(K, IV)
i
Takes n-bit message M = m1 . . . mn ci = m i zi
6
Few Remarks
6
Block Cipher: Real-world Example
7
Block Cipher: Real-world Example
An Example: OpenSSL
• A free, open source, robust, commercial-grade crypto library
implementing various cryptographic algorithms including block
ciphers.
• Available for Windows and Linux.
7
Block Ciphers in OpenSSL
8
Block cipher
Theoretical view
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | =
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | = 2n !.
• Need log(2n !) ≈ n2n bit key to index Pn .
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | = 2n !.
• Need log(2n !) ≈ n2n bit key to index Pn .
• For n = 64, need ≈ 270 bit key ⇒ impractical.
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | = 2n !.
• Need log(2n !) ≈ n2n bit key to index Pn .
• For n = 64, need ≈ 270 bit key ⇒ impractical.
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | = 2n !.
• Need log(2n !) ≈ n2n bit key to index Pn .
• For n = 64, need ≈ 270 bit key ⇒ impractical.
Practical view
• Carefully choose a subset S ⊂ Pn having enough “randomness”
property for “practical” purposes.
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | = 2n !.
• Need log(2n !) ≈ n2n bit key to index Pn .
• For n = 64, need ≈ 270 bit key ⇒ impractical.
Practical view
• Carefully choose a subset S ⊂ Pn having enough “randomness”
property for “practical” purposes.
• 128-bit key ⇒ |S| = 2128
9
Block cipher
Theoretical view
• For each key K , the function E (K , .) is a permutation of {0, 1}n .
For a fixed key k ∈ {0, 1}r , Ek (.) (= E (k, .)) takes as input
m ∈ {0, 1}n and outputs c ∈ {0, 1}n
• Modeled as Pseudorandom Permutation
When K ←$ {0, 1}r EK () should be indistinguishable from a random
permutation on {0, 1}n .
How to distinguish?
Through queries (To be discussed later)
• Pn - Set of permutations on {0, 1}n . |Pn | = 2n !.
• Need log(2n !) ≈ n2n bit key to index Pn .
• For n = 64, need ≈ 270 bit key ⇒ impractical.
Practical view
• Carefully choose a subset S ⊂ Pn having enough “randomness”
property for “practical” purposes.
• 128-bit key ⇒ |S| = 2128
• Practical security claims made w.r.t. key size (e.g. 2128 operations). 9
Data Encryption Standard (DES)
Feistel Network
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
Li+1 = Ri
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
10
Data Encryption Standard (DES)
Feistel Network
i-th Round:
n
Li , Ri ∈ {0, 1} 2
n n
fi : {0, 1} 2 7→ {0, 1} 2 are arbitrary
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
10
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
11
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
Ri = Li+1
11
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
Ri = Li+1
Li = Ri+1 ⊕ fi (Ri )
= Ri+1 ⊕ fi (Li+1 )
11
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
Ri = Li+1
Li = Ri+1 ⊕ fi (Ri )
= Ri+1 ⊕ fi (Li+1 )
11
Li+1 = Ri
Ri+1 = Li ⊕ fi (Ri )
Ri = Li+1
Li = Ri+1 ⊕ fi (Ri )
= Ri+1 ⊕ fi (Li+1 )
11
Data Encryption Standard (DES)
Design of DES:
12
Data Encryption Standard (DES)
Design of DES:
• 16 round Feistel network
• Input size (block length) = 64 bits. Key size = 56 bits.
• Round functions fi , 1 ≤ i ≤ 16 are key dependent.
12
Data Encryption Standard (DES)
Design of DES:
• 16 round Feistel network
• Input size (block length) = 64 bits. Key size = 56 bits.
• Round functions fi , 1 ≤ i ≤ 16 are key dependent.
fi depends on 48-bit subkey ki derived from 56-bit master key
(through a key schedule)
12
Data Encryption Standard (DES)
13
Data Encryption Standard (DES)
Expansion (E ):
Key Schedule: Derives 48-bit
{0, 1}32 → {0, 1}48
round keys Ki from the 56-bit mas-
Permutation (P):
ter key.
{0, 1}32 → {0, 1}32
13
Data Encryption Standard (DES)
14
Data Encryption Standard (DES)
Design Considerations:
• 4 outputs of an S-box affects inputs to 6 S-boxes in the next round;
due to the permutation function P and the expansion function E .
• “Avalanche” effect; changing a single input affects a lot of outputs
after a few rounds.
15
Data Encryption Standard (DES)
Design Considerations:
• 4 outputs of an S-box affects inputs to 6 S-boxes in the next round;
due to the permutation function P and the expansion function E .
• “Avalanche” effect; changing a single input affects a lot of outputs
after a few rounds.
Facts:
• Designed in the 1970s by IBM and NSA. Adopted as FIPS standard
in 1977. Intensely scrutinised for years.
• Key length is small (56 bits) for brute-force attack (in fact, attacked).
• DES cracking box with FPGAs can find a key in 23 hours.
• Other forms of attack like TMTO (TBD) possible due to short key
• Short block length (64 bit) is also problematic -e.g., counter-mode
(TBD) security.
• Weaknesses has been obseved on reduced version, general consensus
is secure for 16 rounds (apart from short key) in practical scenario.
• Enhancements like Triple-DES is still used. Also in Unix passwords. 15
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
16
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
“Affect” does not mean change but change with probability 12 .
16
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
“Affect” does not mean change but change with probability 12 .
A random permutation surely achieves this.
16
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
“Affect” does not mean change but change with probability 12 .
A random permutation surely achieves this.
But requires a large key
16
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
“Affect” does not mean change but change with probability 12 .
A random permutation surely achieves this.
But requires a large key
Is there a way around?
16
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
“Affect” does not mean change but change with probability 12 .
A random permutation surely achieves this.
But requires a large key
Is there a way around?
divide into small blocks
16
Advanced Encryption Standard (AES)
Confusion-Diffusion Paradigm
Goal: Change in a single bit of the input “affects” a lot of (typicall all)
bits of the output.
“Affect” does not mean change but change with probability 12 .
A random permutation surely achieves this.
But requires a large key
Is there a way around?
divide into small blocks
16
Example:
Consider block size 16 bits.
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
Divide into 4 4 bit blocks and permute each block
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
Divide into 4 4 bit blocks and permute each block
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
Divide into 4 4 bit blocks and permute each block
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
Divide into 4 4 bit blocks and permute each block
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
Divide into 4 4 bit blocks and permute each block
17
Example:
Consider block size 16 bits.
Will require key of length ≈ 220
Divide into 4 4 bit blocks and permute each block
Likewise for y
1. Key Mixing: y = x ⊕ k
2. Substitution:
z = S1 (y1 )∥S2 (y2 )∥S3 (y3 )∥S4 (y4 )
3. Permutation: Permutes the bits of z
18
Substitution Permutation Network
Based on confusion-diffusion paradigm.
Instead of key dependent mapping the mapping is fixed (public).
(Sub-)key is xored with the input before the mapping is applied.
For a single round: Input x, Sub-key k,
Intermediate values y and z.
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
Likewise for y
1. Key Mixing: y = x ⊕ k
2. Substitution:
z = S1 (y1 )∥S2 (y2 )∥S3 (y3 )∥S4 (y4 )
3. Permutation: Permutes the bits of z
SPN is invertible
18
Advanced Encryption Standard (AES)
19
AddRoundKey: Add 128-bit
round key to the message.
20
AddRoundKey: Add 128-bit
round key to the message.
20
AddRoundKey: Add 128-bit
round key to the message.
20
AddRoundKey: Add 128-bit
round key to the message.
Speed of Operation:
• Can be measured e.g. by
openssl speed -evp aes-128-{ecb,ctr,cbc,ofb,cfb}
• In (ECB mode) AES can process 3.84 GB per second (depends on
various factors).
21
Modes of Operation
22
NIST standardized modes
• Confidentiality Modes
• ECB, CBC, OFB, CFB, CTR
• Authentication Modes
• XCBC
• Authenticated Encryption Modes
• CCM and GCM (high throughput)
• Modes for Confidentiality on Storage Devices (Disk Encryption)
• XTS
• Key-Wrap Modes
• KW, KWP, TKW
• Modes for Format Preserving Encryption
• FF1, FF3
23
Block cipher: Modes of operations
24
Block cipher: Modes of operations
25
Block cipher: Modes of operations
Counter mode
28
Block cipher: Modes of operations
29
Block cipher: Modes of operations
29
Block cipher: Modes of operations
Facts:
29
Block cipher: Modes of operations
Facts:
• ECB and CTR modes are efficient (order of magnitude faster than the
other modes).
29
Block cipher: Modes of operations
Facts:
• ECB and CTR modes are efficient (order of magnitude faster than the
other modes).
• CTR mode seems optimal for confidentiality purpose.
29
Attacks
What is an “attack”?
30
Keeloq
• Lightweight block cipher that uses 64 bit key and block size is 32 bits.
31
Keeloq
• Lightweight block cipher that uses 64 bit key and block size is 32 bits.
• Used in remote keyless entry systems by car manufacturers.
31
Keeloq
• Lightweight block cipher that uses 64 bit key and block size is 32 bits.
• Used in remote keyless entry systems by car manufacturers.
31
Keeloq
• Lightweight block cipher that uses 64 bit key and block size is 32 bits.
• Used in remote keyless entry systems by car manufacturers.
31
Keeloq
• Lightweight block cipher that uses 64 bit key and block size is 32 bits.
• Used in remote keyless entry systems by car manufacturers.
31
Attack Models
32
Attack Models
32
Attack Models
32
Attack Models
32
Attack Models
32
Attack Models
32
Adversarial goals
33
Adversarial goals
• Key recovery
33
Adversarial goals
• Key recovery
• State recovery
33
Adversarial goals
• Key recovery
• State recovery
• Distinguishing attack
33
Attack on DES
34
Attack on DES
34
Attack on DES
34
Attack on DES
34
Attack on DES
34
F (Ri ) and the permutation P is known
35
F (Ri ) and the permutation P is known
(32 bit) output of S-Box is
known.
35
F (Ri ) and the permutation P is known
(32 bit) output of S-Box is
known.
35
F (Ri ) and the permutation P is known
(32 bit) output of S-Box is
known.
35
4 bit output of S1 to S8 is known
36
4 bit output of S1 to S8 is known
Each Si is {0, 1}6 -to-{0, 1}4 mapping.
36
4 bit output of S1 to S8 is known
Each Si is {0, 1}6 -to-{0, 1}4 mapping.
36
4 bit output of S1 to S8 is known
Each Si is {0, 1}6 -to-{0, 1}4 mapping.
36
4 bit output of S1 to S8 is known
Each Si is {0, 1}6 -to-{0, 1}4 mapping.
36
4 bit output of S1 to S8 is known
Each Si is {0, 1}6 -to-{0, 1}4 mapping.
36
Attacks on SPN
37
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
37
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
Key?
37
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
Key?
Trivial!
37
Attacks on SPN
38
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
38
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
Key?
38
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
Key? Can always find in 216 × 216 = 232 operations.
38
Attacks on SPN
x x x x
z }|1 { z }|2 { z }|3 { z }|4 {
Input (plaintext):x = x1 . . . x4 x5 . . . x8 x9 . . . x12 x13 . . . x16
z z z z
z }|1 { z }|2 { z }|3 { z }|4 {
Output (ciphertext):z = z1 . . . z4 z5 . . . z8 z9 . . . z12 z13 . . . z16
Key? Can always find in 216 × 216 = 232 operations.
Can we do it faster?
38
First Attempt
1. Get y = z ⊕ K2 for each K2 ∈ {0, 1}16
39
First Attempt
1. Get y = z ⊕ K2 for each K2 ∈ {0, 1}16
2. For each y get unique K1 using x as before.
39
First Attempt
1. Get y = z ⊕ K2 for each K2 ∈ {0, 1}16
2. For each y get unique K1 using x as before.
39
First Attempt
1. Get y = z ⊕ K2 for each K2 ∈ {0, 1}16
2. For each y get unique K1 using x as before.
39
First Attempt
1. Get y = z ⊕ K2 for each K2 ∈ {0, 1}16
2. For each y get unique K1 using x as before.
39
First Attempt
1. Get y = z ⊕ K2 for each K2 ∈ {0, 1}16
2. For each y get unique K1 using x as before.
With additional (x, z) pairs possible (K1 , K2 ) pairs can be narrowed down.
39
Second Attempt
40
Second Attempt
40
Second Attempt
40
Second Attempt
40
Second Attempt
40
Second Attempt
40
Few generic attacks
• Brute-force search
• Meet-in-the-middle attack
• Algebraic attack
• Time-memory trade-off
• Differential attack
• Linear attack
• Side channel attack
41
Few generic attacks
• Brute-force search
• Meet-in-the-middle attack
• Algebraic attack
• Time-memory trade-off
• Differential attack
• Linear attack
• Side channel attack
41
Meet-in-the-middle attack
42
Meet-in-the-middle attack
42
Meet-in-the-middle attack
42
Meet-in-the-middle attack
42
Meet-in-the-middle attack
42
Meet-in-the-middle attack
42
Meet-in-the-middle attack
43
• Repeat the procedure with another plaintext-ciphertext pair (x ∗ , y ∗ )
taking the keys from S and then build another table S ∗ .
• After a few iterations correct key can be predicted with high
probability. The complete attack will take time much less than 2112 .
43
Stream Cipher
• Goal is to produce
{
{
K IV
k1 k r iv1 ivs pseudorandom (“random
looking”) key stream.
• Operation is broadly divided
E into two parts - Init and
GenBits
z2 • Init takes key K and
z1 initialization vector IV to
m2 m1 c2 c1
produce state st.
zi = E(K, IV)
i
ci = m i zi • GenBits produces keystream
from st.
44
Stream Cipher
• Goal is to produce
{
{
K IV
k1 k r iv1 ivs pseudorandom (“random
looking”) key stream.
• Operation is broadly divided
E into two parts - Init and
GenBits
z2 • Init takes key K and
z1 initialization vector IV to
m2 m1 c2 c1
produce state st.
zi = E(K, IV)
i
ci = m i zi • GenBits produces keystream
from st.
Why stream ciphers?
44
Stream Cipher
• Goal is to produce
{
{
K IV
k1 k r iv1 ivs pseudorandom (“random
looking”) key stream.
• Operation is broadly divided
E into two parts - Init and
GenBits
z2 • Init takes key K and
z1 initialization vector IV to
m2 m1 c2 c1
produce state st.
zi = E(K, IV)
i
ci = m i zi • GenBits produces keystream
from st.
Why stream ciphers?
Extremely efficient (especially in hardware).
44
Stream Cipher
• Goal is to produce
{
{
K IV
k1 k r iv1 ivs pseudorandom (“random
looking”) key stream.
• Operation is broadly divided
E into two parts - Init and
GenBits
z2 • Init takes key K and
z1 initialization vector IV to
m2 m1 c2 c1
produce state st.
zi = E(K, IV)
i
ci = m i zi • GenBits produces keystream
from st.
Why stream ciphers?
Extremely efficient (especially in hardware).Security?
44
Stream Cipher
• Goal is to produce
{
{
K IV
k1 k r iv1 ivs pseudorandom (“random
looking”) key stream.
• Operation is broadly divided
E into two parts - Init and
GenBits
z2 • Init takes key K and
z1 initialization vector IV to
m2 m1 c2 c1
produce state st.
zi = E(K, IV)
i
ci = m i zi • GenBits produces keystream
from st.
Why stream ciphers?
Extremely efficient (especially in hardware).Security?
Less understood than block ciphers.
44
First (Historical) Attempt
Linear Feedback Shift Register (LFSR):
45
Example:
time t = 1
46
Example:
time t = 1
time t = 2
46
Example:
time t = 1
time t = 2
time t = 3
46
Example:
time t = 1
time t = 2
time t = 3
46
Example:
time t = 1
time t = 2
time t = 3
46
Example:
time t = 1
time t = 2
time t = 3
State at time t + 1 -
(s3t+1 , s2t+1 , s1t+1 , s0t+1 )
46
Example:
time t = 1
time t = 2
time t = 3
s0t+1 = s1t
s1t+1 = s2t
Contents of the array at time t
s2t+1 = s3t
(s3t , s2t , s1t , s0t ) - state at time t
s3t+1 = s0t ⊕ s2t
t
State at time t + 1 - Output at time t + 1 = s0
(s3t+1 , s2t+1 , s1t+1 , s0t+1 )
46
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
2n
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
2n so the states and the output sequence will repeat
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
2n so the states and the output sequence will repeat
What is the maximum period?
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
2n so the states and the output sequence will repeat
What is the maximum period?
2n − 1
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
2n so the states and the output sequence will repeat
What is the maximum period?
2n − 1
Is it possible to achieve a period of 2n − 1 ?
47
If the LFSR has n registers -
s0t+1 = s1t
s1t+1 = s2t
..
.
t+1
sn−2 = snt
t+1
sn−1 = c0 s0t ⊕ c1 s1t ⊕ · · · ⊕ cn−2 sn−2
t
,
where ci = 1 if the i-th register is tapped, = 0 otherwise.
Output at time t + 1 = s0t
For a fixed LFSR output and state at t + 1 is uniquely determined by the
state at t
How many different states are possible?
2n so the states and the output sequence will repeat
What is the maximum period?
2n − 1
Is it possible to achieve a period of 2n − 1 ?
47
Yes, with appropriate tap positions (coefficients ci )
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
48
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
48
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
48
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
48
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
48
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
48
Sequences with period 2n − 1 (maximum length sequences, pseudo-noise
sequences) -
Have good random-like properties -
• # of 0s ≈ # of 1s
• # of 00 ≈ # of 01 ≈ # of 10 ≈ # of 11
..
.
How?
48
If the 2n bits are y1 , . . . , y2n and c0 , . . . cn−1 are unknown then
yn+1 = cn−1 yn ⊕ · · · ⊕ c0 y1
..
.
y2n = cn−1 y2n−1 ⊕ · · · ⊕ c0 yn
49
If the 2n bits are y1 , . . . , y2n and c0 , . . . cn−1 are unknown then
yn+1 = cn−1 yn ⊕ · · · ⊕ c0 y1
..
.
y2n = cn−1 y2n−1 ⊕ · · · ⊕ c0 yn
49
If the 2n bits are y1 , . . . , y2n and c0 , . . . cn−1 are unknown then
yn+1 = cn−1 yn ⊕ · · · ⊕ c0 y1
..
.
y2n = cn−1 y2n−1 ⊕ · · · ⊕ c0 yn
49
If the 2n bits are y1 , . . . , y2n and c0 , . . . cn−1 are unknown then
yn+1 = cn−1 yn ⊕ · · · ⊕ c0 y1
..
.
y2n = cn−1 y2n−1 ⊕ · · · ⊕ c0 yn
49
If the 2n bits are y1 , . . . , y2n and c0 , . . . cn−1 are unknown then
yn+1 = cn−1 yn ⊕ · · · ⊕ c0 y1
..
.
y2n = cn−1 y2n−1 ⊕ · · · ⊕ c0 yn
49
Add nonlinearity in the feedback:
Example: Instead of s0 ⊕ s2 (linear) make it s0 s2 ⊕ s1 s3
50
Add nonlinearity in the feedback:
Example: Instead of s0 ⊕ s2 (linear) make it s0 s2 ⊕ s1 s3
50
Add nonlinearity in the feedback:
Example: Instead of s0 ⊕ s2 (linear) make it s0 s2 ⊕ s1 s3
50
Add nonlinearity in the feedback:
Example: Instead of s0 ⊕ s2 (linear) make it s0 s2 ⊕ s1 s3
50
Add nonlinearity in the feedback:
Example: Instead of s0 ⊕ s2 (linear) make it s0 s2 ⊕ s1 s3
50
Details?
Add nonlinearity in the feedback:
Example: Instead of s0 ⊕ s2 (linear) make it s0 s2 ⊕ s1 s3
50
Details?FIY (Section 6.1.3)
Rivest’s Cipher: RC4
Trivia:
• Proposed by Ronald Rivest - ‘R’ of
RSA
• (Used to be?) used in WEP - Wifi
encryption
• Efficient in software
• Many weaknesses / vulnerabilities
found
Highlights of operation:
• 256 byte array S always contains a
permutation of {0, . . . , 255} - state
of the cipher.
• Init: 16 byte key is intially repeated
(in the 256 byte array) and then used
to swap entries of S.
• GenBits: produces the output byte by
pseudorandomly swapping the entries
of S - each entry is swapped at least
once in 256 times.
51
An attack on WEP
52
An attack on WEP
52
An attack on WEP
52
An attack on WEP
• The attacker waits until IV [0] = 3, IV [1] = 255, IV [2] = X (there are
other patterns as well)
52
An attack on WEP
• The attacker waits until IV [0] = 3, IV [1] = 255, IV [2] = X (there are
other patterns as well)
• After first four iterations of the second loop of Init -
S[0] = 3, S[1] = 0, S[3] = X + 6 + K [0].
52
An attack on WEP
• The attacker waits until IV [0] = 3, IV [1] = 255, IV [2] = X (there are
other patterns as well)
• After first four iterations of the second loop of Init -
S[0] = 3, S[1] = 0, S[3] = X + 6 + K [0].
• i is not touched in the next 252 iterations of Init. So, if j does not
take value in {0, 1, 3} in the next 252 iterations then S[0], S[1], S[3]
does not change.
52
An attack on WEP
• The attacker waits until IV [0] = 3, IV [1] = 255, IV [2] = X (there are
other patterns as well)
• After first four iterations of the second loop of Init -
S[0] = 3, S[1] = 0, S[3] = X + 6 + K [0].
• i is not touched in the next 252 iterations of Init. So, if j does not
take value in {0, 1, 3} in the next 252 iterations then S[0], S[1], S[3]
does not change.
• This happens with probability ( 253
256
)252 ≈ .05 assuming (heuristically) j
to be uniform.
52
An attack on WEP
• The attacker waits until IV [0] = 3, IV [1] = 255, IV [2] = X (there are
other patterns as well)
• After first four iterations of the second loop of Init -
S[0] = 3, S[1] = 0, S[3] = X + 6 + K [0].
• i is not touched in the next 252 iterations of Init. So, if j does not
take value in {0, 1, 3} in the next 252 iterations then S[0], S[1], S[3]
does not change.
• This happens with probability ( 253
256
)252 ≈ .05 assuming (heuristically) j
to be uniform.
• Assuming this to be the case - the first byte output by GenBits is
S[3].
52
An attack on WEP
• The attacker waits until IV [0] = 3, IV [1] = 255, IV [2] = X (there are
other patterns as well)
• After first four iterations of the second loop of Init -
S[0] = 3, S[1] = 0, S[3] = X + 6 + K [0].
• i is not touched in the next 252 iterations of Init. So, if j does not
take value in {0, 1, 3} in the next 252 iterations then S[0], S[1], S[3]
does not change.
• This happens with probability ( 253
256
)252 ≈ .05 assuming (heuristically) j
to be uniform.
• Assuming this to be the case - the first byte output by GenBits is
S[3].
• Since X is known the secret K [0] is revealed
52
“Weaknesses” of RC4:
53
“Weaknesses” of RC4:
Biases
53
“Weaknesses” of RC4:
Biases
Second output byte of GenBits is biased towards 0
53
“Weaknesses” of RC4:
Biases
Second output byte of GenBits is biased towards 0 RIY (Section 6.1.4)
53
Standardization
54
Standardization
54
Standardization
54
Standardization
54
Standardization
54
Standardization
54
Standardization
54
Standardization
54
Standardization
• ISO/IEC 10116:2006 spcifies the modes ECB, CBC, CFB, OFB, CTR.
54
Standardization
• ISO/IEC 10116:2006 spcifies the modes ECB, CBC, CFB, OFB, CTR.
• FIPS PUB 81 specifies ECB, CBC, CFB, OFB.
54
55
Standardization Process
• Starts the (open) competetion with a call for proposal.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
• Being open, the competetions receive entries from across the globe.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
• Being open, the competetions receive entries from across the globe.
• A proposal comprises of technical description along with software and
hardware implementation.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
• Being open, the competetions receive entries from across the globe.
• A proposal comprises of technical description along with software and
hardware implementation.
• Analysis begins and continues for several rounds and several years.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
• Being open, the competetions receive entries from across the globe.
• A proposal comprises of technical description along with software and
hardware implementation.
• Analysis begins and continues for several rounds and several years.
• Security of the schemes are analyzed by the relevant community
(researchers) with open discussion through publication of important
cryptanalytic results and performance evaluations.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
• Being open, the competetions receive entries from across the globe.
• A proposal comprises of technical description along with software and
hardware implementation.
• Analysis begins and continues for several rounds and several years.
• Security of the schemes are analyzed by the relevant community
(researchers) with open discussion through publication of important
cryptanalytic results and performance evaluations.
• Hardware and software performance is also extremely crucial. A more
secure scheme is less considered if it is not adequately efficient.
56
Standardization Process
• Starts the (open) competetion with a call for proposal.
• Prominent competitions: AES (Block ciphers), e-STREAM (Stream
ciphers), SHA-3 (Hash functions), PHC (Password hashing), CAESER
(Authenticated encryption).
• Broader competitions: CRYPTREC, NESSIE.
• Proposals are sumitted within a given deadline.
• Being open, the competetions receive entries from across the globe.
• A proposal comprises of technical description along with software and
hardware implementation.
• Analysis begins and continues for several rounds and several years.
• Security of the schemes are analyzed by the relevant community
(researchers) with open discussion through publication of important
cryptanalytic results and performance evaluations.
• Hardware and software performance is also extremely crucial. A more
secure scheme is less considered if it is not adequately efficient.
• At each round, a few candidates are shortlisted (those with no security
vulnerability and with satisfactory performance); the remaining are
discarded.
56
• At the end of the evaluation phase, a portfolio of selected candidates
is announced (some are suitable for software, some are suitable for
hardware).
57
• At the end of the evaluation phase, a portfolio of selected candidates
is announced (some are suitable for software, some are suitable for
hardware).
• Selected candidates are formally standardized.
57
Example: AES standardization
Requirement specification
59
Example: AES standardization
60
Image Sources
61
Reading Assignments
62