Data Encryption Standard

Work in progress. This note is still being written and incomplete.

Aka. DES. Published in 1975 and standardized in 1977. Superseded by AES (1998/2001). The interactive guide to DES visualizes the Feistel rounds and key schedule.

DES is a Feistel cipher. It splits each block into 2 halves and runs a keyed round function many times, so the same structure encrypts and decrypts.

Design Parameters

  • Block length n=64n = 64 bits.
  • Number of rounds r=16r = 16.
  • Round function combining substitution and permutation.
  • 16 round keys of 48 bits each, from a subkey generation algorithm.
  • Secret key length 56 bits.

Permutation Tables

DES is built from fixed lookup tables. Every one is read the same way. Output bit ii is copied from the input bit whose position is the ii-th table entry.

  • Reordering
    A table that lists every input position exactly once drops and duplicates nothing. IP\text{IP}, IP1\text{IP}^{-1}, and PP are of this kind.
  • Expansion
    A table longer than its input repeats some input positions. EE does this, listing 48 positions over a 32-bit input.
  • Compression
    A table shorter than its input omits some positions. PC-1\text{PC-1} and PC-2\text{PC-2} do this, dropping key bits.

Substitution Boxes

An S-box maps 6 input bits to 4 output bits through a fixed table of 4 rows and 16 columns.

The outer 2 bits (first and last) select 1 of 4 rows. The middle 4 bits select 1 of 16 columns. The table entry at that row and column is the 4-bit output.

In DESm there are 8 S-boxes, and they all are different, fixed, and published in the standard. They are the only non-linear step in DES and the most security-critical component.

S-box 1:

0123456789101112131415
row 001441312151183106125907
row 110157414213110612119538
row 224114813621115129731050
row 331512824917511314100613

Take input 011011011011.

  • Outer bits 00 and 11 give row 01=101 = 1.
  • Middle bits 11011101 give column 1313.
  • Row 11, column 1313 holds 55, so the output is 01010101.

Round Function

The round function f(R,ki)f(R, k_i) takes a 32-bit half RR and the 48-bit round key kik_i, returning 32 bits. Round ii applies it to the previous round’s right half Ri1R_{i-1}. It is computed in order.

Expansion Permutation

Expands the 32 input bits to 48 by the expansion table (EE). Split the 32 input bits into 8 consecutive groups of 4. Output block jj is group jj plus 1 bit borrowed from each side: the last bit of group j1j-1 in front, the first bit of group j+1j+1 behind, wrapping at the ends. Each block is 6 bits and feeds 1 S-box.

E
  1. 1 32
  2. 2 1
  3. 3 2
  4. 4 3
  5. 5 4
  6. 6 5
  7. 7 4
  8. 8 5
  9. 9 6
  10. 10 7
  11. 11 8
  12. 12 9
  13. 13 8
  14. 14 9
  15. 15 10
  16. 16 11
  17. 17 12
  18. 18 13
  19. 19 12
  20. 20 13
  21. 21 14
  22. 22 15
  23. 23 16
  24. 24 17
  25. 25 16
  26. 26 17
  27. 27 18
  28. 28 19
  29. 29 20
  30. 30 21
  31. 31 20
  32. 32 21
  33. 33 22
  34. 34 23
  35. 35 24
  36. 36 25
  37. 37 24
  38. 38 25
  39. 39 26
  40. 40 27
  41. 41 28
  42. 42 29
  43. 43 28
  44. 44 29
  45. 45 30
  46. 46 31
  47. 47 32
  48. 48 1

Cell index is the output bit. Cell value is the input bit. Highlighted middle 4 columns are the group of 4. The unhighlighted first and last columns are the bits borrowed from the neighbouring groups.

Intermediate Steps

  • Key mixing
    XOR the 48-bit expanded value with the round key kik_i.
  • Split
    Cut the 48-bit result into 8 blocks of 6 bits, one per S-box.
  • Substitution
    Each S-box maps its 6-bit block to 4 bits, by the lookup defined above.
  • Combine
    Concatenate the eight 4-bit outputs into 32 bits.

Permutation

Permute the 32 bits by the P-box. Each S-box output bit is scattered to a different S-box’s input group in the next round, so the 4 bits from one S-box never stay together.

P
  1. 1 16
  2. 2 7
  3. 3 20
  4. 4 21
  5. 5 29
  6. 6 12
  7. 7 28
  8. 8 17
  9. 9 1
  10. 10 15
  11. 11 23
  12. 12 26
  13. 13 5
  14. 14 18
  15. 15 31
  16. 16 10
  17. 17 2
  18. 18 8
  19. 19 24
  20. 20 14
  21. 21 32
  22. 22 27
  23. 23 3
  24. 24 9
  25. 25 19
  26. 26 13
  27. 27 30
  28. 28 6
  29. 29 22
  30. 30 11
  31. 31 4
  32. 32 25

Key Schedule

The 64-bit input key has every 8th bit as a parity bit, so the effective key length is 56 bits.

Permuted Choice 1

Selects 56 bits from the 64-bit key, skipping the 8 parity bits, and permutes them. The first 28 outputs form C0C_0, the last 28 form D0D_0.

PC-1
  1. 1 57
  2. 2 49
  3. 3 41
  4. 4 33
  5. 5 25
  6. 6 17
  7. 7 9
  8. 8 1
  9. 9 58
  10. 10 50
  11. 11 42
  12. 12 34
  13. 13 26
  14. 14 18
  15. 15 10
  16. 16 2
  17. 17 59
  18. 18 51
  19. 19 43
  20. 20 35
  21. 21 27
  22. 22 19
  23. 23 11
  24. 24 3
  25. 25 60
  26. 26 52
  27. 27 44
  28. 28 36
  29. 29 63
  30. 30 55
  31. 31 47
  32. 32 39
  33. 33 31
  34. 34 23
  35. 35 15
  36. 36 7
  37. 37 62
  38. 38 54
  39. 39 46
  40. 40 38
  41. 41 30
  42. 42 22
  43. 43 14
  44. 44 6
  45. 45 61
  46. 46 53
  47. 47 45
  48. 48 37
  49. 49 29
  50. 50 21
  51. 51 13
  52. 52 5
  53. 53 28
  54. 54 20
  55. 55 12
  56. 56 4

56 entries drawn from the 64-bit key. Positions 8, 16, 24, 32, 40, 48, 56, 64 (parity) never appear.

Rotation

Each round left-rotates Ci1C_{i-1} and Di1D_{i-1} by pip_i positions to get Ci,DiC_i, D_i, where pip_i is 1 or 2 as fixed by the schedule below.

CiC_i and DiD_i are 28-bit registers. The 16 shifts sum to 28, so a full left-rotation brings C16,D16C_{16}, D_{16} back to C0,D0C_0, D_0. Decryption uses this to walk the schedule backwards by right-rotating instead.

  1. 1 1
  2. 2 1
  3. 3 2
  4. 4 2
  5. 5 2
  6. 6 2
  7. 7 2
  8. 8 2
  9. 9 1
  10. 10 2
  11. 11 2
  12. 12 2
  13. 13 2
  14. 14 2
  15. 15 2
  16. 16 1

Cell index is the round number i. Cell value is pᵢ, the left-rotation amount for that round.

Permuted Choice 2

Rejoins Ci,DiC_i, D_i into 56 bits, then selects and permutes 48 of them to produce round key kik_i. The 8 unused positions are 9, 18, 22, 25, 35, 38, 43, and 54.

PC-2
  1. 1 14
  2. 2 17
  3. 3 11
  4. 4 24
  5. 5 1
  6. 6 5
  7. 7 3
  8. 8 28
  9. 9 15
  10. 10 6
  11. 11 21
  12. 12 10
  13. 13 23
  14. 14 19
  15. 15 12
  16. 16 4
  17. 17 26
  18. 18 8
  19. 19 16
  20. 20 7
  21. 21 27
  22. 22 20
  23. 23 13
  24. 24 2
  25. 25 41
  26. 26 52
  27. 27 31
  28. 28 37
  29. 29 47
  30. 30 55
  31. 31 30
  32. 32 40
  33. 33 51
  34. 34 45
  35. 35 33
  36. 36 48
  37. 37 44
  38. 38 49
  39. 39 39
  40. 40 56
  41. 41 34
  42. 42 53
  43. 43 46
  44. 44 42
  45. 45 50
  46. 46 36
  47. 47 29
  48. 48 32

48 entries over the 56-bit CᵢDᵢ. Output bit 1 takes bit 14 of CᵢDᵢ.

Encryption

DES encrypts one 64-bit block through 5 stages, using the 16 round keys k1,,k16k_1, \dots, k_{16} from the key schedule and the round function ff.

Initial Permutation

Apply IP\text{IP} to the 64-bit input block, reordering all 64 bits.

IP
  1. 1 58
  2. 2 50
  3. 3 42
  4. 4 34
  5. 5 26
  6. 6 18
  7. 7 10
  8. 8 2
  9. 9 60
  10. 10 52
  11. 11 44
  12. 12 36
  13. 13 28
  14. 14 20
  15. 15 12
  16. 16 4
  17. 17 62
  18. 18 54
  19. 19 46
  20. 20 38
  21. 21 30
  22. 22 22
  23. 23 14
  24. 24 6
  25. 25 64
  26. 26 56
  27. 27 48
  28. 28 40
  29. 29 32
  30. 30 24
  31. 31 16
  32. 32 8
  33. 33 57
  34. 34 49
  35. 35 41
  36. 36 33
  37. 37 25
  38. 38 17
  39. 39 9
  40. 40 1
  41. 41 59
  42. 42 51
  43. 43 43
  44. 44 35
  45. 45 27
  46. 46 19
  47. 47 11
  48. 48 3
  49. 49 61
  50. 50 53
  51. 51 45
  52. 52 37
  53. 53 29
  54. 54 21
  55. 55 13
  56. 56 5
  57. 57 63
  58. 58 55
  59. 59 47
  60. 60 39
  61. 61 31
  62. 62 23
  63. 63 15
  64. 64 7

Cell index is the output bit. Cell value is the input bit it copies. Output bit 1 takes input bit 58.

Split

Take the first 32 permuted bits as L0L_0, the last 32 as R0R_0. Reading the entries, every even-positioned input bit lands in L0L_0 and every odd-positioned bit lands in R0R_0.

Feistel Rounds

Run 16 rounds. Round ii sets Li=Ri1L_i = R_{i-1} and Ri=Li1f(Ri1,ki)R_i = L_{i-1} \oplus f(R_{i-1}, k_i).

Rejoin

Concatenate as R16L16R_{16} L_{16}, halves swapped, into a 64-bit block. The swap makes decryption run the exact same steps as encryption.

Final Permutation

Apply IP1\text{IP}^{-1} to produce the ciphertext block. It is the exact inverse of IP\text{IP}. Input bit 58 sits at position 1 after IP\text{IP}, so IP1\text{IP}^{-1} has 58 as its 40th entry, sending it back. Applying it after the rounds cancels the initial reordering.

IP⁻¹
  1. 1 40
  2. 2 8
  3. 3 48
  4. 4 16
  5. 5 56
  6. 6 24
  7. 7 64
  8. 8 32
  9. 9 39
  10. 10 7
  11. 11 47
  12. 12 15
  13. 13 55
  14. 14 23
  15. 15 63
  16. 16 31
  17. 17 38
  18. 18 6
  19. 19 46
  20. 20 14
  21. 21 54
  22. 22 22
  23. 23 62
  24. 24 30
  25. 25 37
  26. 26 5
  27. 27 45
  28. 28 13
  29. 29 53
  30. 30 21
  31. 31 61
  32. 32 29
  33. 33 36
  34. 34 4
  35. 35 44
  36. 36 12
  37. 37 52
  38. 38 20
  39. 39 60
  40. 40 28
  41. 41 35
  42. 42 3
  43. 43 43
  44. 44 11
  45. 45 51
  46. 46 19
  47. 47 59
  48. 48 27
  49. 49 34
  50. 50 2
  51. 51 42
  52. 52 10
  53. 53 50
  54. 54 18
  55. 55 58
  56. 56 26
  57. 57 33
  58. 58 1
  59. 59 41
  60. 60 9
  61. 61 49
  62. 62 17
  63. 63 57
  64. 64 25

Decryption

DES decrypts with the exact same algorithm and tables, feeding the round keys in reverse order k16,,k1k_{16}, \dots, k_1.

The Feistel round is invertible no matter what ff computes. Given Li=Ri1L_i = R_{i-1} and Ri=Li1f(Ri1,ki)R_i = L_{i-1} \oplus f(R_{i-1}, k_i), the previous half is recovered as Li1=Rif(Li,ki)L_{i-1} = R_i \oplus f(L_i, k_i). The final half-swap on the encryption side lines the ciphertext up so the same round formula runs unchanged.

The round keys in reverse come for free from the schedule. Right-rotating Ci,DiC_i, D_i by the same pip_i schedule regenerates kik_i from ki+1k_{i+1} without re-running PC-1.

Security Properties

  • Avalanche effect
    A single plaintext bit difference should flip about 50% of ciphertext bits. EE feeds 16 of the 32 half-bits into 2 S-boxes each, and PP scatters each S-box’s 4 output bits into different S-boxes in the next round, so a local change spreads fast.
  • Key size
    56 bits is the reason DES fell. A brute-force search averages 2552^{55} steps, feasible on dedicated hardware such as the EFF Deep Crack machine in 1998.
  • S-box strength
    The S-boxes were chosen to resist differential cryptanalysis, a technique not public until 1990.

Variations

Double DES

Encrypting twice with the same key, c2=Ek(Ek(m))c_2 = E_k(E_k(m)), adds no strength. The single 56-bit key is still found by brute force in 2552^{55} steps on average. DES is not a group, so the double encryption is not equal to a single DES under some other key. That rules out a trivial break but does not enlarge the key.

Double DES with 2 Keys

c2=Ek2(Ek1(m))c_2 = E_{k_2}(E_{k_1}(m)) with 2 independent 56-bit keys. The key space is 112 bits, but the meet-in-the-middle attack inverts the 2 layers separately and cuts the effective strength to about 2572^{57}.

Triple DES (3DES)

c=Ek3(Dk2(Ek1(m)))c = E_{k_3}(D_{k_2}(E_{k_1}(m))), effective key length 168 bits. The middle step is a decryption so that setting k1=k2=k3k_1 = k_2 = k_3 makes 3DES compute plain DES. 3DES hardware then stays interoperable with single-DES peers.

2-Key 3DES

Setting k1=k3k_1 = k_3 gives c=Ek1(Dk2(Ek1(m)))c = E_{k_1}(D_{k_2}(E_{k_1}(m))), effective key length 112 bits. The 3 forms are the standard keying options. 3 independent keys is option 1, k1=k3k_1 = k_3 is option 2, all keys equal is option 3. NIST has since deprecated 3DES in favour of AES.

Why Not Extend DES

3DES already composed DES instead of redesigning it. 3 problems remained.

  • Block size
    Still 64 bits. Birthday-bound collisions appear after about 2322^{32} blocks under 1 key, no matter the key length.
  • Composition loss
    Double DES’s 112-bit key space drops to about 2572^{57} effective strength under a meet-in-the-middle attack. Reaching close to the nominal strength needs the full 3-stage 3DES structure.
  • Speed
    3DES runs the DES round function 3 times per block, on top of DES already being tuned for 1970s hardware rather than software.

Widening DES’s key or block does not inherit its security margin. The margin comes from the specific interaction between the 16 rounds, the Feistel structure, and the 6-bit S-boxes, not from a formula that scales with the numbers. Changing any of those needs the same fresh cryptanalysis a new cipher would. NIST ran an open competition instead, which also settled decades of suspicion around the NSA’s undisclosed role in choosing the original S-boxes.

Attacking DES

A brute-force known-plaintext attack averages 2552^{55} steps given the 56-bit key.

Meet in the Middle Attack

A known-plaintext attack. Breaks a double encryption c=Ek2(Ek1(m))c = E_{k_2}(E_{k_1}(m)) whose 2 layers can be inverted independently. Trades storage for time instead of searching all 21122^{112} key pairs.

  • Take one known plaintext-ciphertext pair (m,c)(m, c).
  • For every key k1k_1, compute x=Ek1(m)x = E_{k_1}(m) and store (x,k1)(x, k_1) in a table.
  • For every key k2k_2, compute x=Dk2(c)x' = D_{k_2}(c) and look up xx' in the table.
  • Each hit x=xx = x' gives a candidate pair (k1,k2)(k_1, k_2) that agrees at the midpoint.
  • Test surviving candidates against a second known pair to drop false matches.

Take bb-bit keys. The first loop runs 2b2^b encryptions and fills a table of 2b2^b entries. The second loop runs 2b2^b decryptions. The total is 2b+2b=2b+12^b + 2^b = 2^{b+1} cipher calls, with 2b2^b storage for the table. Brute force instead tries every (k1,k2)(k_1, k_2) pair, 2b2b=22b2^b \cdot 2^b = 2^{2b} calls, with no storage. For double DES b=56b = 56, so the work drops from 21122^{112} to roughly 2572^{57}.

Linear Cryptanalysis

A known-plaintext attack, published by Matsui in 1993.

Notation. mim_i is bit ii of the plaintext, cjc_j bit jj of the ciphertext, klk_l bit ll of the key. \bigoplus is XOR taken over a chosen set of positions: II in the plaintext, JJ in the ciphertext, LL in the key. XOR of a set of bits is 1 when an odd number of them are 1, so each side of the equation is the parity of its selected bits.

A linear approximation claims these 2 parities are equal:

iImijJcj=lLkl\bigoplus_{i \in I} m_i \oplus \bigoplus_{j \in J} c_j = \bigoplus_{l \in L} k_l

The left side is built only from bits the attacker can see. The right side is 1 fixed bit, the parity of some unknown key bits. It never changes, since the key is fixed.

Example. With I={4,9}I = \{4, 9\}, J={7}J = \{7\}, L={2,5,18}L = \{2, 5, 18\} the equation reads

m4m9c7=k2k5k18m_4 \oplus m_9 \oplus c_7 = k_2 \oplus k_5 \oplus k_{18}

For a random pair the left side is 0 half the time and 1 half the time, so it says nothing about the right side. The DES S-boxes are slightly unbalanced, so for a well-chosen I,J,LI, J, L the left side equals the right side with probability 12+ε\tfrac{1}{2} + \varepsilon for some bias ε0\varepsilon \ne 0.

  • Collect NN known pairs (m,c)(m, c).
  • Compute the left side of each.
  • If the left side is 0 in more than half the pairs, the fixed right side is 0, otherwise 1.

That recovers 1 bit of information about the key, the parity k2k5k18k_2 \oplus k_5 \oplus k_{18} in the example. The answer is right with confidence that grows in NN, needing about ε2\varepsilon^{-2} pairs. Enough different equations pin down enough key-bit parities to solve for the key. Full DES falls to about 2432^{43} known pairs, below brute force but far more plaintext than an attacker usually holds.

Differential Cryptanalysis

A chosen-plaintext attack, made public by Biham and Shamir around 1990.

Works with the XOR difference of a plaintext pair m,mm, m', not the values. Fix an input difference Δm=mm\Delta m = m \oplus m' and follow the difference forward through the rounds.

  • The linear steps EE, PP, IP\text{IP}, IP1\text{IP}^{-1} satisfy g(x)g(x)=g(xx)g(x) \oplus g(x') = g(x \oplus x'). Their output difference is a fixed function of the input difference, free of the actual values and of the key.
  • An S-box is not linear. For a given input difference its output difference is not fixed, but some output differences are far more likely than others. The difference distribution table counts, for each pair of input and output differences, how many of the 64 input pairs produce it.

Chaining high-probability S-box differences across rounds gives a characteristic. This is a predicted difference through the first 15 rounds that holds with some probability pp.

  • Encrypt many plaintext pairs with input difference Δm\Delta m.
  • For each guess of the last round key feeding the active S-boxes, undo the last round and check whether the round-15 difference matches the characteristic.
  • The correct guess matches at rate pp, wrong guesses at the lower random rate. The guess with the most matches is the key.

The pair difference never depends on kk, since XORing the pair cancels the equal round-key terms. Full DES needs about 2472^{47} chosen plaintexts. The S-boxes were tuned in 1974 to resist exactly this, so the attack does not threaten DES in practice.

Written by September 16, 2026 13 min read
Was this helpful?