Professional Documents
Culture Documents
www.crypto-textbook.com
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.
• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES
• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES
Cryptology
Cryptography Cryptanalysis
• 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.
Example:
• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES
• L and R swapped again at the end of the cipher, i.e., after round 16
followed by a final permutation
• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES
• Bitwise Permutations.
• Inverse operations.
• Described by tables IP and IP-1.
• 4 Steps:
1. Expansion E
2. XOR with round key
3. S-box substitution
4. Permutation
1. Expansion E
• main purpose:
increases diffusion
!
• !
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)
• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES
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
IP
+ F + F
• Introduction to DES
• Overview of the DES Algorithm
• Internal Structure of DES
• Decryption
• Security of DES
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!
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
• 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.
IP = { 2, 6, 3, 1, 4, 8, 5 , 7 }
IP -1= { 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}
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}
• 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}
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
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
• 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)
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.
• 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.
• 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
• 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.
• 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:
• 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.
• 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
R1 = L0 f(R0 , K1 )
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.
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.