[WP] cryptohack symmetric-ciphers how-aes-works

好耶,是 AES,这节是实现部分!

目录传送门:cryptohack 练习学习汇总(writeup index)

Keyed Permutations

Me: What is the mathematical term for a one-to-one correspondence?
ChatGPT: The mathematical term for one-to-one correspondence is a bijection.

Resisting Bruteforce

Me: What is the name for the best single-key attack against AES?
ChatGPT: The name for the best single-key attack against AES is the Biclique Cryptanalysis.

Structure of AES

一个小技巧:如果给 sum 函数添加第二个参数作为初始值,那么 sum 可以用于 list 的求和

代码: cryptohack/mathematics symmetric-ciphers Structure-of-AES.py

Round Keys

一个小技巧:for x, y in zip(lis_x, lis_y) 可以同时遍历 lis_x, lis_y 两个列表

代码: cryptohack/mathematics symmetric-ciphers Round-Keys.py

Confusion through Substitution

不过多赘述

代码: cryptohack/mathematics symmetric-ciphers Confusion-through-Substitution.py

Diffusion through Permutation

不过多赘述,等号左右交换即可

代码: cryptohack/mathematics symmetric-ciphers Diffusion-through-Permutation.py

Bringing It All Together

按照题意复现即可。需要注意,如果按照上面的题目所写的函数,其中两个函数有返回值,而另外两个没有,需要注意区分

代码: cryptohack/mathematics symmetric-ciphers Bringing-It-All-Together.py