You are on page 1of 67

Cryptography

Lecture Five & Six

Data Encryption Standard


(DES)
Understanding Cryptography – A Textbook for
Students and Practitioners
by Christof Paar and Jan Pelzl

www.crypto-textbook.com

Chapter 3 – The Data Encryption Standard (DES)


ver. Nov 26, 2010

These slides were prepared by Markus Kasper, Christof Paar and Jan Pelzl
Some legal stuff (sorry): Terms of Use

• The slides can used free of charge. All copyrights for the slides remain with
the authors.
• The title of the accompanying book “Understanding Cryptography” by
Springer and the author’s names must remain on each slide.
• If the slides are modified, appropriate credits to the book authors and the
book title must remain within the slides.
• It is not permitted to reproduce parts or all of the slides in printed form
whatsoever without written consent by the authors.

3/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


Content of this Chapter

• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES

4/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


Content of this Chapter

• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES

5/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Classification of DES in the Field of Cryptology

Cryptology

Cryptography Cryptanalysis

Symmetric Ciphers Asymmetric Ciphers Protocols

Stream Ciphers Block Ciphers

You are here!

6/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Facts

• Data Encryption Standard (DES) encrypts blocks of size 64 bit.


• Developed by IBM based on the cipher Lucifer under influence of the National
Security Agency (NSA), the design criteria for DES have not been published
• Standardized 1977 by the National Bureau of Standards (NBS) today called
National Institute of Standards and Technology (NIST)
• Most popular block cipher for most of the last 30 years.
• By far best studied symmetric algorithm.
• Nowadays considered insecure due to the small key length of 56 bit.
• But: 3DES yields very secure cipher, still widely used today.
• Replaced by the Advanced Encryption Standard (AES) in 2000

• For a more detailed history see Chapter 3.1 in Understanding Cryptography

7/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Block Cipher Primitives: Confusion and Diffusion

• Claude Shannon: There are two primitive operations with which strong encryption
algorithms can be built:
1. Confusion: An encryption operation where the relationship between key
and ciphertext is obscured.
Today, a common element for achieving confusion is substitution, which is
found in both AES and DES.

2. Diffusion: An encryption operation where the influence of one plaintext


symbol is spread over many ciphertext symbols with the goal of hiding
statistical properties of the plaintext.
A simple diffusion element is the bit permutation, which is frequently used
within DES.

• Both operations by themselves cannot provide security. The idea is to concatenate


confusion and diffusion elements to build so called product ciphers.

8/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Product Ciphers

• Most of today‘s block ciphers are product ciphers as they consist of


rounds which are applied repeatedly to the data.

• Can reach excellent diffusion: changing of one bit of plaintext


results on average in the change of half the output bits.

Example:

single bit flip many bit flips

9/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


Content of this Chapter

• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES

10/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Overview of the DES Algorithm

• Encrypts blocks of size 64 bits.


• Uses a key of size 56 bits.
• Symmetric cipher: uses same key for encryption and decryption
• Uses 16 rounds which all perform the identical operation
• Different subkey in each round derived from main key

11/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 The DES Feistel Network (1)

• DES structure is a Feistel network

• Advantage: encryption and decryption


differ only in keyschedule

• Bitwise initial permutation, then 16 rounds


1. Plaintext is split into 32-bit halves Li and Ri
2. Ri is fed into the function f, the output of which is then XORed with Li
3. Left and right half are swapped
• Rounds can be expressed as:

12/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 The DES Feistel Network (2)

• L and R swapped again at the end of the cipher, i.e., after round 16
followed by a final permutation

13/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


Content of this Chapter

• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES

14/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Initial and Final Permutation

• Bitwise Permutations.
• Inverse operations.
• Described by tables IP and IP-1.

Initial Permutation Final Permutation

15/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 The f-Function

• main operation of DES


• f-Function inputs:
Ri-1 and round key ki

• 4 Steps:
1. Expansion E
2. XOR with round key
3. S-box substitution
4. Permutation

16/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 The Expansion Function E

1. Expansion E
• main purpose:
increases diffusion
!

17/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Add Round Key

2. XOR Round Key

• Bitwise XOR of the round key and


the output of the expansion
function E

• Round keys are derived from the


main key in the DES keyschedule
(in a few slides)

18/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 The DES S-Boxes
3. S-Box substitution
• Eight substitution tables.
• 6 bits of input, 4 bits of output.
• Non-linear and resistant to differential
cryptanalysis.
• Crucial element for DES security!
• Find all S-Box tables and S-Box design criteria
in Understanding Cryptography Chapter 3.

19/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 The Permutation P
4. Permutation P
• Bitwise permutation.
• Introduces diffusion.
• Output bits of one S-Box effect several S-Boxes
in next round
• Diffusion by E, S-Boxes and P guarantees that
after Round 5 every bit is a function of each key
bit and each plaintext bit.

20/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Key Schedule (1)

• !
Derives 16 round keys (or subkeys) ki of 48 bits each from the original 56 bit key.
• The input key size of the DES is 64 bit: 56 bit key and 8 bit parity:

1) PC-1
• Parity bits are removed in a first permuted choice PC-1:
(note that the bits 8, 16, 24, 32, 40, 48, 56 and 64 are not used at all)

21/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Key Schedule (2)
2) Split
• Split key into 28-bit halves C0 and D0.

• In rounds i = 1, 2, 9 ,16, the two halves are each


rotated left by one bit.
3) Left Rotate (1/2)
• In all other rounds where the two halves are each
rotated left by two bits.
4) PC-2
• In each round i permuted choice PC-2
selects a permuted subset of 48 bits of Ci and Di as
round key ki, i.e. each ki is a permutation of k!

• Note: The total number of rotations:


4 x 1 + 12 x 2 = 28  D0 = D16 and C0 = C16!
22/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl
Content of this Chapter

• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES

23/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Decryption (1)
• In Feistel ciphers only the keyschedule has
to be modified for decryption.
• Generate the same 16 round keys in reverse
order.
(for a detailed discussion on why this works
see Understanding Crptography Chapter 3)

• Reversed key schedule:


As D0=D16 and C0=C16 the first round key can
be generated by applying PC-2 right after PC-
1 (no rotation here!).
All other rotations of C and D can be reversed
to reproduce the other round keys resulting in:
• No rotation in round 1.
• One bit rotation to the right in rounds 2, 9
and 16.
• Two bit rotations to the right in all other
rounds.
24/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl
 Decryption (2)

X Y
R1(d) reverses the R16
IP IP R16(d) reverses the R1

R1(e) R1(d)

R2(e) R2(d)
.. ..
. .
R15(e) R15(d)

R16(e) R16(d)

IP-1 IP-1

Y X

25/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Decryption (3) Y
64

IP

L15(e) R15(e) L0(d) R0(d)


32 32 32
32
K16 K16

+ F + F

L16(e) R16(e) L1(d) R1(d)

1) L0(d) = R16(e) : R0(d) = L16(e) Direct


IP-1 1) L1(d) = R15(e) : Direct

64 1) Prove that: R1(d) = L15(e)


Prove
Y R1(d) = L0(d) + F(K16+ R0(d))
R1(d) = R16(e) + F(K16+ R0(d))
R1(d) = L15(e) + F(K16, R15(e)) + F(K16+ R0(d))
R1(d) = L15(e) + F(K16, R15(e)) + F(K16+ R15(e))= L15(e)

26/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


Content of this Chapter

• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES

27/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Security of DES

• After proposal of DES two major criticisms arose:


1. Key space is too small (256 keys)
2. S-box design criteria have been kept secret: Are there any hidden
analytical attacks (backdoors), only known to the NSA?
Two families of attacks:
1. Analytical Attacks: DES is highly resistent to both differential and linear
cryptanalysis, which have been published years later than the DES. This
means IBM and NSA had been aware of these attacks for 15 years!
So far there is no known analytical attack which breaks DES in realistic
scenarios.

1. Exhaustive key search: For a given pair of plaintext-ciphertext (x, y) test all
256 keys until the condition DESk-1(x)=y is fulfilled.
 Relatively easy given today’s computer technology!

28/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 History of Attacks on DES
Year Proposed/ implemented DES Attack

1977 Diffie & Hellman, (under-)estimate the costs of a key search machine

1990 Biham & Shamir propose differential cryptanalysis (247 chosen ciphertexts)

1993 Mike Wiener proposes design of a very efficient key search machine:
Average search requires 36h. Costs: $1.000.000

1993 Matsui proposes linear cryptanalysis (243 chosen ciphertexts)

Jun. 1997 DES Challenge I broken, 4.5 months of distributed search

Feb. 1998 DES Challenge II--1 broken, 39 days (distributed search)


Jul. 1998 DES Challenge II--2 broken, key search machine Deep Crack built by the Electronic Frontier
Foundation (EFF): 1800 ASICs with 24 search engines each,
Costs: $250 000, 15 days average search time (required 56h for the Challenge)

Jan. 1999 DES Challenge III broken in 22h 15min


(distributed search assisted by Deep Crack)

2006- Reconfigurable key search machine COPACOBANA developed at the Universities in


Bochum and Kiel (Germany), uses 120 FPGAs to break DES in
2008
6.4 days (avg.) at a cost of $10 000.

29/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Triple DES – 3DES

• Triple encryption using DES is often used in practice to extend the effective key
length of DES to 112. For more info on multiple encryption and effective key
lengths see Chapter 5 of Understanding Cryptography.

• Alternative version of 3DES:

Advantage: choosing k1=k2=k3 performs single DES encryption.


• No practical attack known today.
• Used in many legacy applications, i.e., in banking systems.

30/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Alternatives to DES

Algorithm I/O Bit key lengths remarks


DES ''replacement'',
AES / Rijndael 128 128/192/256
worldwide used standard
Triple DES 64 112 (effective) conservative choice
Mars 128 128/192/256 AES finalist
RC6 128 128/192/256 AES finalist
Serpent 128 128/192/256 AES finalist
Twofish 128 128/192/256 AES finalist
IDEA 64 128 patented

31/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Simplified DES

• Input (plaintext) block: 8-bits


• Output (ciphertext) block: 8-bits
• Key: 10-bits
• Rounds: 2
• Round keys generated using permutations and left shifts
• Encryption: initial permutation, round function, switch halves
• Decryption: Same as encryption, except round keys used in
opposite order
 S-DES Algorithm

IP = { 2, 6, 3, 1, 4, 8, 5 , 7 }

IP -1= { 4,1 ,3 ,5 ,7 ,2 ,8 , 6}

Simplified DES Scheme


S-DES Key generation

P10 = { 3, 5, 2, 7, 4, 10, 1, 9, 8, 6}

P8 = { 6, 3, 7, 4, 8, 5, 10, 9}

keys generation for simplified DES


S-DES Encryption Details

IP = { 2.,6, 3 , 1 , 4 , 8 , 5 , 7 }

E/P = { 4, 1, 2, 3, 2, 3, 4, 1}

P4 = { 2, 4, 3, 1}

IP -1 = { 4.,1 ,3 , 5 , 7 , 2, 8 , 6}

Simplified DES Encryption Detail


 S-Box
• S-DES (and DES) perform substitutions using S-
Boxes
• S-Box considered as a matrix: input used to select
row/column; selected element is output
• 4-bit input: bit1; bit2; bit3; bit4
• bit1 , bit4 species row (0, 1, 2 or 3 in decimal)
• bit2bit3 species column
• 2-bit output
 S-DES Example

• S-DES Example
• Plaintext: 01110010
• Key: 1010000010
• Ciphertext: 01110111
1010000010
 Simplified DES Example 1 2 3 4 5 6 7 8 9 10
P10 = { 3, 5, 2, 7, 4, 10, 1, 9, 8, 6}

Assume input 10-bit key, K, is: 1010000010


1000001100
Then the steps for generating the two 8-bit round keys,
10000 01100
K1 and K2, are:
1. Rearrange K using P10: 1000001100
00001 11000
12345 678910
2. Left shift by 1 position both the left and right halves: 00001 11000
3. Rearrange the halves with P8 to produce K1: 10100100

10100100 00001 11000


4. Left shift by 2 positions the left and right halves: 00100 00011
5. Rearrange the halves with P8 to produce K2: 01000011 00011
00100
12345 678910
K1 and K2 are used as inputs in the encryption and decryption stages.

01000011

P8 = { 6, 3, 7, 4, 8, 5, 10, 9}
 S-DES Encryption IP = { 2.,6, 3 , 1 , 4 , 8 , 5 , 7 }
Assume a 8-bit plaintext, P: 01110010. Then the steps for encryption are: 12345678
1. Apply the initial permutation, IP, on P: 10101001 01110010
2. Assume the input from step 1 is in two halves, L and R: L=1010, R=1001
10101001
3. Expand and permutate R using E/P: 11000011 1234 1234
4. XOR input from step 3 with K1: 10100100 XOR 11000011 = 01100111 1010 1001
11000011 10100100
5. Input left halve of step 4 into S-Box S0 and right halve into S-Box S1:
01100111
a. For S0: 0110 as input: b1,b4 for row, b2,b3 for column
0110 0111
Row 00, column 11 -> output is 2=10 E/P = { 4, 1, 2, 3, 2, 3, 4, 1} 10 11
c. For S1: 0111 as input: 12 34
P4 = { 2, 4, 3, 1}
Row 01, column 11 -> output is 3=11 0111
6. Rearrange outputs from step 5 (1011) using P4: 0111 1010
1101 1001
7. XOR output from step 6 with L from step 2: 0111 XOR 1010 = 1101
S0
8. Now we have the output of step 7 as the left half and the original R as the right half. 1001
1101
Switch the halves and move to round 2: 1001 1101 1234
01000011
11101011
9. E/P with right half: E/P(1101) = 11101011 10101000
10. XOR output of step 9 with K2: 11101011 XOR 01000011 = 10101000 1010 1000

11. Input to s-boxes: 10 11


12 34
a. For S0, 1010: b. Row 10, column 01 -> output is: 2=10
0111
c. For S1, 1000 d. Row 10, column 00 -> output is: 3=11 1001
1234 5678
1110 1101
12. Rearrange output from step 11 (1011) using P4: 0111
13. XOR output of step 12 with left halve from step 8: 0111 XOR 1001 = 1110 S1
01110111
14. Input output from step 13 and right halve from step 8 into inverse IP
a. Input us 1110 1101 b. Output is: 01110111 IP -1 = { 4.,1 ,3 , 5 , 7 , 2, 8 , 6}
So our encrypted result of plaintext 01110010 with key 1010000010 is: 01110111
 S-DES Decryption IP = { 2.,6, 3 , 1 , 4 , 8 , 5 , 7 }

Assume a 8-bit ciphertext, C: 01110111. Then the steps for decryption are: 12345678
1. Apply the initial permutation, IP, on C: 01110111 01110111
2. Assume the input from step 1 is in two halves, L and R: L=1110, R=1101
11101101
3. Expand and permutate R using E/P: 11101011 1234 1234
4. XOR input from step 3 with K2: 01000011 XOR 11101011 = 10101000 1110 1101
01000011
5. Input left halve of step 4 into S-Box S0 and right halve into S-Box S1: 11101011
10101000
a. For S0: 1010 as input: b1,b4 for row, b2,b3 for column
1010 1000
Row 10, column 01 -> output is 2=10 E/P = { 4, 1, 2, 3, 2, 3, 4, 1} 10 11
c. For S1: 1000 as input: 12 34
P4 = { 2, 4, 3, 1}
Row 10, column 00 -> output is 3=11 0111
6. Rearrange outputs from step 5 (1011) using P4: 0111 1110
1001 1101
7. XOR output from step 6 with L from step 2: 0111 XOR 1110 = 1001
S0
8. Now we have the output of step 7 as the left half and the original R as the right half. 1101
1001
Switch the halves and move to round 2: 1101 1001 1234 10100100
11000011
9. E/P with right half: E/P(1001) =11000011 01100111
10. XOR output of step 9 with K1: 11000011 XOR 10100100 = 01100111 0110 0111

11. Input to s-boxes: 10 11


12 34
a. For S0, 0110: b. Row 00, column 11 -> output is: 2=10
0111
c. For S1, 0111 d. Row 01, column 11 -> output is: 3=11 1101
1234 5678
1010 1001
12. Rearrange output from step 11 (1011) using P4: 0111
13. XOR output of step 12 with left halve from step 8: 0111 XOR 1101 = 1010 S1
01110010
14. Input output from step 13 and right halve from step 8 into inverse IP
a. Input us 1010 1001 b. Output is: 01110010
IP -1 = { 4.,1 ,3 , 5 , 7 , 2, 8 , 6}
So our decrypted result of ciphertext 01110111 with key 1010000010 is: 01110010
 S-DES Summery

• S-DES expressed as functions:

• Security of S-DES:
• 10-bit key, 1024 keys: brute force easy
• If know plaintext and corresponding ciphertext, can we
determine key? Very hard
 DES Encryption (Example)

• Let M be the plain text message:


M = 0123456789ABCDEF,
where M is in hexadecimal (base 16) format.

• Rewriting M in binary format, we get the 64-bit block of text:


M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
L = 0000 0001 0010 0011 0100 0101 0110 0111
R = 1000 1001 1010 1011 1100 1101 1110 1111

42/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)

• Example: Let K be the hexadecimal key


K = 133457799BBCDFF1.
• This gives us as the binary key (setting 1 = 0001, 3 = 0011,
etc., and grouping together every eight bits, of which the last
one in each group will be unused):
• K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001
• The DES algorithm uses the following steps:

43/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• The 64-bit key is permuted according to the following table, PC-1.


• Since the first entry in the table is "57", this means that the 57th bit of the original
key K becomes the first bit of the permuted key K+.
• The 49th bit of the original key becomes the second bit of the permuted key.
• The 4th bit of the original key is the last bit of the permuted key.
• Note only 56 bits of the original key appear in the permuted key.

44/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• Example: From the original 64-bit key


25 33 41 49 57

• K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111 11110001


• we get the 56-bit permutation
• K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111
• Next, split this key into left and right halves, C0 and D0, where each half has 28 bits.
• Example: From the permuted key K+, we get
• C0 = 1111000 0110011 0010101 0101111
D0 = 0101010 1011001 1001111 0001111

45/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• With C0 and D0 defined, we now create 16 blocks Cn and Dn , 1<=n<=16.


• Each pair of blocks Cn and Dn is formed from the previous pair Cn-1 and Dn-1,
respectively, for n = 1, 2, ..., 16, using the following schedule of "left shifts" of the
previous block.
• To do a left shift, move each bit one place to the left, except for the first bit, which
is cycled to the end of the block.

In rounds i = 1, 2, 9 ,16, the two halves are each rotated left by one bit.

In all other rounds where the two halves are each rotated left by two bits.

46/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• This means, for example, C3 and D3 are obtained from C2 and D2, respectively, by two left
shifts, and C16 and D16 are obtained from C15 and D15, respectively, by one left shift.
• In all cases, by a single left shift is meant a rotation of the bits one place to the left, so that
after one left shift the bits in the 28 positions are the bits that were previously in positions
2, 3,..., 28, 1.

• Example: From original pair C0 and D0 we obtain:


• C0 = 1111000011001100101010101111
D0 = 0101010101100110011110001111

• C1 = 1110000110011001010101011111 rotated left by 1 bit


D1 = 1010101011001100111100011110

• C2 = 1100001100110010101010111111 rotated left by 1 bit


D2 = 0101010110011001111000111101

• C3 = 0000110011001010101011111111 rotated left by 2 bit


D3 = 0101011001100111100011110101
47/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl
 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• C4 = 0011001100101010101111111100 • C11 = 0101011111111000011001100101


D4 = 0101100110011110001111010101 D11 = 1100011110101010101100110011
• C5 = 1100110010101010111111110000 • C12 = 0101111111100001100110010101
D5 = 0110011001111000111101010101 D12 = 0001111010101010110011001111
• C6 = 0011001010101011111111000011 • C13 = 0111111110000110011001010101
D6 = 1001100111100011110101010101 D13 = 0111101010101011001100111100
• C7 = 1100101010101111111100001100 • C14 = 1111111000011001100101010101
D7 = 0110011110001111010101010110 D14 = 1110101010101100110011110001
• C8 = 0010101010111111110000110011 • C15 = 1111100001100110010101010111
D8 = 1001111000111101010101011001 D15 = 1010101010110011001111000111
• C9 = 0101010101111111100001100110 • C16 = 1111000011001100101010101111
D9 = 0011110001111010101010110011 D16 = 0101010101100110011110001111
• C10 = 0101010111111110000110011001
D10 = 1111000111101010101011001100

48/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• We now form the keys Kn, for 1<=n<=16, by applying the following permutation table to each of the
concatenated pairs CnDn. Each pair has 56 bits, but PC-2 only uses 48 of these.
• Therefore, the first bit of Kn is the 14th bit of CnDn, The second bit the 17th, and so on, ending with the
48th bit of Kn being the 32th bit of CnDn.
• Example: For the first key we have: 11 14 17 24

C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011 0011110 0011110


• which, after we apply the permutation PC-2, becomes
K1 = 000110 110000 001011 101111 111111 000111 000001 110010
• For the other keys we have
• K2 = 011110 011010 111011 011001 110110 111100 100111100101
K3 = 010101 011111 110010 001010 010000 101100 111110 011001
K4 = 011100 101010 110111 010110 110110 110011 010100 011101
K5 = 011111 001110 110000 000111 111010 110101 001110 101000
K6 = 011000 111010 010100 111110 010100 000111 101100 101111

49/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 1: Create 16 subkeys, each of which is 48-bits long.

• K7 = 111011 001000 010010 110111 111101 100001 100010 111100


• K8 = 111101 111000 101000 111010 110000 010011 101111 111011
• K9 = 111000 001101 101111 101011 111011 011110 011110 000001
• K10 = 101100 011111 001101 000111 101110 100100 011001 001111
• K11 = 001000 010101 111111 010011 110111 101101 001110 000110
• K12 = 011101 010111 000111 110101 100101 000110 011111 101001
• K13 = 100101 111100 010111 010001 111110 101011 101001 000001
• K14 = 010111 110100 001110 110111 111100 101110 011100 111010
• K15 = 101111 111001 000110 001101 001111 010011 111100 001010
• K16 = 110010 110011 110110 001011 000011 100001 011111 110101

So much for the subkeys. Now we look at the message itself.

50/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.

Divide into L=32 & R=32


initial
Expansion (Ri-1)
permutation IP
Ri-1=Li
DES 16 Round XOR Ri-1 with Ki
F(Ri-1, K)
Inverse S-Box
permutation IP-1
Lf
Permutation
 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.
1) initial permutation IP
• There is an initial permutation IP of the 64 bits of the message data M.
• This rearranges the bits according to the following table, where the entries in
the table show the new arrangement of the bits from their initial order.
• The 58th bit of M becomes the first bit of IP.
• The 50th bit of M becomes the second bit of IP.
• The 7th bit of M is the last bit of IP.
 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.
1) initial permutation IP
Example: Applying the initial permutation to the block of text M, given previously, we get:
0 34 42 50 58

• M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010
• Here the 58th bit of M is "1", which becomes the first bit of IP.
• The 50th bit of M is "1", which becomes the second bit of IP.
• The 7th bit of M is "0", which becomes the last bit of IP.
• Next divide the permuted block IP into a left half L0 of 32 bits, and a right half R0 of 32 bits.

53/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.
2) Round i

• Example: From IP, we get L0 and R0


• L0 = 1100 1100 0000 0000 1100 1100 1111 1111 2.1 divide into L and R
R0 = 1111 0000 1010 1010 1111 0000 1010 1010
• We now proceed through 16 iterations (Round), for 1<=n<=16, using a function f which
operates on two blocks--a data block of 32 bits and a key Kn of 48 bits--to produce a
block of 32 bits.
• Then for n going from 1 to 16 we calculate:
Ln = Rn-1
Rn = Ln-1  f(Rn-1,Kn)
• This results in a final block, for n = 16, of L16R16.
• That is, in each Round, we take the Right (R) 32 bits of the previous result and make
them the Left (L) 32 bits of the current step.
• For the Right (R) 32 bits in the current step, we XOR the Left (L) 32 bits of the previous
step with the calculation f .

54/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3 f(R0,K1) 2.3.1 Expansion (E)
• Example: For n = 1, we have
• K1 = 000110 110000 001011 101111 111111 000111 000001 110010
L1 = R0 = 1111 0000 1010 1010 1111 0000 1010 1010 2.2
R1 = L0  f(R0,K1) 2.3 and 2.4
• It remains to explain how the function f works. To calculate f: 2.3
➢We first expand each block Rn-1 from 32 bits to 48 bits. 2.3.1
✓This is done by using a selection table that repeats some of the bits in Rn-1 .
✓We'll call the use of this selection table the function E. Thus E(Rn-1) has a 32 bit input
block, and a 48 bit output block.
✓Let E be such that the 48 bits of its output, written as 8 blocks of 6 bits each, are
obtained by selecting the bits in its inputs in order according to the following table:

55/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3 f(R0,K1) 2.3.1 Expansion (E)
• Thus the first three bits of E(Rn-1) are the bits in positions 32, 1 and 2 of Rn-1 while the
last 2 bits of E(Rn-1) are the bits in positions 32 and 1.

Example: We calculate E(R0) from R0 as follows: 32
• R0 = 1111 0000 1010 1010 1111 0000 1010 1010
E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101
• (Note that each block of 4 original bits has been expanded to a block of 6 output bits.)
• Next in the f calculation, we XOR the output E(Rn-1) with the key Kn:
Kn  E(Rn-1). 2.3.2 XOR

56/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3 f(R0,K1) 2.3.1 √
2.3.2 K1  E(R0)

• Example: For K1 , E(R0), we have


• K1 = 000110 110000 001011 101111 111111 000111 000001 110010
E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101
K1  E(R0) = 011000 010001 011110 111010 100001 100110 010100 100111.
• We have not yet finished calculating the function f .
• To this point we have expanded Rn-1 from 32 bits to 48 bits, using the selection table,
and XORed the result with the key Kn .

57/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3.1 √
2.3 f(R0,K1)
2.3.2 √
2.3.3 S-BOX
• We now have 48 bits, or eight groups of six bits.
• We now do something strange with each group of six bits: we use them as addresses in
tables called "S boxes".
• Each group of six bits will give us an address in a different S box. Located at that
address will be a 4 bit number. This 4 bit number will replace the original 6 bits.
• The net result is that the eight groups of 6 bits are transformed into eight groups of 4 bits
(the 4-bit outputs from the S boxes) for 32 bits total.

• To repeat, each of the functions S1, S2,..., S8, takes a 6-bit block as input and yields a
4-bit block as output. The table to determine S1 is shown and explained below:

58/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3.1 √
2.3 f(R0,K1)
2.3.2 √
2.3.3 S-BOX

• That block is the output S1(B) of S1 for the input B. For example, for input
block B = 100101 the first bit is “1" and the last bit "1" giving 11 as the row.
• This is row 3. The middle four bits are "0010". This is the binary equivalent of
decimal 2, so the column is column number 2. In row 3, column 2 appears 8.
• This determines the output; 8 is binary 1000, so that the output is 1000.
Hence S1(100101) = 0101.

59/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0 2.3.1 √
2.3 f(R0,K1) 2.3.2 √
2.3.3 S-BOX
S1 S2 S3 S4 S5 S6 S7 S8

011000 010001 011110 111010 100001 100110 010100 100111

60/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3.1 √
2.3 f(R0,K1)
2.3.2 √
2.3.3 S-BOX
• Example: For the first round, we obtain as the output of the eight S boxes:
• K1  E(R0) = 011000 010001 011110 111010 100001 100110 010100 100111.
• S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) = 0101 1100 1000 0010 1011 0101 1001 0111
• The final stage in the calculation of f is to do a permutation P of the S-box output to obtain the final
value of f:
• f = P(S1(B1)S2(B2)...S8(B8))
• The permutation P is defined in the following table. P yields a 32-bit output from a 32-bit input by
permuting the bits of the input block.

61/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data. Round 1
2) Round 1 2.2 L1=R0
2.3.1 √
2.3 f(R0,K1)
2.3.2 √
2.3.3 √
2.3.4 Permutation

• The final stage in the calculation of f is to do a permutation P of the S-box output to obtain
the final value of f: f = P(S1(B1)S2(B2)...S8(B8))
• The permutation P is defined in the following table. P yields a 32-bit output from a 32-bit
input by permuting the bits of the input block.
• In our example: From the output of the eight S boxes: 7 16 20 20

S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) = 0101 1100 1000 0010 1011 0101 1001 0111


• We get after the permutation:
f = 0010 0011 0100 1010 1010 1001 1011 1011

62/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.
2) Round 1 2.2 L1=R0 √
2.3 f(R0,K1)
• 2.4 R1 = L0  f(R0 , K1 )
The Last stage of Round 1 is:

R1 = L0  f(R0 , K1 )

L0 = 1100 1100 0000 0000 1100 1100 1111 1111



f(R0 , K1 ) = 0010 0011 0100 1010 1010 1001 1011 1011

= 1110 1111 0100 1010 0110 0101 0100 0100

63/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.
3) Inverse Permutation IP-1
• In the next round, we will have L2 = R1, which is the block we just calculated, and then
we must calculate R2 =L1  f(R1, K2), and so on for 16 rounds. At the end of the 16th
round we have the blocks L16 and R16. We then reverse the order of the two blocks into
the 64-bit block
R16L16

and apply a final permutation IP-1 as defined by the following table:

That is, the output of the algorithm has bit 40 of the preoutput block as its first bit, bit 8 as its second bit,
and so on, until bit 25 of the preoutput block is the last bit of the output.

64/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 DES Encryption (Example)
 Step 2: Encode each 64-bit block of data.
3) Inverse Permutation IP-1

• Example: If we process all 16 blocks using the method defined previously, we


get, on the 16th round,
• L16 = 0100 0011 0100 0010 0011 0010 0011 0100
R16 = 0000 1010 0100 1100 1101 1001 1001 0101
• We reverse the order of these two blocks and apply the final permutation to
• R16L16 = 00001010 01001100 11011001 10010101 01000011 01000010 00110010 00110100
• IP-1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100 00000101
which in hexadecimal format is 85E813540F0AB405.
• This is the encrypted form of M = 0123456789ABCDEF: namely, C = 85E813540F0AB405.
• Decryption is simply the inverse of encryption, following the same steps as
above, but reversing the order in which the subkeys are applied

65/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl


 Comparing Between S-DES and DES

S-DES DES
block 8-bit blocks 64-bit blocks
Key 10-bit key: 2 x 8-bit 56-bit key: 16 x 48-
round keys bit round keys
IP 8-bits IP: 64 bits
F function operates on 4 bits operates on 32 bits

S-Boxes 2 8
Round 2 16
 Lessons Learned

• DES was the dominant symmetric encryption algorithm from the mid-1970s to the
mid-1990s. Since 56-bit keys are no longer secure, the Advanced Encryption
Standard (AES) was created.

• Standard DES with 56-bit key length can be broken relatively easily nowadays
through an exhaustive key search.

• DES is quite robust against known analytical attacks: In practice it is very difficult
to break the cipher with differential or linear cryptanalysis.

• By encrypting with DES three times in a row, triple DES (3DES) is created, against
which no practical attack is currently known.

• The “default” symmetric cipher is nowadays often AES. In addition, the other four
AES finalist ciphers all seem very secure and efficient.

67/29 Chapter 3 of Understanding Cryptography by Christof Paar and Jan Pelzl

You might also like