UNIT 2 2nd half
UNIT 2 2nd half
SDES
BLOCK CIPHER PRINCIPLES
DES
DIFFERENTIAL AND LINEAR CRYPTANALYSIS
BLOCK CIPHER DESIGN PRINCIPLES
BLOCK CIPHER MODE OF OPERATION
AES
RC4
KEY DISTRIBUTION
SDES(Simplified DES)
What is Simplified DES
• Developed 1996 as a teaching tool
– Santa Clara University
• Prof. Edward Schaefer
– Takes an 8-bit block plaintext, a 10 –bit key and
produces an 8-bit block of ciphertext
– Decryption takes the 8-bit block of ciphertext,
the same 10-bit key and produces the original
8-bit block of plaintext
S-DES Scheme
Encryption
Decryption
P10
8-bit plaintext 8-bit plaintext
SHIFT
IP IP - 1
P8
K1 K1
fk fk
SHIFT
SW SW
K2 P8 K2
fk fk
IP - 1 IP
4
Encryption Detail
E/P
8 K1
4
4 4
S0 S1
2 2
P4 4
SW
E/P
K2
S0 S1
P4
I P -1
Initial Permutation (IP)
Move the bits of the original character around a little…
k1 k2 k3 k4 k5 k6 k7 k8
k2 k6 k3 k1 k4 k8 k5 k7
Expansion/Permutation (E/P)
Expand 4 bits into 8 and permutate them…
k1 k2 k3 k4
k4 k1 k2 k3 k2 k3 k4 k1
Key Generation
10
P10
5 5
LS-1 LS-1
5 5
P8
8
K1
LS-2 LS-2
5 5
P8
8
K2
P10 Permutation
k1 k2 k3 k4 k5 k6 k7 k8 k9 k10
k3 k5 k2 k7 k4 k10 k1 k9 k8 k6
P8 Permutation
Permutate 10 into 8
k1 k2 k3 k4 k5 k6 k7 k8 k9 k10
k6 k3 k7 k4 k8 k5 k10 k9
LS-1
Left circular shift 1 each 5 bit group
k3 k 5 k 2 k 7 k 4 k10 k1 k9 k8 k6
k5 k 2 k 7 k 4 k 3 k1 k9 k8 k6 k10
LS-2
Left circular shift 2 each 5 bit group
k3 k 5 k 2 k 7 k 4 k10 k1 k9 k8 k6
k2 k7 k4 k3 k5 k9 k8 k6 k10 k1
Substitution Boxes
S0 S1
1 0 3 2 0 1 2 3
3 2 1 0 2 0 1 3
0 2 1 3 3 0 1 0
3 1 3 2 2 1 0 3
Block Cipher Principles
Stream Ciphers And Block Ciphers
Stream Cipher:
It is one that encrypts a digital data stream one
bit or one byte at a time.
Eg: Vignere Cipher and the Vernam Cipher
Block Cipher:
It is one in which a block of plaintext is treated
as a whole and used to produce a ciphertext
block of equal length.
Typically block size will be 64 or 128 bits
Stream Cipher
BLOCK CIPHER
BLOCK CIPHER PRINCIPLES
Motivation for the Feistel Cipher Structure:
n-bit block cipher takes n-bit plaintext and
produces n-bit ciphertext
2ⁿ possible different plaintext blocks
Encryption must be reversible(decryption
possible)
Each plaintext block must produce unique
ciphertext block
Total transformation is 2ⁿ!
Feistel cipher - introduction
• Claude Shannon introduced idea of substitution-permutation
– substitution(S-box)
– permutation(P-box)
Li = Ri-1
Ri = Li-1 x F(Ri-1, Ki)
Initial Permutation
To see that these two permutation functions where Mi is a binary digit. Then the
are indeed the inverse of each other, consider permutation X = IP(M) is as follows:
the following 64-bit input M:
After initial permutation next step it
goes to round 1. the below diagram
shows the each round
Expansion permutation
goes to permuted choice 2 (ie) key
generation. the below diagram shows the
key generation
Permuted choice 1
After pc 1 next step goes to left shift
Left shift
Next step pc2
Permutated choice 2
After initial permutation next step it
goes to round 1. the below diagram
shows the each round
Encryption (Round) (cont.)
F
S-box
[1]
ENCRYPTION (ROUND) (CONT.)
S-box
ENCRYPTION (ROUND) (CONT.)
Separate plaintext as L0R0
L0: left half 32 bits of plaintext
R0: right half 32 bits of plaintext
F
Expansion/permutation: E( )
Substitution/choice: S-box( )
Permutation: P( )
Ri Li 1 ~ P ( S _ box ( E ( Ri 1 ) ~ Keyi ))
Li Ri 1
Key Generation (cont.)
• Original Key: Key0
• Permuted Choice One: PC_1( )
• Permuted Choice Two: PC_2( )
• Schedule of Left Shift: SLS( )
(C0 , D0 ) PC _ 1( Key 0 )
(Ci , Di ) SLS (Ci 1 , Di 1 )
Keyi PC _ 2( SLS (Ci 1 , Di 1 ))
Decryption
• The same algorithm as
encryption.
• Reversed the order of key
(Key16, Key15, … Key1).
• For example:
– IP undoes IP-1 step of
encryption.
– 1st round with SK16 undoes
16th encrypt round.
[1]
Strength of DES
• Criticism
– Reduction in key size of 72 bits
• Too short to withstand with brute-force attack
– S-boxes were classified.
• Weak points enable NSA to decipher without key.
• 56-bit keys have 256 = 7.2 x 1016 values
– Brute force search looks hard.
– A machine performing one DES encryption per
microsecond would take more than a thousand year to
break the cipher.
Strength of DES (cont.)
• i=1,2,…....,16
Differential cryptanalysis attack(cont)
K
State
P + C
RC4 is based on the concept of a state.
8.110
Figure 8.10 The idea of RC4 stream cipher
KSA
PRGA
8.111
RC4 Key Schedule KSA
Scrambling Pseudocode :
for i = 0 to 255 do
S[i] = i
j=0
for i = 0 to 255 do
j = (j + S[i] + k[i ]) (mod 256)
swap (S[i], S[j])
8.112
RC4 PRGA and Encryption
8.113
RC4 Encryption Example
8.114
RC4 PRGA and Encryption
The first step is to generate the stream.
Initialise the state vector S and temporary vector T. S is initialised so
the S[i] = i, and T is initialised so it is the key K (repeated as
necessary).
S = [0 1 2 3 4 5 6 7]
T = [1 2 3 6 1 2 3 6]
Now perform the initial permutation on S.
j = 0;
for i = 0 to 7 do
j = (j + S[i] + T[i]) mod 8
Swap(S[i],S[j]);
end
For i = 0:
j = (0 + 0 + 1) mod 8 = 1
Swap(S[0],S[1]);
S = [1 0 2 3 4 5 6 7]
8.115
RC4 PRGA and Encryption
For i = 1:
j=3
Swap(S[1],S[3])
S = [1 3 2 0 4 5 6 7];
For i = 2:
j=0
Swap(S[2],S[0]);
S = [2 3 1 0 4 5 6 7];
For i = 3:
j = 6;
Swap(S[3],S[6])
S = [2 3 1 6 4 5 0 7];
8.116
RC4 PRGA and Encryption
For i = 4:
j=3
Swap(S[4],S[3])
S = [2 3 1 4 6 5 0 7];
For i = 5:
j=2
Swap(S[5],S[2]);
S = [2 3 5 4 6 1 0 7];
For i = 6:
j = 5;
Swap(S[6],S[4])
S = [2 3 5 4 0 1 6 7];
For i = 7:
j = 2;
Swap(S[7],S[2])
S = [2 3 7 4 0 1 6 5];
Hence, our initial permutation of S = [2 3 7 4 0 1 6 5];
8.117
RC4 PRGA and Encryption
Now we generate 3-bits at a time, k, that we XOR with each 3-bits of
plaintext to produce the ciphertext. The 3-bits k is generated by:
i, j = 0;
while (true) {
i = (i + 1) mod 8;
j = (j + S[i]) mod 8;
Swap (S[i], S[j]);
t = (S[i] + S[j]) mod 8;
k = S[t]; }
Remember, P = [1 2 2 2]
So our first 3-bits of ciphertext is obtained by: k XOR P
5 XOR 1 = 101 XOR 001 = 100 = 4
8.120
Key Distribution
KEY DISTRIBUTION