User:Rajib Kumar Halder

DES Algorithm Key Generation
In DES algorithm there are sixteen round and for each round needs one key where every key size is 48 bit.That means total sixteen keys are needed for whole process.

Step:1
First a 64 bit key convert  to 56 bit key with the help of a “Parity Bit Drop” table. The “Parity Bit Drop” table drop 8,16,24,32,64,40,48,56,64 position number bits from the 64 bit key and at last remain 56 bit. Now this 56 bits are re-arranged according to the number’s positing that number’s contain by the “Parity Bit Drop” table. This re-arrange process is called permutation.

Table : Parity Bit Drop

From above table we notice that 8,16,24,32,64,40,28,56,64 are not present in this table. That means these table drops the parity bits (8,16,24,32,64,40,28,56,64) from 64 bit key(64-8=56 bit)

Example:

Let a key, K=133457799BBCDFF1.

Now convert it to binary value.

K=133457799BBCDFF1 Now this is a 64 bit key. Draw a box that have 64 blocks and numbering the block from 1 to 64.Put per bit in per block.

According to the  #Step:1 now convert this 64 bit key to 56 bit key with the help of a “Parity Bit Drop” table.

Table: 1 : 64 bit key    

Table: 2 : Parity Drop Table

Now we select that bits from table:1 which position numbers are present in Table:2 and arrange it according to the position number of  Table:2 value. After dropping and re-arranged , Finally the 56 bit key is

1111000 0110011 0010101 0101111  0101010 1011001 1001111 0001111

Step:2
56 bit key divided into two section. Here per section contain 28 bit. let the two section are respectively C0 and D0.Here C0 contains first 28 bit key and D0 contains second 28 bit key.

Example: Above Step:1 we get 56 bit key.

1111000 0110011 0010101 0101111  0101010 1011001 1001111 0001111

Now divide it into two section.

1111000 0110011 0010101 0101111                     0101010 1011001 1001111 0001111

C0=1st 28 bit                                                         D0=2nd 28 bit

Step:3
Now Each section C0 and  D0 are shifted left(circular round) individually and after shifting renamed to $$C_1$$ and $$D_1$$ respectively.

$$C_1$$=shift left($$C_0$$)

$$D_1$$=shift left($$D_0$$)

Up to n times........

$$C_n$$=shift left(Cn-1)

$$D_n$$=shift left(Dn-1)

Where 1<=n<=16

In left shifting there are two condition.


 * C1 and D1 ,C2 and D2 ,C9 and D9,C16 andD16 are produced by shifting only one bit respectively from C0.and D0,C1 and D1,C8 and D8,C15 and D15 That means-


 * 1) C1 and D1   are obtained from  C0.and D0    respectively by one left shift.
 * 2) C2 and D2   are obtained from  C1 and D1    respectively by one left shift
 * 3) C9 and D9   are obtained from  C8 and D8    respectively by one left shift.
 * 4) C16 andD16 are obtained from C15 and D15 respectively by one left shift.


 * And in other, shifting two bits at a time respectively based on previous. That means-


 * 1) C3  and D3 are obtained from  C2 and D2  respectively by two left shift at a time. According to this rule obtain other pair without C1 and D1 ,C2 and D2 ,C9 and D9,C16 andD16.

Example: From  #Step:2 we get,


 * C0 = 1111000011001100101010101111
 * D0 = 0101010101100110011110001111

Now According to Step:3 apply  


 * C1 = 1110000110011001010101011111 ->1bit left shift(C0)
 * D1 = 1010101011001100111100011110 ->1 bit left shift(D0)
 * C2 = 1100001100110010101010111111->1bit left shift(C1)
 * D2 = 0101010110011001111000111101->1bit left shift(D1)
 * C3 = 0000110011001010101011111111->2 bit left shift(C2)
 * D3 = 0101011001100111100011110101 ->2bit left shift(D2)
 * C4 = 0011001100101010101111111100->2 bit left shift(C3)
 * D4 = 0101100110011110001111010101 ->2 bit left shift(D3)
 * C5 = 1100110010101010111111110000->2 bit left shift(C4)
 * D5 = 0110011001111000111101010101 ->2 bit left shift(D4)
 * C6 = 0011001010101011111111000011->2 bit left shift(C5)
 * D6 = 1001100111100011110101010101->2 bit left shift(D5)
 * C7 = 1100101010101111111100001100->2 bit left shift(C6)
 * D7 = 0110011110001111010101010110->2 bit left shift(D6)
 * C8 = 0010101010111111110000110011->2 bit left shift(C7)
 * D8 = 1001111000111101010101011001 ->2 bit left shift(D7)
 * C9 = 0101010101111111100001100110->1bit left shift(C8)
 * D9 = 0011110001111010101010110011->1bit left shift(D8)
 * C10 = 0101010111111110000110011001->2 bit left shift(C9)
 * D10 = 1111000111101010101011001100 ->2 bit left shift(D9)
 * C11 = 0101011111111000011001100101->2 bit left shift(C10)
 * D11 = 1100011110101010101100110011->2 bit left shift(D10)
 * C12 = 0101111111100001100110010101->2 bit left shift(C11)
 * D12 = 0001111010101010110011001111->2 bit left shift(D11)
 * C13 = 0111111110000110011001010101->2 bit left shift(C12)
 * D13 = 0111101010101011001100111100 ->2 bit left shift(D12)
 * C14 = 1111111000011001100101010101->2 bit left shift(C13)
 * D14 = 1110101010101100110011110001->2 bit left shift(D13)
 * C15 = 1111100001100110010101010111->2 bit left shift(C14)
 * D15 = 1010101010110011001111000111->2 bit left shift(D14)
 * C16 = 1111000011001100101010101111->1bit left shift(C15)
 * D16 = 0101010101100110011110001111->1bit left shift(D15)

Step:4
Now concate the pair $$C_n$$and $$D_n$$ where 1<=n<=16.After concating apply “Compression D-box” table on it. This “Compression D-box” change the bit position and convert the 56 bit key to 48 bit key.

Example: From  Step:4 we get,


 * C1 D1 = 11100001100110010101010111111010101011001100111100011110
 * C2 D2 = 11000011001100101010101111110101010110011001111000111101
 * C3 D3 = 00001100110010101010111111110101011001100111100011110101
 * C4 D4= 0011001100101010101111111100 0101100110011110001111010101
 * C5 D5= 11001100101010101111111100000110011001111000111101010101
 * C6 D6 = 00110010101010111111110000111001100111100011110101010101
 * C7 D7 = 11001010101011111111000011000110011110001111010101010110
 * C8 D8 = 00101010101111111100001100111001111000111101010101011001
 * C9 D9 = 01010101011111111000011001100011110001111010101010110011
 * C10D10= 01010101111111100001100110011111000111101010101011001100
 * C11 D11 = 01010111111110000110011001011100011110101010101100110011
 * C12 D12 = 01011111111000011001100101010001111010101010110011001111
 * C13D13 = 01111111100001100110010101010111101010101011001100111100
 * C14 D14 = 11111110000110011001010101011110101010101100110011110001
 * C15D15 = 11111000011001100101010101111010101010110011001111000111
 * C16D16 = 11110000110011001010101011110101010101100110011110001111

Now apply “Compression D-box” on C1D1 =1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110 Table : C1D1

Table : Compression D-box

Now


 * 1) select that bits from Table : C1D1  which position number present in Compression D-box.
 * 2) arrange them according to the order of Table : Compression D-box value

 

After dropping and re-arranged ,

Finally we get,


 * K1 = 000110 110000 001011 101111 111111 000111 000001 110010

Applying he same process on C2 D2,C3 D3 ,C4 D4,C5 D5 ,C6 D6 ,C7 D7 ,C8 D8 ,C9 D9 ,C10D10,C11 D11 ,C12 D12 ,C13D13, C14 D14, C15D15,C16D16 and create keys respectively.


 * 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
 * K15 = 101111 111001 000110 001101 001111 010011 111100 001010
 * K16 = 110010 110011 110110 001011 000011 100001 011111 110101