# DES Encryption

```CSCI 440 – Computer Security – DES Algorithm
Encrypt a message of your choice up to 16 bits in length (2 characters as ASCII) using 2 rounds of a
simplified DES. You will first create a 16 bit key (2 characters as ASCII) for the encryption/decryption
process. Once encrypted trade your key and ciphertexts and decrypt the characters.
πππ π πππ (π΄ππΆπΌπΌ) =
πππ π πππ (π΅πππππ¦) =
Step 1. Create subkeys from the 16 bit key, πΎ using the following tables for permutations and shift
schedule. Eliminate the bits using the same method as DES.
πΎ (π΄ππΆπΌπΌ) =
πΎ (π΅πππππ¦) =
ππΆ1
12
10
15
11
5 14 1
2 6 9
4 13 7
3
ππΆ1(πΎ) =
Split ππΆ1(πΎ) into 2 halves and left rotation on schedule.
πβπππ‘ ππβπππ’ππ
Round 1 1
Round 2 3
πππ’ππ 1 πΏπππ‘ =
πππ’ππ 1 πππβπ‘ =
πππ’ππ 2 πΏπππ‘ =
πππ’ππ 2 πππβπ‘ =
Concatenate Round 1 Left and Right and permute using ππΆ2 to create ππ’ππππ¦1 . Do the same for
ππ’ππππ¦2 using Round 2 Left and Right.
ππΆ2
6 11
13 3
1 10
ππ’ππππ¦1
4 8
12 5
2 9
=
ππ’ππππ¦2 =
Step 2. Permute message using Initial Permutation, πΌπ.
πΌπ
2
12
5
11
14
8
13
1
6
16
3
15
10
4
9
7
πΌπ πππ π’ππ‘ =
Split IP Result into left and right halves.
πΏπππ‘ =
πππβπ‘ =
Round 1
Step 3. Expansion and process ππ’ππππ¦1
Expansion: Expand πππβπ‘ using Expansion table, πΈ below
πΈ
8 1 2 3
4 5 4 5
6 7 8 1
πΈπ₯ππππ πππ πππ π’ππ‘ =
XOR with ππ’ππππ¦1
π1 ⊕ ππ’ππππ¦1 =
Substitution: Apply Substitution with S-boxes on each 6 bit Left and Right halves of 12-bit XORed result.
π-π΅ππ₯1 (Left)
0π¦π¦π¦π¦0
0π¦π¦π¦π¦1
1π¦π¦π¦π¦0
1π¦π¦π¦π¦1
π₯0000π₯
0100
1101
0001
0110
π₯0001π₯
1011
0000
0100
1011
π₯0010π₯ π₯0011π₯
0010
1110
1011
0111
1011
1101
1101
1000
π₯0100π₯
1111
0100
1100
0001
π₯0101π₯
0000
1001
0011
0100
π₯0110π₯ π₯0111π₯
1000
1101
0001
1010
0111
1110
1010
0111
0π¦π¦π¦π¦0
0π¦π¦π¦π¦1
1π¦π¦π¦π¦0
1π¦π¦π¦π¦1
π₯1000π₯
0011
1110
1010
1001
π₯1001π₯
1100
0011
1111
0101
π₯1010π₯
1001
0101
0110
0000
π₯1011π₯
0111
1100
1000
1111
π₯1100π₯
0101
0010
0000
1110
π₯1101π₯
1010
1111
0101
0010
π₯1110π₯
0110
1000
1001
0011
0π¦π¦π¦π¦0
0π¦π¦π¦π¦1
1π¦π¦π¦π¦0
1π¦π¦π¦π¦1
π₯0000π₯
1101
0001
0111
0010
π₯0001π₯
0010
1111
1011
0001
π₯0010π₯ π₯0011π₯
1000
0100
1101
1000
0100
0001
1110
0111
π₯0100π₯
0110
1010
1001
0100
π₯0101π₯
1111
0011
1100
1010
π₯0110π₯ π₯0111π₯
1011
0001
0111
0100
1110
0010
1000
1101
0π¦π¦π¦π¦0
0π¦π¦π¦π¦1
1π¦π¦π¦π¦0
1π¦π¦π¦π¦1
π₯1000π₯
1010
1100
0000
1111
π₯1001π₯
1001
0101
0110
1100
π₯1010π₯
0011
0110
1010
1001
π₯1100π₯
0101
0000
1111
0011
π₯1101π₯
0000
1110
0011
0101
π₯1110π₯
1100
1001
0101
0110
π₯1111π₯
0001
0110
0010
1100
π-π΅ππ₯2 (Right)
π₯1011π₯
1110
1011
1101
0000
ππ’ππ π‘ππ‘π’π‘πππ πππ π’ππ‘ (8-πππ‘π ) =
Permutation: Permute of the ππ’ππ π‘ππ‘π’π‘πππ πππ π’ππ‘ using π-πππ₯
π-π΅ππ₯
6 4 7 3
5 1 8 2
πππ π’ππ‘ =
XOR πππ π’ππ‘ with πΏπππ‘
πΆππβπππ‘ππ₯π‘ =
π₯1111π₯
0111
0010
1000
1011
Round 2
Swap πΆππβπππ‘ππ₯π‘ and πππβπ‘. That is πΆππβπππ‘ππ₯π‘ becomes the new Right Side and πππβπ‘ becomes the
new πΏπππ‘
πΏπππ‘ =
πππβπ‘ =
Repeat Expansion, Substitution and Permutation steps on πππβπ‘ using ππ’ππππ¦2 .
πΈπ₯ππππ πππ πππ π’ππ‘ =
π1 ⊕ ππ’ππππ¦2 =
ππ’ππ π‘ππ‘π’π‘πππ πππ π’ππ‘ =
πππππ’π‘ππ‘πππ πππ π’ππ‘ =
XOR πππππ’π‘ππ‘πππ πππ π’ππ‘ and πΏπππ‘
πΆππβπππ‘ππ₯π‘ =
Concatenate πΆππβπππ‘ππ₯π‘ and πππβπ‘
πππ π’ππ‘ =
Step 4. Permute the ciphertext πππ π’ππ‘ with πΌπ−1
πΌπ−1
14
9
12
10
1
3
4
2
11
16
13
15
8
6
5
7
π¬ππππππππ π΄ππππππ =