Intro

DES is a symmetric key block cipher that uses the same key for both encryption and decryption, processing data in fixed-size blocks.

Note

DES encrypts 64-bit plaintext using a 56-bit key to produce a 64-bit ciphertext.

History

In 1973, the National Bureau of Standards (NBS) in the United States recognized the need for a standardized encryption method and called for proposals for what would become the DES (Data Encryption Standard). In 1977, NBS selected a modified version of an encryption algorithm called Lucifer, developed by IBM, to become DES. The National Security Agency (NSA) made modifications to Lucifer, including reducing the key length from 128 bits to 56 bits and altering the structure of the S-Box. This led to speculation that the U.S. intelligence agencies could more easily decrypt messages encrypted with DES. Despite these suspicions, DES went on to become the most widely used block cipher worldwide for 30 years after its publication. When DES was first introduced in the 1970s, a 56-bit key length provided adequate security. However, with advancements in computing, DES is no longer considered secure. In the late 1990s, distributed.net and the EFF DES cracker (Deep Crack) successfully demonstrated how feasible it was to brute-force DES keys, highlighting the vulnerability of the 56-bit key length. The EFF built Deep Crack, which was capable of breaking DES encryption in less than a day. These demonstrations underscored that DES was no longer suitable for secure communication. To address these limitations, multiple DES techniques were introduced, notably Triple DES (3DES), which applies DES three times and provides 112 bits of security, making it more robust. In 2005, NIST officially retired simple DES. Triple DES was also deprecated in 2019, and its usage was prohibited by the end of 2023, except for processing already encrypted data. Today, DES has been replaced by the more secure and powerful AES.

Design

High-level description of DES is as following:

  1. Initial Permutation (IP)
  2. 16 Rounds of Feistel function and Swap
    • Feistel Function
      • Expansion P-Box
      • XOR with Round Key
      • S-Box Substitution
      • P-Box Permutation
    • Swap
  3. Inverse Initial Permutation (IP⁻¹)
  4. Key Scheduling
    • Parity Bit Drop (PC-1)
    • Shift
    • Compression P-Box (PC-2)

Initial Permutation (IP)

The first step applied when 64-bit plaintext is input is the Initial Permutation (IP), where the bits are rearranged based on a predefined permutation.

IP
585042342618102
605244362820124
625446383022146
645648403224168
57494133251791
595143352719113
615345372921135
635547393123157

The permuted input takes bit 58 of the original input as its first bit, bit 50 as its second bit, and continues in this manner, ending with bit 7 as its final bit. This permuted block then serves as the input to a key-dependent computation, which is described below.

16 Rounds of Feistel function and Swap

DES consists of a total of 16 rounds, each divided into two stages: the Mixer stage and the Swapper stage.

  1. Mixer Stage: In this stage, the 32-bit right half and the round key are used to calculate the F function value, which is then XORed with the 32-bit left half. This can be represented by the following formula:
  2. Swapper Stage: In the swapper stage, the value computed from the XOR operation is placed on the right, while the original 32-bit right half is moved to the left. This can be expressed as: Thus, the i-th round can be represented as follows.

Feistel function

Expansion P-Box

The Expansion P-Box is a process that permutes the order of the bits of a 32-bit input value while expanding the output to 48 bits. The method for expanding the input value is as follows:

  1. Divide the 32-bit input value into 8 parts, each consisting of 4 bits.
  2. Expand each 4-bit part to 6 bits according to predefined rules.
XOR with Round Key

After the 32-bit input value is expanded to 48 bits, it is XORed with a 48-bit round key. The 16 round keys are generated from the 56-bit secret key of DES, which is explained in detail in the Key Scheduling section.

S-Box Substitution

The 48-bit output value from the XOR operation is reduced to 32 bits using substitution tables. In DES, these substitution tables are called S-Boxes, and their operation is as follows:

  1. Divide the 48-bit input value into 8 parts, each consisting of 6 bits.
  2. Feed each 6-bit segment into one of the 8 S-Boxes in sequence.
  3. Each S-Box takes a 6-bit input and produces a 4-bit output.
S-Box 10123456789101112131415
014041301021511080310061205090007
100150704140213100306121109050308
204011408130602111512090703100500
315120802040901070511031410000613
S-Box 20123456789101112131415
01518146113497213120510
13134715281412011069115
20147111041315812693215
31381013154211671205149
S-Box 30123456789101112131415
01009146315511312711428
11370934610285141211151
21364981530111212510147
31101306987415143115212
S-Box 40123456789101112131415
07131430691012851112415
11381156150347212110149
21069012117131513145284
33150610113894511127214
S-Box 50123456789101112131415
02124171011685315130149
11411212471315015103986
24211110137815912563014
31181271142136150910453
S-Box 60123456789101112131415
01211015926801334147511
11015427129561131401138
29141552812370410113116
34321295151011141760813
S-Box 70123456789101112131415
04112141508133129751061
11301174911014351221586
21411131237141015680592
36111381410795015142312
S-Box 80123456789101112131415
01328461511110931450127
11151381037412561101492
27114191214206101315358
32114741081315129035611

The S-Box is the only nonlinear component in DES that provides confusion. The rule for substituting the 6-bit input value into a 4-bit output is as follows:

  1. The first and sixth bits of the 6-bit input are concatenated to determine the row. These two bits form a binary value of 00, 01, 10, or 11, corresponding to a decimal value between 0 and 3 to select the row.
  2. The remaining 4 bits determine the column, forming a decimal value between 0 and 15 to select the column.
P-Box Permutation

After the S-Box Substitution, the resulting 32-bit output value is permuted using the P-Box.

P-Box
1607202129122817
0115232605183110
0208241432270309
1913300622110425

Inverse Initial Permutation (IP⁻¹)

Also known as the Final Permutation, this is the final step in the DES encryption process. It is the inverse of the Initial Permutation (IP), meaning that it restores the positions of the bits that were rearranged during the initial permutation back to their original order.

IP⁻¹
4008481656246432
3907471555236331
3806461454226230
3705451353216129
3604441252206028
3503431151195927
3402421050185826
3301410949175725

Note

The Initial Permutation (IP) and Inverse Initial Permutation (IP⁻¹) are inverses of each other, both taking a 64-bit input and producing a 64-bit output.

Key Scheduling

The Key Scheduling process takes a 64-bit input value and generates 16 round keys, each 48 bits in length.

Parity Bit Drop (PC-1)

The secret key for DES is input as a 64-bit value, but the bits at positions 8, 16, 24, etc., are parity bits (specifically, odd parity bits for the remaining 7 bits) and are not part of the actual DES key. (Thus, DES uses a 56-bit key, not a 64-bit one!) In the first step of key scheduling, these parity bits are removed, and the remaining 56 bits are permuted to generate the output value. The Parity Bit Drop Table (PC-1) is as follows:

5749413325170901
5850423426181002
5951433527191103
6052443663554739
3123150762544638
3022140661534537
2921130528201204

Shift

The Shift step divides the 56-bit input into a left 28-bit part and a right 28-bit part, and then cyclically shifts each 28-bit part to the left by 1 or 2 bits. In rounds 1, 2, 9, and 16, a 1-bit shift is performed, while in all other rounds, a 2-bit shift is used, as shown in the table below.

Round12345678910111213141516
Shifts1122222212222221

Compression P-Box (PC-2)

The Compression P-Box (PC-2) step takes a 56-bit input value and reduces it to a 48-bit output.

1417112401050328
1506211023191204
2608160727201302
4152313747553040
5145334844493956
3453464250362932