Main-DES With exaMPLE
Main-DES With exaMPLE
M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (64)
K = 133457799BBCDFF1
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
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
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
C1 = 1110000110011001010101011111
D1 = 1010101011001100111100011110
C0 = 1111000011001100101010101111
D0 = 0101010101100110011110001111
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
After that each block of bits CnDn for 1<=n<=16 is permuted according
the first bit of Kn is the 14th bit of CnDn, the second bit the 17th, and so on, ending with
M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 (64)
Message Encoding
Step 1: IP permutation
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
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)
L1 = R1-1 = R0
R1 = L0 + f(R0,K1)
R0 is 32 bits
K1 is 48 bits
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
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,
S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)
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)
we get
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
R16L16
If we process all 16 blocks using the method defined previously, we
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