Simplified DES
Slide deck 3. S-DES: the five encryption functions, the function f_K and F, S-boxes, key generation and a full worked encryption.
Feistel Cipher - ComputerphileComputerphile · the Feistel structure that S-DES and DES use, 8 min
1. Simplified DES (S-DES) Key Generation Solved Example in Cryptograhy by Vidya Mahesh HuddarMahesh Huddar · S-DES key generation: P10, shifts, P8, K1 and K2, 6 min
S-DES Encryption || Simplified data encryption standard(S-DES) || - Key GenerationLectures by Shreedarshan K · S-DES encryption and key generation step by step, 16 min
S - DES Decryption || Simplified data encryption standard(S-DES) || Explanation with exampleLectures by Shreedarshan K · S-DES decryption with an example (K2 first, then K1), 14 minS-DES overviewSearch on YouTube
Inputs and outputsSearch on YouTube
The S-DES encryption algorithm takes two inputs:
- an 8-bit block of plaintext (for example )
- a 10-bit key
It produces an 8-bit block of ciphertext as output.
The S-DES decryption algorithm takes an 8-bit block of ciphertext and the same 10-bit key. It produces the original 8-bit block of plaintext.
Comparison with DESSearch on YouTube
S-DES is a teaching cipher with the same structure as DES but small parameters. Professor Edward Schaefer of Santa Clara University developed it. It is not secure.
| Parameter | S-DES | DES |
|---|---|---|
| Block | 8 bits | 64 bits |
| Key | 10 bits | 56 bits |
| Subkeys | 2 subkeys of 8 bits | 16 subkeys of 48 bits |
| Rounds | 2 | 16 |
| S-boxes | 2 boxes, 4 bits in, 2 bits out | 8 boxes, 6 bits in, 4 bits out |
Think of S-DES as DES in a toy box. Every permutation, S-box and shift in S-DES has a bigger version in DES.
Five encryption functionsSearch on YouTube
The encryption algorithm involves five functions, in this order:
- An initial permutation (IP).
- A complex function . It does both permutation and substitution and depends on a key input.
- A simple permutation function SW that switches the two halves of the data.
- The function again.
- A permutation function that is the inverse of the initial permutation ().
The slide "Simplified DES Encryption Detail" shows the two blocks. Each block contains the function , with E/P, XOR with the subkey, S0, S1 and P4.
Composition of functionsSearch on YouTube
The slide writes the algorithm as a composition of functions:
where
Decryption is essentially the reverse of encryption:
Thus there are:
- Two permutation functions, IP and , with .
- Two permutation/substitution functions . Each uses one subkey.
- One switch function SW. It interchanges the left and right 4 bits, so the second operates on a different set of bits.
Pipeline: IP, , SW, , . Decryption uses the same functions with the subkey order reversed: first, then .
Initial and final permutationsSearch on YouTube
Each table entry names the input bit that goes to that output position.
| IP | 2 | 6 | 3 | 1 | 4 | 8 | 5 | 7 |
|---|
| 4 | 1 | 3 | 5 | 7 | 2 | 8 | 6 |
|---|
Slide example:
| Operation | Input | Output |
|---|---|---|
| IP | ||
The result is .
The round functionSearch on YouTube
The function f_KSearch on YouTube
Let L be the left 4 bits and R the right 4 bits of the 8-bit input. Let SK be a subkey. Then:
Here is the bit-by-bit exclusive-OR. Thus changes the left half only. The right half passes through unchanged.
Slide example: assume the output of the IP stage is . Then . Assume for some subkey. This value changes with the subkey.
Inside FSearch on YouTube
takes the right 4 bits and an 8-bit subkey:
| Step | In | Out |
|---|---|---|
| E/P (expansion/permutation) | 4 bits | 8 bits |
| XOR with the subkey | 8 bits | 8 bits |
| S0 (left 4 bits) and S1 (right 4 bits) | 4 bits each | 2 bits each |
| P4 (permutation) | 4 bits | 4 bits |
Expansion and key mixingSearch on YouTube
E/P maps the 4 input bits to 8 bits:
| E/P | 4 | 1 | 2 | 3 | 2 | 3 | 4 | 1 |
|---|
The slide arranges the 8 bits in two rows:
XOR the 8-bit subkey into these bits:
Rename these 8 bits:
| Row 1 | ||||
|---|---|---|---|---|
| Row 2 |
Row 1 goes into S-box S0. Row 2 goes into S-box S1. Each S-box gives a 2-bit output.
S-boxesSearch on YouTube
The slide gives the S-boxes in decimal:
| col 0 | col 1 | col 2 | col 3 | |
|---|---|---|---|---|
| row 0 | 1 | 0 | 3 | 2 |
| row 1 | 3 | 2 | 1 | 0 |
| row 2 | 0 | 2 | 1 | 3 |
| row 3 | 3 | 1 | 3 | 2 |
| col 0 | col 1 | col 2 | col 3 | |
|---|---|---|---|---|
| row 0 | 0 | 1 | 2 | 3 |
| row 1 | 2 | 0 | 1 | 3 |
| row 2 | 3 | 0 | 1 | 0 |
| row 3 | 2 | 1 | 0 | 3 |
To use an S-box:
- Use the first and fourth input bits as a 2-bit row number.
- Use the second and third input bits as a 2-bit column number.
- Write the entry at that row and column as 2 bits. This is the output.
Slide example: S0 entry is . S1 entry is .
Row = outer bits (1 and 4). Column = inner bits (2 and 3). S0 gives the left 2 bits. S1 gives the right 2 bits.
P4 and the switchSearch on YouTube
P4 permutes the 2 bits from S0 and the 2 bits from S1:
| P4 | 2 | 4 | 3 | 1 |
|---|
A 4-bit input leaves P4 as . The P4 output is the output of . Then XORs it into the left half.
The switch function SW interchanges the left and right halves. Thus the second , with subkey , operates on different data. The second works the same as the first. Decryption uses all the same functions, run backwards.
: E/P expands 4 bits to 8 bits. The subkey is XORed in. S0 and S1 each change 4 bits into 2 bits. P4 permutes the 4 result bits.
Key generationSearch on YouTube
Key schedule stepsSearch on YouTube
S-DES uses a 10-bit key shared between sender and receiver. The key schedule produces two 8-bit subkeys for particular stages of encryption and decryption.
- Apply P10 to the 10-bit key.
- Split the result into two 5-bit halves.
- Do a circular left shift by 1 (LS-1) on each half.
- Apply P8 to select and permute 8 of the 10 bits. The result is .
- Do a circular left shift by 2 more (LS-2) on each half from step 3.
- Apply P8 again. The result is .
| P10 | 3 | 5 | 2 | 7 | 4 | 10 | 1 | 9 | 8 | 6 |
|---|
| P8 | 6 | 3 | 7 | 4 | 8 | 5 | 10 | 9 |
|---|
Subkey K1Search on YouTube
Slide example key: .
P10 takes bits of . The result is .
| Operation | First half | Second half |
|---|---|---|
| After P10 | ||
| After LS-1 |
P8 takes bits of :
Subkey K2Search on YouTube
Take the output of LS-1 and shift each half by 2 more positions:
| Operation | First half | Second half |
|---|---|---|
| After LS-1 | ||
| After LS-2 |
P8 on gives:
Shift pattern: 1 bit, then 2 more bits. Each shift is circular and applies to each 5-bit half separately.
Tables to memorize: IP = 2 6 3 1 4 8 5 7. = 4 1 3 5 7 2 8 6. P10 = 3 5 2 7 4 10 1 9 8 6. P8 = 6 3 7 4 8 5 10 9. E/P = 4 1 2 3 2 3 4 1. P4 = 2 4 3 1.
Worked encryptionSearch on YouTube
Round 1Search on YouTube
The last two slides run one full encryption. Key: , so and . Plaintext: .
| Step | Value |
|---|---|
| Plaintext | |
| After IP | , so and |
| E/P of | |
| XOR | |
| S0 on | row , column , entry , output |
| S1 on | row , column , entry , output |
| P4 of | |
| XOR with | |
| output |
Switch and round 2Search on YouTube
SW gives and .
| Step | Value |
|---|---|
| E/P of | |
| XOR | |
| S0 on | row , column , entry , output |
| S1 on | row , column , entry , output |
| P4 of | |
| XOR with | |
| Add the right side ("+RS") |
Final permutationSearch on YouTube
takes bits of . These bits are . So:
Short trace: IP gives . gives . SW gives . gives . gives .
DecryptionSearch on YouTube
Reverse subkey orderSearch on YouTube
Decryption uses the same functions, with the subkeys in reverse order:
- Apply IP to the ciphertext.
- Apply with .
- Apply SW.
- Apply with .
- Apply .
| Direction | First key | Second key |
|---|---|---|
| Encryption | ||
| Decryption |
Decryption of with this key gives again.
The exam can ask for a small encryption by hand. Write all the tables at the top of your rough sheet first. Then check your answer: decrypt it and compare with the plaintext.
Role of each partSearch on YouTube
| Part | Type | Job |
|---|---|---|
| IP, | Permutation | Mix the bits at the start and undo the mix at the end |
| E/P | Expansion | Give each S-box bits from the whole 4-bit half |
| XOR with subkey | Key mixing | Make the output depend on the key |
| S0, S1 | Substitution | The only nonlinear step |
| P4 | Permutation | Spread the S-box output bits |
| SW | Permutation | Make the second act on the other half |
Quick self-testSearch on YouTube
What are the block size and key size of S-DES?
The block is 8 bits. The key is 10 bits. The key schedule makes two 8-bit subkeys, and .
Name the five functions of S-DES encryption in order.
IP, with , SW, with , and . So ciphertext .
Give the IP and inverse IP tables.
IP = 2 6 3 1 4 8 5 7. = 4 1 3 5 7 2 8 6. The slide example maps to and back.
Define f_K and say what happens to each half.
. The left half is XORed with the output of . The right half does not change.
How is F(R, SK) built?
E/P (4 1 2 3 2 3 4 1) expands 4 bits to 8 bits. XOR with the 8-bit subkey. The left 4 bits go to S0 and the right 4 bits go to S1. Each S-box gives 2 bits. P4 (2 4 3 1) permutes the 4 bits.
How do you read an S-box?
Bits 1 and 4 give the row. Bits 2 and 3 give the column. The entry, written as 2 bits, is the output.
Produce K1 and K2 from key 1010000010.
P10 gives . LS-1 gives . P8 gives . LS-2 gives . P8 gives .
Encrypt plaintext 11110011 with key 1010000010.
IP gives . Round 1: E/P , XOR , S0 , S1 , P4 , XOR gives . SW gives . Round 2: E/P , XOR , S0 , S1 , P4 , XOR gives . .
How does decryption differ from encryption?
The functions are the same. The subkey order is reversed: the first uses and the second uses .
- S-DES: 8-bit block, 10-bit key, two 8-bit subkeys. The structure is the same as DES.
- Encryption: IP, , SW, , . .
- : E/P, XOR with the subkey, S0 and S1 (outer bits = row, inner bits = column), then P4.
- Key schedule: P10, LS-1, P8 gives . LS-2, P8 gives . Key gives and .
- Plaintext with this key encrypts to . Decryption uses first, then .