Foundations of Security Week8 Lecture

1308 字
7 分钟
Foundations of Security Week8 Lecture

Lecture Outline#

  1. Introduction to the Data Encryption Standard (DES) algorithm
  2. Structure of DES block cipher
  3. Initial permutation (IP) in DES
  4. Key schedule and generation of 16 subkeys
  5. 16 rounds of DES processing
  6. Expansion function (E-box) and Subkey mixing using XOR operation
  7. Substitution using S-boxes

Learning Outcomes#

By the end of this lecture, students should be able to:

  1. Explain the structure of the DES encryption algorithm
  2. Describe how plaintext is divided into left and right halves
  3. Explain how the DES key schedule generates subkeys
  4. Describe the steps involved in the 16 rounds of DES processing
  5. Describe how the expansion function (E-box) works
  6. Describe how S-boxes perform substitution in DES

Data Encryption Standard (DES) Algorithm#

Is a symmetric-key block cipher algorithm that was developed in the 1970s by IBM and later adopted by the U.S. National Institute of Standards and Technology (NIST) as a federal standard in 1977.
It has since been replaced by more secure algorithms like AES (Advanced Encryption Standard) due to its small key size vulnerability.

It encrypts data in 64-bit blocks using a 56-bit key (though the key is technically 64 bits, with 8 bits used for parity).

Key Features of DES:
Symmetric Key Algorithm: Uses the same key for encryption and decryption.
Block Cipher: Encrypts data in fixed-size blocks (64-bit blocks).
Key Length: 56-bit effective key length (64-bit key with 8 bits used for parity).
Rounds of Processing: 16 rounds of substitution and permutation.
Feistel Network Structure: Divides the block into two halves and processes them alternately.


Step-by-Step Process

  1. Input
  2. Initial Permutation (IP)
  3. Key Schedule (16 Subkeys Generation)
  4. 16 Rounds of Processing
  5. Final Permutation (FP)

Initial Permutation (IP)#

  • The 64-bit plaintext is rearranged according to a fixed table (IP table).
  • This doesn’t encrypt; it just prepares the data for processing.
  • Bit 58 of the plaintext becomes bit 1, bit 50 becomes bit 2, and so on.

Initial Permutation (IP) Table

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

  • Output: Split the 64-bit permuted block into two 32-bit halves:
    L0\textcolor{red}{L_0} (left 32 bits)
    R0\textcolor{red}{R_0} (right 32 bits).


Step-by-Step Process

  1. Input
  2. Initial Permutation (IP)
  3. Key Schedule (16 Subkeys Generation)
  4. 16 Rounds of Processing
  5. Final Permutation (FP)

Key Schedule (16 Subkeys Generation)
Permutation (IP)#

Key Schedule (16 Subkeys Generation)

  • The key is provided in hexadecimal format
    eg Hexadecimal Key = 133457799BBCDFF1 (16 hexadecimal digits).
  • Convert to binary.
  • The 64-bit key is permuted using the Permuted choice 1 (PC-1) table, and 8 parity bits are discarded, leaving a 56-bit key. Bit 57 of the key becomes bit 1, bit 49 becomes bit 2, and so on.


  • Split into Halves: The 56-bit key is split into two 28-bit halves, C0 and D0
  • Left Shifts: For each round, C0 and D0 are left-shifted (rotated) by 1 or 2 bits, depending on the round (e.g., rounds 1, 2, 9, 16 shift by 1 bit; others by 2).
  • Permuted Choice 2 (PC-2): After shifting, a 48-bit subkey is selected from the 56-bit C and D using the PC-2 table

K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111

C0 = 1111000 0110011 0010101 0101111
D0 = 0101010 1011001 1001111 0001111


  • Left Shifts: For each round, C0 and D0 are left-shifted (rotated) by 1 or 2 bits, depending on the round




  • Permuted Choice 2 (PC-2): After shifting, a 48-bit subkey is selected from the 56-bit C and D using the PC-2 table. We form the 16 Kn\textcolor{red}{K_n} keys of 48-bits.


K1\textcolor{red}{K_1} = 000110 110000 001011 101111 111111 000111 000001 110010
K2\textcolor{red}{K_2} = 011110 011010 111011 011001 110110 111100 100111 100101
K3\textcolor{red}{K_3} = 010101 011111 110010 001010 010000 101100 111110 011001
K4\textcolor{red}{K_4} = 011100 101010 110111 010110 110110 110011 010100 011101
K5\textcolor{red}{K_5} = 011111 001110 110000 000111 111010 110101 001110 101000
K6\textcolor{red}{K_6} = 011000 111010 010100 111110 010100 000111 101100 101111
K7\textcolor{red}{K_7} = 111011 001000 010010 110111 111101 100001 100010 111100
K8\textcolor{red}{K_8} = 111101 111000 101000 111010 110000 010011 101111 111011
……
K16\textcolor{red}{K_{16}} = 110010 110011 110110 001011 000011 100001 011111 110101


Step-by-Step Process

  1. Input
  2. Initial Permutation (IP)
  3. Key Schedule (16 Subkeys Generation)
  4. 16 Rounds of Processing
  5. Final Permutation (FP)

16 Rounds of Processing

  • Input: The left half (Ln1\textcolor{blue}{L_{n-1}}) and right half (Rn1\textcolor{blue}{R_{n-1}}) from the previous round (or IP for round 1).
  • Feistel Function (F): The right half (Rn1\textcolor{blue}{R_{n-1}}) is processed with the subkey (Kn\textcolor{blue}{K_n}) to produce a 32-bit output:
  • Expansion (E-box): The 32-bit Rn1\textcolor{blue}{R_{n-1}} is expanded to 48 bits using an expansion table (some bits are duplicated).
  • Subkey Mixing: The 48-bit expanded Rn1\textcolor{blue}{R_{n-1}} is XORed with the 48-bit subkey Kn\textcolor{blue}{K_n}.
    • XOR: A bitwise operation where 00=0\textcolor{purple}{0 \oplus 0 = 0}, 11=0\textcolor{purple}{1 \oplus 1 = 0}, 10=1\textcolor{purple}{1 \oplus 0 = 1}, 01=1\textcolor{purple}{0 \oplus 1 = 1}.
  • S-boxes (Substitution): The 48-bit result is divided into eight 6-bit chunks. Each chunk is passed through one of eight S-boxes (lookup tables), which map 6 bits to 4 bits, reducing the total to 32 bits (8×4=328 \times 4 = 32).
    • Each S-box uses the outer 2 bits of the 6-bit input to select a row and the inner 4 bits to select a column, outputting a 4-bit value.
  • P-box (Permutation): The 32-bit S-box output is permuted using a fixed permutation table (P-box).
  • Output of Feistel Function: A 32-bit value, from F(Rn1\textcolor{blue}{R_{n-1}}, Kn\textcolor{blue}{K_n}).
  • Swap Halves

L0\textcolor{red}{L_0} = 1100 1100 0000 0000 1100 1100 1111 1111
R0\textcolor{red}{R_0} = 1111 0000 1010 1010 1111 0000 1010 1010

graph LR %% 左侧原始公式(多色文本,用HTML span实现) A["<span style='color:red'>L<sub>n</sub></span> = <span style='color:red'>R<sub>n-1</sub></span><br> <span style='color:red'>R<sub>n</sub></span> = <span style='color:red'>L<sub>n-1</sub></span> <span style='color:purple'>⊕</span> F(<span style='color:blue'>R<sub>n-1</sub></span>, <span style='color:blue'>K<sub>n</sub></span>)"] %% 右侧代入n=1后的公式(完全匹配原图多色) C["<span style='color:red'>L<sub>1</sub></span> = <span style='color:red'>R<sub>1-1</sub></span> = <span style='color:red'>R<sub>0</sub></span><br> <span style='color:red'>R<sub>1</sub></span> = <span style='color:red'>L<sub>1-1</sub></span> <span style='color:purple'>⊕</span> F(<span style='color:blue'>R<sub>1-1</sub></span>, <span style='color:blue'>K<sub>1</sub></span>) = <span style='color:red'>L<sub>0</sub></span> <span style='color:purple'>⊕</span> F(<span style='color:blue'>R<sub>0</sub></span>, <span style='color:blue'>K<sub>1</sub></span>)"] %% 箭头文字:"for n=1" 设为红色,和原图一致 A -- "<span style='color:red'>for n=1</span>" --> C

We have


16 Rounds of Processing - Expansion (E-box)

To calculate F, we first expand each block R0\textcolor{red}{R_0}, from 32 bits to 48 bits.
This is done by using a expansion table that repeats some of the bits in R0\textcolor{red}{R_0}

F(R0\textcolor{blue}{R_0}, K1\textcolor{blue}{K_1})


16 Rounds of Processing - Subkey Mixing

F(R0,K1)F(E(R0),K1)F(\textcolor{blue}{R_0}, \textcolor{blue}{K_1}) \textcolor{purple}\longrightarrow F(\textcolor{red}{E(R_0)}, \textcolor{blue}{K_1})

E(R0)K1E(R_0) \oplus K_1

E(R0)=011110 100001 010101 010101 011110 100001 010101 010101\colorbox{#FFF2CC}{$\textcolor{red}{E(R_0)} \textcolor{black}{= 011110 ~ 100001 ~ 010101 ~ 010101 ~ 011110 ~ 100001 ~ 010101 ~ 010101}$}

\textcolor{purple}\oplus

K1=000110 110000 001011 101111 111111 000111 000001 110010\colorbox{#E2F0D9}{$\textcolor{red}{K_1} \textcolor{black}{= 000110 ~ 110000 ~ 001011 ~ 101111 ~ 111111 ~ 000111 ~ 000001 ~ 110010}$}

E(R0)K1=011000 010001 011110 111010 100001 100110 010100 100111\colorbox{#FBE5D6}{$\textcolor{black}{E(R_0) \oplus K_1 = 011000 ~ 010001 ~ 011110 ~ 111010 ~ 100001 ~ 100110 ~ 010100 ~ 100111}$}


16 Rounds of Processing - S-boxes (Substitution)

The 48-bit result is divided into eight 6-bit chunks. Each chunk is passed through one of eight S-boxes (lookup tables), which map 6 bits to 4 bits, reducing the total to 32 bits (8×4=328 \times 4 = 32).

We now compute

S1(B1)   S2(B2)    S3(B3)    S4(B4)    S5(B5)    S6(B6)    S7(B7)    S8(B8)

S-box 1 (S1)
1441312151183106125907
0157414213110612119538
4114813621115129731050
1512824917511314100613

S1

1441312151183106125907
0157414213110612119538
4114813621115129731050
1512824917511314100613

S2

1518146113497213120510
3134715281412011069115
0147111041315812693215
1381013154211671205149

S3

1009146315511312711428
1370934610285141211151
1364981530111212510147
1101306987415143115212

S4

7131430691012851112415
1381156150347212110149
1069012117131513145284
3150610113894511127214

S5

2124171011685315130149
1411212471315015103986
4211110137815912563014
1181271142136150910453

S6

1211015926801334147511
1015427129561131401138
9141552812370410113116
4321295151011141760813

S7

4112141508133129751061
1301174911014351221586
1411131237141015680592
6111381410795015142312

S8

1328461511110931450127
1151381037412561101492
7114191214206101315358
2114741081315129035611

Reading Assignment#

Read on how to compute the following using the 8 S-boxes

S1(B1)   S2(B2)    S3(B3)    S4(B4)    S5(B5)    S6(B6)    S7(B7)    S8(B8)

To be continued

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
Foundations of Security Week8 Lecture
https://firefly.anka2.top/posts/obu/level5/semester2/fos/week8/lecture/
作者
🐦‍🔥不死鸟Anka
发布于
2026-04-28
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
A-n-k-a
Over the Frontier / Into the Front
看这里~
合作翻译官绝赞招募中!
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
59
分类
6
标签
20
总字数
550,118
运行时长
0
最后活动
0 天前

目录