0% found this document useful (0 votes)
137 views55 pages

Main-DES With exaMPLE

The document provides an overview of DES encryption. [1] It describes taking a plain text message and running it through the DES algorithm with a given key to encrypt it. [2] The main steps are an initial permutation of the plaintext, splitting it into halves, running it through 16 iterations with subkeys derived from the main key and an expansion-permutation function, and a final permutation. [3] Each iteration uses substitution boxes to map 6-bit blocks of the expanded half-block value.

Uploaded by

Aniket Chanda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views55 pages

Main-DES With exaMPLE

The document provides an overview of DES encryption. [1] It describes taking a plain text message and running it through the DES algorithm with a given key to encrypt it. [2] The main steps are an initial permutation of the plaintext, splitting it into halves, running it through 16 iterations with subkeys derived from the main key and an expansion-permutation function, and a final permutation. [3] Each iteration uses substitution boxes to map 6-bit blocks of the expanded half-block value.

Uploaded by

Aniket Chanda
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 55

DES Encryption Overview

Plain text message : M = 0123456789ABCDEF,

where M is in hexadecimal (base 16) format.

Rewriting M in binary format, we get the 64-bit block of text:

M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (64)

Let K be the hexadecimal key

K = 133457799BBCDFF1

K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001


(64)
Key Schedule
Step 1: PC-1 permutation
DES operates on the 64-bit blocks using key sizes of 56- bits.

The keys are actually stored as being 64 bits long, but every 8th bit in
the key is not used (i.e. bits numbered 8, 16, 24, 32, 40, 48, 56, and
64).
The 64-bit key is permuted with table PC-1.

Since the first entry in the table is "57", this means that the 57th bit of the
original key K becomes the first bit of the permuted key K+. The 49th bit of
the original key becomes the second bit of the permuted key. The 4th bit of the
original key is the last bit of the permuted key.
From the original 64-bit key

K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001 (64: 8*8)
we get the 56-bit permutation

K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111 (56 : 7*8)
Key Schedule
Step 2: K+ splitting

Split permuted key K+ (56) into two half's of each 28 bit

• Left halve : C0 (28)

• Rright halve : D0 (28)

K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111 (56)

C0 = 1111000 0110011 0010101 0101111 (28)

D0 = 0101010 1011001 1001111 0001111 (28)


Key Schedule
Step 3: Creating 16 subkeys using shifting

Next we create sixteen pairs Cn and Dn for 1<=n<=16. Every pair Cn,

Dn is created from the previous pair Cn-1, Dn-1 for 1<=n<=16 through

certain number of "left shifts" of the previous block of bits. To

perform a left shit we need to move each bit of a block of data one

place to the left. The first bit goes to the end of the block.
Iteratation No. No. of Shifts
1 1
2 1
3 2
4 2
5 2
6 2
7 2
8 2
9 1
10 2

11 2

12 2

13 2

14 2

15 2

16 1
C0 = 1111000011001100101010101111

D0 = 0101010101100110011110001111

Iteratation No. No. of Shifts


1 1

C1 = 1110000110011001010101011111

D1 = 1010101011001100111100011110
C0 = 1111000011001100101010101111

D0 = 0101010101100110011110001111

Iteratatio No. of Shifts


C1 = 1110000110011001010101011111 n No.
D1 = 1010101011001100111100011110 1 1
2 1
3 2

C2 = 1100001100110010101010111111 4 2

D2 = 0101010110011001111000111101

C3 = 0000110011001010101011111111
D3 = 0101011001100111100011110101

C4 = 0011001100101010101111111100
D4 = 0101100110011110001111010101
C5 = 1100110010101010111111110000
D5 = 0110011001111000111101010101

C6 = 0011001010101011111111000011
D6 = 1001100111100011110101010101

C7 = 1100101010101111111100001100
D7 = 0110011110001111010101010110

C8 = 0010101010111111110000110011
D8 = 1001111000111101010101011001
C9 = 0101010101111111100001100110
D9 = 0011110001111010101010110011

C10 = 0101010111111110000110011001
D10 = 1111000111101010101011001100

C11 = 0101011111111000011001100101
D11 = 1100011110101010101100110011

C12 = 0101111111100001100110010101
D12 = 0001111010101010110011001111
C13 = 0111111110000110011001010101
D13 = 0111101010101011001100111100

C14 = 1111111000011001100101010101
D14 = 1110101010101100110011110001

C15 = 1111100001100110010101010111
D15 = 1010101010110011001111000111

C16 = 1111000011001100101010101111
D16 = 0101010101100110011110001111
Key Schedule
Step 4: PC-2 permutation
56-48

Before the final permutation we need to merge each pair of data.

Kn = CnDn ( K1 = C1 D1 ) find till K16

After that each block of bits CnDn for 1<=n<=16 is permuted according

to the PC-2 table forming the keys Kn.

Only 48 bits of each concatenated pair remain in the permuted key.


C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 (56 :7*8)
which, after we apply the permutation PC-2, becomes
K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (48: 6*8)

the first bit of Kn is the 14th bit of CnDn, the second bit the 17th, and so on, ending with

the 48th bit of Kn being the 32th bit of CnDn.


For the other keys we have
K2 = 011110 011010 111011 011001 110110 111100 100111 100101

K3 = 010101 011111 110010 001010 010000 101100 111110 011001

K4 = 011100 101010 110111 010110 110110 110011 010100 011101

K5 = 011111 001110 110000 000111 111010 110101 001110 101000

K6 = 011000 111010 010100 111110 010100 000111 101100 101111

K7 = 111011 001000 010010 110111 111101 100001 100010 111100

K8 = 111101 111000 101000 111010 110000 010011 101111 111011

K9 = 111000 001101 101111 101011 111011 011110 011110 000001

K10 = 101100 011111 001101 000111 101110 100100 011001 001111

K11 = 001000 010101 111111 010011 110111 101101 001110 000110

K12 = 011101 010111 000111 110101 100101 000110 011111 101001

K13 = 100101 111100 010111 010001 111110 101011 101001 000001

K14 = 010111 110100 001110 110111 111100 101110 011100 111010

K = 101111 111001 000110 001101 001111 010011 111100 001010


Message Encoding

Plain text message : M = 0123456789ABCDEF,

M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (64)
Message Encoding
Step 1: IP permutation

There is an initial permutation IP of the 64 bits of the message data M. This

rearranges the bits according to the following table, where the entries in the

table show the new arrangement of the bits from their initial order. The 58th

bit of M becomes the first bit of IP. The 50th bit of M becomes the second bit

of IP. The 7th bit of M is the last bit of IP.


M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (64)

IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 (64)
Message Encoding
Step 2: IP splitting

The next step is splitting IP into halves: L0 and R0. Both halves have 32 bits.

IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010 (64)

L0 = 1100 1100 0000 0000 1100 1100 1111 1111 (32)

R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (32)


School of Computing and 24
Information Technology, Lovely
Professional University
Ln = 32
Rn = 32
Kn = 48

in the f calculation, we XOR the output


Ln = Rn-1 E(Rn-1) with the key
Rn = Ln-1 + f(Rn-1,Kn)
f(Rn-1,Kn) = E(Rn-1) + Kn E- expansion

Initially we have L0 and R0 and also Kn

L1 = R1-1 = R0

R1 = L1-1 + f(R1-1,K1) = L0 + f(R0, K1)

We now proceed through 16 iterations, for 1<=n<=16, using a function f whic


operates on two blocks--a data block of 32 bits and a key Kn of 48 bits--to produce
block of 32 bits. Let + denote XOR addition
K1 = 000110 110000 001011 101111 111111 000111 000001 110010

L1 = R0 = 1111 0000 1010 1010 1111 0000 1010 1010

R1 = L0 + f(R0,K1)

R0 is 32 bits

K1 is 48 bits

so convert R0 to 48 bits with help of expansion table (E BIT-SELECTION TABLE)


Rn Expansion :
Division of 32 bit Rn into Eight 4-bit block
Rn Expansion :
Rn Expansion Permutation Table

32 1 2 3 4 5 4 5 6 7 8 9

8 9 10 11 12 13 12 13 14 15 16 17

16 17 18 19 20 21 20 21 22 23 24 25

24 25 26 27 28 29 28 29 30 31 32 1
Rn Expansion Permutation Table

32 1 2 3 4 5 4 5 6 7 8 9

8 9 10 11 12 13 12 13 14 15 16 17

16 17 18 19 20 21 20 21 22 23 24 25

24 25 26 27 28 29 28 29 30 31 32 1
R0 = 1111 0000 1010 1010 1111 0000 1010 1010 (32)

E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101 (48)
Rn = Ln-1 + f(Rn-1,Kn)

f(Rn-1,Kn) = E(Rn-1) + Kn

R1 = L1-1 + f(R1-1,K1) = L0 + f(R0, K1 )

K1 = 000110 110000 001011 101111 111111 000111 000001 110010 (48)

E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101 (48)

f(E(R0)+k1 ) = 011000 010001 011110 111010 100001 100110 010100 100111. (48)
Way to S-Box Substitution
S-Box Substitution
School of Computing and 35
Information Technology, Lovely
Professional University
Selecting an Entry in a S-Box
based on the 6-bit input
Kn + E(Rn-1) =B1B2B3B4B5B6B7B8,

each Bi is a group of six bits. We now calculate

S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)

where Si(Bi) referres to the output of the i-th S box.


To repeat, each of the functions S1, S2,..., S8, takes a 6-bit block as input and yield
4-bit block as output.
We have B1B2B3B4B5B6B7B8, from e- expansion
Now we need S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)
Example
B1: 0 1 1 0 0 0

00 : 0 th row

1100 : 12 th column

it is 5 so 5 = 0101

So S(B1)= 0101
Kn + E(Rn-1) = B1 B2 B3 B4 B5 B6 B7 B8,

E(R0)+k1 = 011000 010001 011110 111010 100001 100110 010100 100111. (48)

S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)

= 0101 1100 1000 0010 1011 0101 1001 0111 (32)


permutation P of the S-box

•The final stage in the calculation of f is to do a permutation P of the S-box output to


obtain the final value of f:
f = P(S1(B1)S2(B2)...S8(B8))
•The permutation P is defined in the following table. P yields a 32-bit output from
a 32-bit input by permuting the bits of the input block.
S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) = 0101 1100 1000 0010 1011 0101 1001 0111

we get

f = 0010 0011 0100 1010 1010 1001 1011 1011


R1 = L0 + f(R0 , K1 )

= 1100 1100 0000 0000 1100 1100 1111 1111


+ 0010 0011 0100 1010 1010 1001 1011 1011
= 1110 1111 0100 1010 0110 0101 0100 0100
In the next round, we will have L2 = R1, which is the block we just calculated, and then

we must calculate R2 =L1 + f(R1, K2), and so on for 16 rounds. At the end of the sixteenth

round we have the blocks L16 and R16. We then reverse the order of the two blocks into

the 64-bit block

R16L16
If we process all 16 blocks using the method defined previously, we

get, on the 16th round,

L16 = 0100 0011 0100 0010 0011 0010 0011 0100

R16 = 0000 1010 0100 1100 1101 1001 1001 0101


Swap of 32 bit

LR=RL at 16th round

L16 = 0100 0011 0100 0010 0011 0010 0011 0100

R16 = 0000 1010 0100 1100 1101 1001 1001 0101

L16 R16 = 0100 0011 0100 0010 0011 0010 0011 0100 0000 1010 0100 1100 1101 1001 1001 0101

After swap

R16 L16 =

0000 1010 0100 1100 1101 1001 1001 0101 0100 0011 0100 0010 0011 0010 0011 0100
final permutation

R16 L16 =

0000 1010 0100 1100 1101 1001 1001 0101 0100 0011 0100 0010 0011 0010 0011 0100

IP-1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100 00000101


IP-1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100 00000101

which in hexadecimal format is


85E813540F0AB405.

You might also like