DES Encryption

advertisement
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
π‘¬π’π’„π’“π’šπ’‘π’•π’†π’… π‘΄π’†π’”π’”π’‚π’ˆπ’† =
Trade your encrypted message and your secret key with someone in class and decrypt their message
using their key. What does their message say?
Download