Skip to main content

Simplified DES Example: Step by Step

Simplified DES or S-DES is an encryption algorithm which follows feistal cipher structure. In this tutorial, we will take an example of S-DES. Let’s get started.

We need plaintext and key to start with. For this example, let’s consider 01001000 be the 8-bit plaintext and 1110001110 be the 10-bit key.

Key Generation:
The first step in S-DES process is key generation. From the 10-bit key that we give as input, it generates 2 1-bit keys called k1 and k2. Following is the process:

1.       Pass the 10-bit input key into the P10 table:

3
5
2
7
4
10
1
9
8
6

This gives: 1011001110. (For example, take the 3rd bit from input key which is 1. It becomes the first bit for our new key)
2.       Divide the new key into two halves and left shift each half’s bits by one. So by dividing we get 10110 and 01110. We perform left shift so the left most bit becomes the right most bit and remaining each bit is shifted to its left. This gives: 01101 and 11100. Or you can think of it as the left most bit is taken to the right while other bits keep their position.
3.       Pass both of these halves into P8 table as given bellow:
6
3
7
4
8
5
10
9

This gives: 01111001. This gives our first key. Second key is generated similarly.
4.       Now for Key 2 we take as input the key which was shifted by 1 in the previous process:  01101 and 11100. We shift it two times to the left: 10101, 10011.
5.       We pass this with P8 given above: 11000111. This is our key 2.
We are done with key generation part. Next is encryption:
Encryption:
1.       We pass the plaintext (01001000) which is given as input to the initial permutation table given bellow:
2
6
3
1
4
8
5
7

This gives: 10000010.
2.       We break the result into two halves (four bits each): 1000 and 0010.
3.       Pass the right half into E/P table given below:
4
1
2
3
2
3
4
1

This gives: 00010100
4.       Now XOR the result with the key 1 that we got from the key generation process:
00010100
01111001
01101101

5.       Again divide the result into two halves: 0110 and 1101. After that for both the halves, take 1st and last bit, convert it into decimal, call it row: 00 for first half. 11 for second. Take the middle two bits for both halves and call them column: 11 for first half and 10 for second. Convert them into decimal: 1st half gives row = 0, col = 3. 2nd half gives row = 3, col = 2.
6.       Identify the entry from the following s-box 0 table by selecting the first row and first column you identified in previous step and do the same with second row and column that you identified with passing it into s1:
S0

C0
C1
C2
C3
R0
1
0
3
2
R1
3
2
1
0
R2
0
2
1
3
R3
3
1
3
2
S1

C0
C1
C2
C3
R0
0
1
2
3
R1
2
0
1
3
R2
3
0
1
0
R3
2
1
0
3


This gives: 2 and 0. Converting into binary gives: 1000.

7.       Apply permutation P4 to the result:
2
4
3
1

This gives: 0001.
8.       XOR the result with the left half of what we got after passing plaintext into IP table from above:
1000
0001
1001
9.       Make a new byte by adding the result that we got in previous result to the left and right half from the IP table above to the right: 10010010. Swap them and divide into two halves: 0010 and 1001 (We are going to repeat the process for key 2).
10.   Pass the right 4 bit into the E/P Table:
4
1
2
3
2
3
4
1

11000011.
11.   XOR it with key 2:
10000010
11000011
01000001

12.   divide the result into two halves: 0100 and 0001. After that for both the halves, take 1st and last bit, convert it into decimal, call it row: 00 for first half. 01 for second. Take the middle two bits for both halves and call them column: 10 for first half and 00 for second. Convert them into decimal: 1st half gives row = 0, col = 2. 2nd half gives row = 1, col = 0.
13.   Identify the entry from the following s-box 0 table by selecting the first row and first column you identified in previous step and do the same with second row and column that you identified with passing it into s1:
S0

C0
C1
C2
C3
R0
1
0
3
2
R1
3
2
1
0
R2
0
2
1
3
R3
3
1
3
2
S1

C0
C1
C2
C3
R0
0
1
2
3
R1
2
0
1
3
R2
3
0
1
0
R3
2
1
0
3


This gives: 3 and 2. Converting into binary gives: 1110.
14.   Apply permutation P4 to the result:
2
4
3
1

This gives: 1011.
15.   XOR the result with the above swapped result:
0010
1011
1001

16.   Make a new byte by adding the result that we got in previous result to the left and right half from the swapped byte above to the right: 10010010.        
17.   Finally pass result into IP-1 Table:
4
1
3
5
7
2
8
6

11001000.

We presented an example of a simplified DES encryption. First we look at key generation process and then the encryption process.


Comments

Popular posts from this blog

HCI: Research Topic Ideas

I was reading an interesting research paper (Personal Tasks at Work: An Exploration, ACM 2017) in which the writer talks about the personal tasks that we have to do at work such as scheduling appointments, paying electricity and other bills, etc. The problem at first seems to be a social science one which has nothing to do with computer science but when looked closely the problem highlights an important aspect of our daily life that has to be sorted out using technology. The paper basically discusses those tasks and categorizes them based on frequency of occurring based on a survey. So, for example out of the 93 people who participated in the survey presented in the paper, 51% reported a need for scheduling an appointment while 33% have to coordinate their personal activities. Some will say (specially management science guys) that few of the problems can be solved by proper time management but remember that the purpose of technology is to make life easier for humans. Also, not every …

Cyber Security Awareness: for Employees

The insecurity of data and information that exists on the internet and computer networks has been a major issue for a number of businesses, organizations, and institutions; which don't invest on network and internet security training and awareness programs for their employees. Ideally, most employers rush to invest in new and expensive technologies in the name of protecting their companies online, not knowing that in most cases, the safety of a company online largely depends on the cyber security awareness of the employees. Consequently, your company's protection online starts by ensuring that your employees are well equipped with basic network safety practices and policies, so that they can assist in keeping your computers and networks safe from cyber-attacks that come in form of a virus, malware, and cyber-crime.

Different Ways to Create Cyber Security Awareness to Your Employees:
1.Authentication
The most basic network security measure that your employees need to use is a pass…