Showing posts with label DES (Data Encryption Standard). Show all posts
Showing posts with label DES (Data Encryption Standard). Show all posts
Initial and Final Permutation


Each Permtation takes a 64-bit input and permutes them according to a predefined rule.
It follows the Initial Permutation table . The table is fixed so meaning to say the 58th Bit will become the 1st Bit, 50th Bit becomes the 2nd bit, 42th Bit become the 3rd bit, so on and so forth.

For the Final Permutation, It follows the Final Permutation Table which is as follows:

In this case the 40th Bit become the 1st Bit, the 8th bit becomes the 2nd bit, 48th bit becomes the 3rd bit.
Lets take an example of a Plaintext: 123456ABCD132536
We will apply initial permutation to it.
Firstly the plain text is in HEX. We have to convert it to binary.
1 = 0001 2 = 0010 3=0011
4 = 0100 5= 0101 6=0100
7 = 0111 8 = 1000 9 = 1001
A = 1010 B = 1011 C = 1100
D = 1101 E = 1100 F = 1111
Therefore 123456ABCD132536 converted to binary would be
0001 0010 0011 0100 0101 0100 1010 1011 1100 1101 0001 0011 0010 0101 0011 0100
16 x 4 bits each = 64 bits.
1st bit = 0
2nd bit = 0
3rd bit = 0
4th bit = 1
5th bit = 0
6th bit = 0
7th bit = 1
8th bit = 0
and so on...
Now we map the bits into the first permutation table
we will get :
in this case the 58th bit is a 1 so
we place the 0 in the first bit position
next we look at the 2nd bit which is suppose to be fitted with value of the 50th bit which is also a 0
now the 3rd bit is to be fited by value from the 42th bit which has the value of 0
the 4th bit is to be fitted by value from the 34th Bit which is suppose to be the value of 1
0001
and we carry on with the rest ..
0001 0010 0011 0100 0101 0110 1010 1011 1100 1101 0001 0011 0010 0101 0011 0110
Converted To :
0001 0100 1010 0111 1101 0110 0111 1000 0001 1000 1100 1010 0001 1000 1010 1101
and now we convert this back to HEX using the table above where
0001 = 1
0100 = 4
1010 = A
0111 = 7
and so we will end up with
14A7D67818CA18AD
We will do the Final Permutation after the 16 rounds of Feistel Encryption.

Data Encryption Standard Algorithm
The DES algorithm is based on Feistel ciper.
The Encryption Process Follows three stages:
Step 1
Given a 64-Bit Plaintext P, DES first applies a fixed initial permutation (IP) to P to obtain P0 = IP(P). Express Po = Lo Ro (L for left , R for right) where L0 is the first 32 bits of P0 and Ro is the last 32 bits of Po.
Step 2
Next it will follow a 16 rounds of Feistel Encryption
Li = Ri-1
Ri = Li-1 XOR f(Ri-1,Ki)
Ki referes to the 48bit key obtain from the key K and f is the Feistel Function.
It is ok that it sounds messy to you at this stage, we will look into it in the next post.
Step 3
Switch Left and RIght to obtain R16L16 then apply the inverse permutation to obtain the ciphertext c=IP-1(R16L16).
The initial and final permutation is called P-Boxes.
It is ok that you will ask me, what are you talking about!!??? Don't worry. I asked that question when I first come over it. I will explain it later. =)

DATA ENCRYPTION STANDARD (DES)
The Data Encryption Standard (DES) is a symmetric-key block cipher published by the National Institute of Standards and Technology.
Today NIST has recommand the use of Triple DES as well as Advance Encryption Standard(AES) as DES which was published in January 1977 is no longer secure.
DES is a block cipher. It takes in 64-bit plaintext and creates a 64-bit ciphertext on the Encryption Side. It takes a 64-bit ciphertext and create a 64-bit plaintext on the decryption side.
The same key of a 56-bit cipher key is used for encryption and decryption.