Lec 4
Lec 4
17022522
-Block Ciphers and the Data Encryption
Standard-
Lecture slides by Dr. Eman Daraghmi
Associate Professor
1
2020 - 2021
Topics To be Covered …
vFeistel Structure
vKey Generation
2
Part I: Block Ciphers Principles
3
Traditional Symmetric Ciphers vs.
Modern Symmetric Ciphers
Symmetric
Ciphers
4
Block Ciphers vs. Stream Ciphers
vIn block cipher, a block of plaintext is used to produce a ciphertext block
of equal length.
vTypically, a block size of 64 or 128 bits is used. The choice of block size
does not directly affect to the strength of encryption scheme. The
strength of cipher depends up on the key length.
vPadding algorithms could be used if necessary
5
Padding Example
How many padding bits must be added to a message of 100 characters if 8-bit
ASCII is used for encoding and the block cipher accepts blocks of 64 bits?
6
Padding Example
How many padding bits must be added to a message of 100 characters if 8-bit
ASCII is used for encoding and the block cipher accepts blocks of 64 bits?
Answer:
7
Reversible/Singular Mapping or
Transformation
v Reversible Encryption = v Irreversible Encryption =
each plaintext block must produce More than one plaintext block may
produce the same ciphertext block.
a unique ciphertext block.
8
General n-bit-n-bit Block
Substitution (n = 4)
9
Claude Shannon and Substitution-Permutation Ciphers
10
Components of Modern Cipher
1- P-Boxes (Permutation Boxes): Perform Transposition
11
Components of Modern Cipher
1- Straight P-Boxes: It takes n inputs and produces n outputs via
permutation
Example of a 64 × 64 straight P-Box
12
Components of Modern Cipher -
Example
• Design an 8 × 8 permutation table for a straight P-
box that moves the two middle bits (bits 4 and 5) in
the input word to the two ends (bits 1 and 8) in the
output words. Relative positions of other bits
should not be changed.
13
Part II: Feistel Block Cipher
14
Feistel Block Cipher
15
Feistel Block Cipher
16
Feistel Block Cipher
This is a trivial example. The plaintext and ciphertext are each 4 bits long and the
key is 3 bits long. Assume that the function takes the first and third bits of the
key, interprets these two bits as a decimal number, squares the number, and
interprets the result as a 4-bit binary pattern. Show the results of encryption and
decryption if the original plaintext is 0111 and the key is 101.
Feistel Block Cipher
This is a trivial example. The plaintext and ciphertext are each 4 bits long and the
key is 3 bits long. Assume that the function takes the first and third bits of the
key, interprets these two bits as a decimal number, squares the number, and
interprets the result as a 4-bit binary pattern. Show the results of encryption and
decryption if the original plaintext is 0111 and the key is 101.
Solution
The function extracts the first and second bits to get 11 in binary or 3 in decimal. The
result of squaring is 9, which is 1001 in binary.
Feistel Cipher Structure- Encryption Process
19
Feistel Cipher Decryption
20
Feistel Cipher Design Elements
21
Part III: Data Encryption Standard
(DES)
22
Data Encryption Standard (DES)
23
DES Design Controversy
valthough DES standard is public
vwas considerable controversy over design
qin choice of 56-bit key (vs Lucifer 128-bit)
qand because design criteria
vsubsequent events and public analysis show in
fact design was appropriate
vuse of DES has flourished
qespecially in financial applications
qstill standardised for legacy application use
24
DES Encryption
1- plaintext 64 bits
Process
25
DES Encryption Process
vDES is based on R1
three basics phases
qInitial Permutation
qPermutation and R2
substitution
qPermutation
(inverse the initial
permutation)
R16
26
Initial Permutation IP
v The initial and final permutations are straight Permutation boxes (P-
boxes) that are inverses of each other.
v Rearrange the bits according to the following table, e.g. the 58bits
of the input becomes the first bit after the IP
27
Initial Permutation IP Example
• Plaintext
675a6967 5e5a6b5a
Convert it to binary
28
0110 0111 0 1 0 1 1 0 1 0 0 1 1 0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 0 0 1 0 1 1 0 0 1 1 1 0 1 0 1
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
1 1 1 0 0 1 0 1 1 0 1 0
37 38 39 40 41 42 43 44 45 46 47 48
0 1 1 0 1 0 1 1 0 1 0 1 1 0 1 0
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
• Apply the Initial Permutation
1111 1111 1011 0010 0001 1001 0100 1001
0000 0000 0100 1101 1111 0110 1111 1011
29
IP Example 2
• Consider the following Plaintext
and apply the IP
0000 0001 0010 0011 0100 0101 0110 0111
1000 1001 1010 1011 1100 1101 1110 1111
IP =
1100 1100 0000 0000 1100 1100 1111 1111
1111 0000 1010 1010 1111 0000 1010 1010
30
DES Details of a single Round
31
2- Proceeding through 16 iterations, for
1<=i<=16, using a function f which
operates on two blocks
--a data block of 32 bits and a key Ki of 48
bits--to produce a block of 32 bits.
--The heart of this cipher is the DES
function, f. The DES function applies a 48-
bit key to the rightmost 32 bits to produce
a 32-bit output.
• Li = Ri-1
• Ri = Li-1 ⊕ F(Ri-1, Ki)
32
From the Previous Example (example #2)
• Consider the following Plaintext and apply the IP
0000 0001 0010 0011 0100 0101 0110 0111
1000 1001 1010 1011 1100 1101 1110 1111
IP =
1100 1100 0000 0000 1100 1100 1111 1111
1111 0000 1010 1010 1111 0000 1010 1010
33
Example
vExample: For R = 1, we have
K1 =
000110 110000 001011 101111
111111 000111 000001 110010
L1 = R0 =
1111 0000 1010 1010 1111 0000 1010
1010
R1 = L0 ⊕ f(R0,K1)
34
Example
vExample: For R = 1, we have
K1 =
000110 110000 001011 101111
111111 000111 000001 110010
L1 = R0 =
1111 0000 1010 1010 1111 0000 1010
1010
R1 = L0 ⊕ f(R0,K1)
35
Round Function Explanation
v Expansion Permutation
Box (E(Ri))
36
Expansion Permutation Box
37
Expansion Permutation Box
38
Example (R0 from previous step)
39
Round Function Explanation
vXOR (Whitener).
qAfter the expansion
permutation, DES does XOR
operation on the expanded
right section and the round
key.
qThe round key is used only in
this operation.
qMathematically ki + E(n-1)
INPUT OUTPUT
A B A XOR B
0 0 0
0 1 1
1 0 1
1 1 0 40
XOR (Whitener) Example
Example:
41
Round Function Explanation
v Substitution Boxes:
42
Substitution Boxes
v With each group of six bits, DES uses them as addresses in tables
called “S boxes”
v Each group of six bits will give us an address in a different S box.
v Located at that address will be a 4 bit number. This 4 bit number will
replace the original 6 bits.
v The net result is that the eight groups of 6 bits are transformed into
eight groups of 4 bits (the 4-bit outputs from the S boxes) for 32 bits
total.
43
Substitution Boxes
44
Substitution Boxes
Table for S1 box
• The first and last bits of B represent in base 2 a number in the decimal range 0 to 3
(or binary 00 to 11). Let that number be i.
• The middle 4 bits of B represent in base 2 a number in the decimal range 0 to 15
(binary 0000 to 1111). Let that number be j.
Look up in the table the number in the i-th row and j-th column. It is a
number in the range 0 to 15 and is uniquely represented by a 4 bit block.
That block is the output S1(B) of S1 for the input B.
45
Substitution Boxes
v For input block B = 011011 the first bit is "0" and the last bit "1" giving 01
as the row. This is row 1.
v The middle four bits are "1101". This is the binary equivalent of decimal
13, so the column is column number 13.
v In row 1, column 13 appears 5.
v This determines the output; 5 is binary 0101, so that the output is 0101.
v Hence S1(011011) = 0101.
46
Substitution Boxes
v The tables defining the functions S1,...,S8 are the following:
47
Substitution Boxes
48
Substitution Boxes
49
Substitution Boxes
50
Substitution Boxes Example (continued)
51
Round Function Explanation
52
Straight Permutation Example (continued ..)
we get
f = 0010 0011 0100 1010 1010 1001 1011 1011
53
Example (continued ..)
The result of the first round
• R1 = L0 XOR f(R0,K1)
54
Summary: DES Details of a single Round
55
Part IV: Creating 16 DES sub keys
56
Creating 16 DES sub keys
57
Creating 16 DES sub keys
58
Creating 16 DES sub keys
v Next, split this key into left and right halves, C0 and D0,
where each half has 28 bits.
v Example: From the permuted key K+, we get
q C0 = 1111000 0110011 0010101 0101111
q D0 = 0101010 1011001 1001111 0001111
v With C0 and D0 defined, we now create sixteen blocks Cn
and Dn, 1<=n<=16.
v Each pair of blocks Cn and Dn is formed from the
previous pair Cn-1 and Dn-1, respectively, for n = 1, 2, ...,
16, using the following schedule of "left shifts" of the
previous block.
v To do a left shift, move each bit one place to the left,
except for the first bit, which is cycled to the end of the
block.
59
Creating 16 DES sub keys
v This means, for example, C3 and D3 are obtained from C2 and D2,
respectively, by two left shifts, and C16 and D16 are obtained
from C15 and D15, respectively, by one left shift.
60
Creating 16 DES sub keys
61
Creating 16 DES sub keys
62
Creating 16 DES sub keys
63
Creating 16 DES sub keys
64
Creating 16 DES sub keys
65
Creating 16 DES sub keys
v We now form the keys Kn, for 1<=n<=16, by applying the following
permutation table to each of the concatenated pairs CnDn.
v Each pair has 56 bits, but PC-2 only uses 48 of these.
66
Creating 16 DES sub keys
67
Creating 16 DES sub keys
68
Creating 16 DES sub keys
69
Creating 16 DES sub keys
70
DES Key Schedule
v forms sub keys used in each round
q initial permutation of the key (PC1)
which selects 56-bits in two 28-bit
halves
q 16 stages consisting of:
§ rotating each half separately either 1
or 2 places depending on the key
rotation schedule K
§ permuting them by PC2 for use in
round function F
71
DES Decryption
72
Analyzing DES
73
Avalanche Effect
74
Avalanche Effect - Example 1:
75
Avalanche Effect – Example 2
• This table shows a similar test in which a single plaintext
is input:
01101000 10000101 00101111 01111010 00010011
01110110 11101011 10100100
• with two keys that differ in only one bit position:
1110010 1111011 1101111 0011000 0011101 0000100
0110001 11011100
0110010 1111011 1101111 0011000 0011101 0000100
0110001 11011100
76
Summary
v have considered:
qblock vs stream ciphers
qFeistel cipher design & structure
qDES
§ details
§ Key generation
77
Summary
v have considered:
qblock vs stream ciphers
qFeistel cipher design & structure
qDES
§ details
§ Key generation
§ Strength of DES
78