forked from avalonsaber/crypto1sub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3 - 2 - The Data Encryption Standard (22 min).srt
1713 lines (1445 loc) · 40.8 KB
/
3 - 2 - The Data Encryption Standard (22 min).srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:00,000 --> 00:00:03,662
现在我们理解了什么是分组密码
So now that we understand what block
ciphers are, let's look at a classic
2
00:00:03,662 --> 00:00:07,655
我们看一个经典的例子叫数据加密标准
DES。简单提醒一下大家
example called the Data Encryption
Standard. So, just a quick reminder. Block
3
00:00:07,655 --> 00:00:12,379
分组密码将N位输入映射到N位输出
ciphers basically map N bits of input to N
bits of output. And we talked about two
4
00:00:12,379 --> 00:00:17,045
我们讨论了两个经典的例子,3DES和AES。
本节我们讲DES
canonical examples, triple DES and AES. In
this segment, we're gonna talk about DES,
5
00:00:17,045 --> 00:00:21,480
然后在下一节讨论3DES
and we'll talk about triple DES, actually,
in the next segment. And then I also
6
00:00:21,480 --> 00:00:26,031
我之前提过,分组密码由迭代构造。特别地
mentioned before that block ciphers are
often built by iteration. In particular,
7
00:00:26,031 --> 00:00:30,985
我们看的分组密码里的迭代
we're gonna look at block ciphers that are
built by a form of iteration where a key K
8
00:00:30,985 --> 00:00:35,863
开始时密钥K被扩张成一组回合密钥,
然后回合函数应用到输入信息上
is first expanded into a bunch of round
keys. And then a round function is applied
9
00:00:35,863 --> 00:00:40,660
一次又一次,所有轮次
to the input message, again and again and
again. And essentially, after all these
10
00:00:40,660 --> 00:00:45,156
都完事后,我们获得最终的密文,对吧?
round functions are applied, we obtain the
resulting cipher text, okay? And again,
11
00:00:45,156 --> 00:00:49,253
我们要看看数据加密标准DES如何工作
what we're gonna look at, how DES, the
data encryption standard, uses this
12
00:00:49,253 --> 00:00:53,577
使用这个格式。我想更清楚点
事实上,指定一个这种类型的分组密码
format. I just wanna be clear that, in
fact, to specify a block cipher of this
13
00:00:53,577 --> 00:00:57,788
需要指定密钥扩张的机制
type, one needs to specify the key
expansion mechanism, and one needs to
14
00:00:57,788 --> 00:01:02,113
需要指定回合函数。本节我关注回合函数
specify the round function. In the segment
here, I'm gonna focus on the round
15
00:01:02,113 --> 00:01:06,551
我不会讨论太多密钥扩张的细节
function, and I'm not gonna talk much
about key expansion. But I just wanted to
16
00:01:06,551 --> 00:01:10,990
但我想提一下,事实上,密钥扩张也是描述
分组密码的重要部分
mention that, in fact, key expansion is
also a big part of describing how block
17
00:01:10,990 --> 00:01:15,892
好,那么我们来看看DES的历史
cipher works. Okay, so let's talk about
the history of DES. Essentially, in the
18
00:01:15,892 --> 00:01:20,715
1970年代初,IBM发现他们的消费者要求
early 1970s, IBM realized that their
customers are demanding some form of
19
00:01:20,715 --> 00:01:25,869
某种形式的加密。于是它们成立了一个
密码小组,组长是Horst Feistel
encryption. And so they formed a crypto
group, and the head of that group, was
20
00:01:25,869 --> 00:01:30,492
在70年代初,他设计了Lucifer密码
Horst Feistel, who, in the early 70s,
designed a cipher called Lucifer. Now,
21
00:01:30,492 --> 00:01:35,560
有趣的是,事实上Lucifer有很多变种
it's interesting. In fact Lucifer had a
number of variations but one of the later
22
00:01:35,560 --> 00:01:40,559
但是其中一种新变种有128位的密钥长度
variations in fact had a key length that
was 128 bits and a block length that's
23
00:01:40,559 --> 00:01:45,682
分组大小也是128位。好,1973年
政府发现它买了很多商业的
also 128 bits. Okay, in 1973 the governor
realized that it's buying many commercial
24
00:01:45,682 --> 00:01:50,867
已下架的计算机,所有它希望这些计算机
提供商能有个好的算法
off-the-shelf computers and so it wanted
its suppliers to actually have a good grip
25
00:01:50,867 --> 00:01:55,434
可以在卖给政府的产品中有用
to algorithm that they could use in
products sold to the government. So in
26
00:01:55,434 --> 00:02:00,157
1973年国家安全局(当时的称谓)
1973 the National Bureau of Standards as
it was called at the time put out a
27
00:02:00,157 --> 00:02:04,503
放出了一个征求分组密码的项目
选中的会成为联邦标准
request for proposals for a block cipher
that is going to become a federal
28
00:02:04,503 --> 00:02:09,026
事实上IBM提交了Lucifer的一个变种
standard. And in fact IBM submitted a
variant of Lucifer. That variant actually
29
00:02:09,026 --> 00:02:13,901
这个变种经过一些标准化的修改之后
went through some modification during the
standardization process and then finally
30
00:02:13,901 --> 00:02:18,482
最后于1976年由国家安全局采用为联邦标准
in 1976, the national bureau standard
adopted DES as a federal standard. And, in
31
00:02:18,482 --> 00:02:23,122
事实上DES很有意思,它的密钥长度比Lucifer要少
fact, for DES it's interesting that the
key length was far reduced from Lucifer.
32
00:02:23,122 --> 00:02:27,602
仅为56位,分组大小也减少到64位
It's only 56 bits. And the block length
was also reduced to 64 bits. And in
33
00:02:27,602 --> 00:02:31,838
事实上这些决定,特别是减少密钥长度
fact, these decisions, especially the
decision to reduce the key length, is
34
00:02:31,838 --> 00:02:36,653
是导致很多人怀疑DES寿命的原因
going to be a key length yield of DES and
was a source of many complaints over its
35
00:02:36,653 --> 00:02:41,062
特别地,早在1997年,DES就被穷举密钥攻击
life. In particular, already back in 1997,
DES was broken by exhaustive search
36
00:02:41,062 --> 00:02:45,994
破解了,意思是让计算机遍历所有
2的56次方个可能的密钥
meaning that a machine was able to search
through all two to the 56 possible keys to
37
00:02:45,994 --> 00:02:50,867
来找到特定的密钥。事实上我们会
recover a particular challenge key. And in
fact we're going to talk about exhaustive
38
00:02:50,867 --> 00:02:54,683
详细讨论一下穷举攻击。这个问题很有趣
search quite a bit. It's quite an
interesting question, and there are
39
00:02:54,683 --> 00:02:59,335
有很多方法可以来抵抗穷举攻击
various ways to defend against exhaustive
search. And basically this 1997 experiment
40
00:02:59,335 --> 00:03:03,655
1997年的实验预示了DES的末路,
它意味着DES本身不再安全了
kinda spelled the doom of DES. It meant
that DES is itself, is no longer secure.
41
00:03:03,655 --> 00:03:08,251
于是国家标准研究所对外发出请求
And as a result, the National Institute of
Standards, as it became known, issued a
42
00:03:08,251 --> 00:03:12,755
征求下一代分组密码方案
request for proposals. For our next
generation's block cipher standard and in
43
00:03:12,755 --> 00:03:17,427
在2000年,它在Rijndael的基础上研发标准
2000 it standardized on a cipher called Rijndael.
Which became the advanced encryption
44
00:03:17,427 --> 00:03:21,903
成为了高级加密标准AES。我们稍后讨论AES
standard, AES. And we'll talk about AES
later on. But in this segment, I wanna
45
00:03:21,903 --> 00:03:26,199
本节我想描述DES的工作原理
DES是个(历史上)异常成功的密码
describe how DES works. Now, DES is a
cipher, it's an amazingly successful
46
00:03:26,199 --> 00:03:30,496
它被用于银行业界。事实上
cipher. It's been used in the banking
industry. In fact, there's a classic
47
00:03:30,496 --> 00:03:34,613
有一个经典的网络叫做电子打扫房间
network called the Electronic
Clearing House, which banks use to clear
48
00:03:34,613 --> 00:03:39,447
银行使用这个网络来处理支票
DES被用来保护这些事务的完整性
checks with one another. And DES is used
for integrity in those transactions. It's
49
00:03:39,447 --> 00:03:43,922
DES也被商用。事实上它不久前很流行
also used in commerce. In fact, it was
very popular up until recently, as the
50
00:03:43,922 --> 00:03:48,699
曾是网络的主要加密机制
当然,现在它已被AES和其他密码替代
main encryption mechanism for the web. Of
course, now, that's been replaced with AES
51
00:03:48,699 --> 00:03:52,977
总的来说,从应用的角度来看
DES是个非常成功的密码
and other ciphers. Overall, it's a
very successful cipher in terms of
52
00:03:52,977 --> 00:03:57,425
DES也有非常丰富的被攻击历史
deployment. DES also has a very rich
history of attacks, which we'll talk about
53
00:03:57,425 --> 00:04:01,931
我们将在下一节中讨论DES的攻击
现在,我们讨论DES的构造
in the next segment. Okay, so now, let's
talking about the construction of DES. So,
54
00:04:01,931 --> 00:04:06,608
DES背后的核心思想叫做Feistel网络
由Horst Feistel提出
the core idea behind DES is what's called
a Feistel network, due to Horst Feistel.
55
00:04:06,608 --> 00:04:11,087
这是一个非常聪明的方法,
来根据任意函数F1到FD构造分组密码
And basically, it's a very clever idea for
building the block cipher out of arbitrary
56
00:04:11,087 --> 00:04:15,485
好的,那么我们有这些函数F1到FD
functions, F1 to FD. Okay so imagine we
have these functions F1 to FD
57
00:04:15,485 --> 00:04:18,765
它们从n位字符串映射到n位字符串
现在这些是任意的函数
that happens to match n bits to n bits.
Now these are arbitrary functions,
58
00:04:18,765 --> 00:04:22,425
它们不一定是可逆的,而我们要做的
they don't have to be invertible or
anything. What we want to do is build an
59
00:04:22,425 --> 00:04:26,956
是根据这D个函数构造出一个可逆函数。
我们实现的方法是
invertible function out of those D
functions and the way we'll do it is by
60
00:04:26,956 --> 00:04:31,484
构造一个新的函数,我们记为F
将2n位字符串映射到2n位字符串
building a new function we'll call capital
F that maps 2n bits to 2n bits.
61
00:04:31,484 --> 00:04:35,593
构造方法写在这里了
那么这里有我们的输入
And the construction is described right
here. So here we have our inputs. You
62
00:04:35,593 --> 00:04:40,299
大家注意,有两个n位的分组
换句话说,输入实际上是2n位
notice, there are two blocks of n bits.
In other words, the input is actually
63
00:04:40,299 --> 00:04:44,792
R和L分布代表右和左。典型地
2n bits. The R and L stand for right and
left. Typically, people describe a
64
00:04:44,792 --> 00:04:49,205
我们从高层到底层来表述Feistel网络。
这里n位字符串分左右
Feistel network from top to bottom. In
which case, these n bits really would be
65
00:04:49,205 --> 00:04:52,214
但这里我横向描述会更方便些
right and left. But here it is more
convenient for me to describe it
66
00:04:52,214 --> 00:04:56,300
如果我们跟着右边R走
horizontally. So if we follow the R
inputs. You realize it basically gets
67
00:04:56,300 --> 00:05:01,555
发现它被左边输出原样复制了一份
没有发生任何改变,对吧?
copied into the L output, without any
change at all. Okay? However, the L
68
00:05:01,555 --> 00:05:07,260
但是输入L有些变化。将输入R
inputs, is changed somewhat. What happens
is, basically, the R inputs is fit into
69
00:05:07,260 --> 00:05:12,888
应用函数F1,然后结果和L0异或,就成为了新的R1
the function F1 and the result is then
XORed with L0 and that becomes the new R1
(编号表示第几回合的结果)
70
00:05:12,888 --> 00:05:17,711
好,那么这个叫做Feistel网络的一个回合
input. Okay, so this is called one round
of a Feistel network, and is done using
71
00:05:17,711 --> 00:05:22,584
它是使用函数F1的。现在我们再做一遍,使用函数F2来完成
the function F1. Now we do this again with
another round of the Feistel network
72
00:05:22,584 --> 00:05:26,122
Feistel网络,然后我们一次又一次地做
with the function F2, and we do it again
and again and again, 'till we get to the
73
00:05:26,122 --> 00:05:31,969
直到最后一轮,用函数FD完成之。
最终所得的结果
last round, and we do it again with the
function FD. And finally, the output is
74
00:05:31,969 --> 00:05:37,542
记为Rd和Ld。那么如果你乐意,我们能
写成符号的形式,就是说
Rd, Ld. Okay. So, if you like, we can write
this in symbols. That basically, Li is
75
00:05:37,542 --> 00:05:43,003
Li等于R_i-1,然后Ri更复杂
simply equal to R_i-1. And Ri,
let's see, that's the more complicated
76
00:05:43,003 --> 00:05:50,451
Ri等于。。我们跟着这条线
Ri等于Fi应用到
one. Ri is equal, well, let's just follow
the lines here. Ri is just equal to Fi
77
00:05:50,451 --> 00:05:58,968
R_i-1,再异或Li,对吧?
applied to, R_i-1 XOR Li. Okay?
So this, and this is basically, i goes
78
00:05:58,968 --> 00:06:06,618
这里i从1到d。这个方程定义了一个Feistel网络
from, 1 to d. So this is the, equation
that defines a Feistel network, mapping a
79
00:06:06,618 --> 00:06:09,673
将一个2n位输入映射到2n位输出
所以我们这里有
2n bit input to 2n bit outputs. So
here we have the, again, I just copied the
80
00:06:09,673 --> 00:06:14,831
我刚刚复制了Feistel网络的图
令人惊讶的论断是,事实上
picture of the Feistel network. And the
amazing claim is that, in fact, it doesn't
81
00:06:14,831 --> 00:06:19,541
与你给我的函数们F1到Fd无关
对于这些给我的函数
matter which functions you give me. For
any functions, F1 to FD that you give me,
82
00:06:19,541 --> 00:06:24,602
构造出的Feistel网络事实上是可逆的
the resulting Feistel network function is,
in fact, invertible. And the way we're
83
00:06:24,602 --> 00:06:27,635
我们证明的方法是构造出它的一个逆
going to prove that is basically we're
going to construct an inverse, because not
84
00:06:27,635 --> 00:06:31,235
因为它不仅可逆,而且它的逆可被有效计算。
那么我们来看看
only is it invertible, it's efficiently
invertible. So let's see. So let's look at
85
00:06:31,235 --> 00:06:36,628
我们先看一回合Feistel网络:
这里是输入Ri和Li
one round of a Feistel network, so
here, this is the inputs, Ri, Li, and this
86
00:06:36,628 --> 00:06:41,618
这是输出R_i+1和L_i+1。现在我问大家
如何求这个的逆呢?
is the output R_i+1, L_i+1. And now what I'm
going to ask you is to invert this.
87
00:06:41,618 --> 00:06:48,781
那我们看看。假设我们有的输入是R_i+1和L_i+1
So let's see. So suppose now the input that
we're given is R_i+1, L_i+1 and we want to
88
00:06:48,781 --> 00:06:54,883
我们想计算Ri和Li。我们想计算这一回合
从相反的方向来
compute Ri, Li. So we want to compute the
round in the reverse direction. So let's
89
00:06:54,883 --> 00:07:00,024
我们看看行不行。好,我们先看Ri。
Ri非常简单
see if we can do it. Well, let's look at
Ri. So, Ri is very easy. Basically, Ri is
90
00:07:00,024 --> 00:07:07,240
Ri就等于L_i+1。所有L_i+1就成为了R_i
现在我问大家
just equal to L_i+1. So L_i+1 just becomes
R_i. But now, let me ask you, to write the
91
00:07:07,245 --> 00:07:12,157
写出L_i的表达式,用R_i+1和L_i+1表示
expression for L_i in terms of R_i+1, and L_i+1.
92
00:07:13,049 --> 00:07:17,991
那么我希望大家都写出来了,
将L_i+1输入到函数F_i+1
So I hope everybody sees that, basically, L_i+1
is fed into the function F_i+1.
93
00:07:17,991 --> 00:07:24,810
函数结果跟R_i+1异或,答案就是L_i
The result is XORed with R_i+1,
and that gives the L_i input.
94
00:07:24,810 --> 00:07:28,181
这就是Feistel网络一轮的逆
So this the inverse of one round
of a Feistel network.
95
00:07:28,181 --> 00:07:32,865
如果我们画成这幅图,写下逆的构造图
And if we draw this as a diagram, let's just
write the picture for the inverse.
96
00:07:32,865 --> 00:07:38,810
大家注意输入是R_i+1, L_i+1
输出是Ri和Li,对吧?
So here you notice the input is R_i+1, L_i+1
and the output is Ri, Li. Right?
97
00:07:38,810 --> 00:07:43,278
我们在计算每回合的逆
大家注意到Feistel回合的逆
So we're computing, we're inverting, the
rounds. So you notice that the inverse of
98
00:07:43,278 --> 00:07:47,242
和正向Feistel网络本身长得很像
a Feistel round looks pretty much the
same as the Feistel round in the
99
00:07:47,242 --> 00:07:50,237
由于技术原因,字面上看
forward direction. It's literally, you
know, just for a technical reason, it's
100
00:07:50,237 --> 00:07:54,309
它们互为镜像,构造是相同的
kinda the mirror image of one another. But
it's basically, the same construct. And
101
00:07:54,309 --> 00:07:59,133
当我们一起用这些回合的逆时
when we put these inverted rounds back
together. We essentially get the inverse
102
00:07:59,133 --> 00:08:03,446
我们就可以获得整个Feistel网络的逆了。
那么大家注意到我们从第D个回合开始
of the entire Feistel network. So you
notice we start off with the round number D
103
00:08:03,446 --> 00:08:07,632
计算第D个回合的逆,然后计算
第D-1个回合的逆,等等
with the inverse of round number D,
then we do the inverse of round number D-1
104
00:08:07,632 --> 00:08:11,458
直到我们获得了第一回合的逆
and so on and so forth until we
get to the inverse of the first round. And
105
00:08:11,458 --> 00:08:18,063
我们得到了最后的输出R0和L0
这就是输入
we get our final outputs which is R0, L0,
like this is the inputs and we manage to
106
00:08:18,063 --> 00:08:22,694
这样我们设法用Rd和Ld,计算出R0和L0。有趣的是
invert basically Rd, Ld and get R0, L0
and the interesting thing is that
107
00:08:22,694 --> 00:08:25,882
这些求逆的计算和加密的计算非常类似
basically these inversion circuits look
pretty much the same as the encryption
108
00:08:25,882 --> 00:08:31,105
唯一的不同是函数应用的顺序正好相反
circuits and the only difference is that
the functions are applied in reverse order.
109
00:08:31,105 --> 00:08:35,566
我们从Fd出发,到F1结束。当我们加密时
Right we started with Fd and ended with
F1. Whereas when we were encrypting, we
110
00:08:35,566 --> 00:08:40,539
从F1出发,到Fd结束。所以,对硬件设计者而言
started with F1 and ended with Fd. So, for
hardware designers, this is very
111
00:08:40,539 --> 00:08:44,808
这个非常吸引人,因为想节省硬件开销
attractive, because, basically, if you
wanna save hardware, you realize that your
112
00:08:44,808 --> 00:08:48,536
加密硬件要和解密硬件一样
encryption hardware is identical to your
decryption hardware. So you only have to
113
00:08:48,536 --> 00:08:52,674
所以大家只需要实现一个算法即可
同时可以获得两个算法
implement one algorithm, and you get both
algorithms the same way. The only
114
00:08:52,674 --> 00:08:56,899
唯一的不同在于函数应用的顺序相反
difference is that the functions are
applied in reverse order. Okay. So this
115
00:08:56,899 --> 00:09:01,109
好的,这个Feistel机制是个构造可逆函数的一般方法
Feistel mechanism is a general method
for building invertible functions from
116
00:09:01,109 --> 00:09:06,224
根据任意函数F1到Fd。事实上
它在很多不同的分组密码中都有应用
arbitrary functions F1 to Fd and in fact,
it's used in many different block ciphers.
117
00:09:06,224 --> 00:09:11,040
不过有趣的是,AES没有使用它
Although, interestingly, it's not actually
used in AES. So, there are many other
118
00:09:11,040 --> 00:09:15,297
有许多其他分组密码用了Feistel网络
当然,它们的回合函数
block ciphers that use a Feistel
network. Or, of course, they differ from
119
00:09:15,297 --> 00:09:19,838
与DES中的F1到Fd不同。但是AES
使用了一个完全不同的结构类型
DES in the functions F1 to Fd. But AES
actually uses a completely different type
120
00:09:19,838 --> 00:09:24,033
并非Feistel网络,过几节
of structure that's actually not a
Feistel network. We'll see how AES
121
00:09:24,033 --> 00:09:29,043
我们会看到AES的工作原理。
现在我们知道了Feistel网络是什么了
works in a couple of segments. So now that
we know what Feistel networks are, let
122
00:09:29,043 --> 00:09:32,898
让我提一个关于Feistel网络的重要定理
me mention an important theorem about the
theory of Feistel networks that shows
123
00:09:32,898 --> 00:09:37,794
用来证实Feistel网络是个好办法
这个定理由Luby和Rackoff于1985年提出
why they're a good idea. This theorem is
due to Luby and Rackoff back in 1985, and it
124
00:09:37,794 --> 00:09:41,774
表述如下。假设我有一个安全的伪随机函数
says the following. Suppose I have a
function that is a secure pseudorandom
(参见论文How to construct pseudorandom
permutations from pseudorandom functions)
125
00:09:41,774 --> 00:09:46,804
那么它与定义在N位字符串上的随机函数不可区分
function, okay. So it's indistinguishable
from random and happens to act on N bits.
126
00:09:46,804 --> 00:09:52,857
所以它使用密钥K将N位字符串映射到N位字符串
So it maps N bits to N bits and uses a
key K. Then, it turns out, that if you use
127
00:09:52,857 --> 00:09:57,621
如果在三轮Feistel网络中使用这个函数
最后得到的是一个安全的伪随机置换
this function in three rounds of a Feistel
network. What you end up with is a secure
128
00:09:57,621 --> 00:10:03,208
换句话说,最终得到的是一个可逆函数
pseudo random permutation. In other words,
what you end up with is an invertible
129
00:10:03,208 --> 00:10:07,724
它与真随机函数不可区分
function that is indistinguishable from a
truly random invertible function. And I
130
00:10:07,724 --> 00:10:11,457
我希望大家还记得安全的分组密码的定义
hope you remember that the true definition
of a secure block cipher is that it needs
131
00:10:11,457 --> 00:10:16,106
它需要一个安全的伪随机置换。这个定理说
to be a secure pseudo random permutation.
So what this theorem says, is that if you
132
00:10:16,106 --> 00:10:20,303
如果你从一个安全的伪随机函数出发
最后可以得到一个安全的分组密码
start with a secure pseudo random
function, you end up with a secure block
133
00:10:20,303 --> 00:10:23,824
就是这些。让我再解释得更多一点
cipher. Basically, that's what this is.
And let me explain in a little bit more
134
00:10:23,824 --> 00:10:28,939
到底发生什么了。本质上
PRF在Feistel网络的每一回合里
detail what's actually going on here. So,
essentially, the PRF is used in every
135
00:10:28,939 --> 00:10:34,808
都被使用。换句话说
round of the Feistel network. So, in
other words, here, what's actually
136
00:10:34,808 --> 00:10:39,731
PRF使用密钥K0计算
computed is the PRF using one secret key,
K0. Here, what's computed is the PRF
137
00:10:39,731 --> 00:10:45,959
当然,使用另一不同密钥对付R1
using a different secret key, of course
applied to R1. And here we have yet
138
00:10:45,959 --> 00:10:51,578
这里我们还有另一密钥K1,对付R1;K2对付R2。大家注意
another secret key, K1 applied, K2 applied
to R2. And you notice, this is why,
139
00:10:51,578 --> 00:10:55,371
这就是为什么Feistel机制使用K^3里的密钥
basically this Feistel construction,
uses keys in K cubed. In other words, it
140
00:10:55,371 --> 00:11:01,004
换句话说,它使用了三个独立的密钥
密钥独立这点很重要
uses three independent keys. So it's very
important that the keys are actually
141
00:11:01,004 --> 00:11:07,438
所以我们需要三个独立的密钥
independent. So really, we need three,
independent keys. And then we end up with
142
00:11:07,438 --> 00:11:12,600
然后我们最后得到了一个安全的伪随机置换
好,那就是支撑Feistel网络的理论
a secure pseudorandom permutation. Okay,
so that's the theory behind Feistel
143
00:11:12,600 --> 00:11:16,051
现在我们理解了,可以看看DES的特例了
networks. And now that we understand that,
we can actually look at the specifics of DES.
144
00:11:16,051 --> 00:11:20,256
DES有16回合的Feistel网络,好的
So DES is basically a sixteen round
Feistel network, okay. So there are
145
00:11:20,256 --> 00:11:26,349
有函数F1到F16,将32位字符串映射到
32位字符串,因此
functions F1 to F16 that map 32 bits to
32 bits, and as a result, the DES itself
146
00:11:26,349 --> 00:11:33,054
DES本身是作用于64位分组上的,2x32
现在DES里的16个回合函数
acts on 64 bit blocks, 2x32. Now the
sixteen round functions in DES are
147
00:11:33,054 --> 00:11:37,673
都是由一个函数F推导而来的
只不过回合密钥不同
actually all derived from a single
function F. Just used with different keys.
148
00:11:37,673 --> 00:11:44,765
事实上,每轮的回合密钥不同。Ki是回合密钥
So in fact, these are the different round
keys. So Ki is, a round key. And it's
149
00:11:44,765 --> 00:11:52,585
由DES的56位主密钥推导而来
basically derived from the key K, derived
from the 56 bit DES key K. Okay and I'll
150
00:11:52,585 --> 00:11:56,567
我待会再来描述这个函数F
describe what this function F is in just a
minute. But basically that, you see that
151
00:11:56,567 --> 00:12:01,856
大家看到有16个不同的回合密钥
我们得到了16个不同的回合函数
by using sixteen different round keys, we
get sixteen different round functions. And
152
00:12:01,856 --> 00:12:06,460
这给我们Feistel网络。所以从高层看DES的工作
that gives us the Feistel network. So just
on a high level how the DES works
153
00:12:06,460 --> 00:12:10,829
你有64位输入。第一件事是
basically you have a 64 bit input. The
first thing it does is, this initial
154
00:12:10,829 --> 00:12:15,175
初始置换仅是置换这64位字符串
它把第0位换到第6位
permutation that just permutes the 64 bits
around. Namely it maps bit number one to
155
00:12:15,175 --> 00:12:20,216
把第2位换到第17位,等等
bit number six. Bit number two to bit
number seventeen, and so on. This is not
156
00:12:20,216 --> 00:12:24,702
这并不是出于安全考虑,仅仅是标准里的要求
for security reasons, this is just
specified in the standard. Then we go into
157
00:12:24,702 --> 00:12:29,076
然后进行16轮Feistel网络