Fundamental Security Properties and Mechanisms I (Cryptographic Analysis Task)R

Java与Python的密码分析任务

Java Python COM6014

Fundamental Security Properties and Mechanisms

Assignment I (Cryptographic Analysis Task)

Deadline for submission via MOLE: Wednesday 11th December 2024 at 15:00

Total Marks Available 100

Submission format details are given at the end of this question.

Question: Linear Cryptanalysis (100 Marks)

A simple 3-round substitution permutation network (SPN) cipher (inspired by the Heys’ Tutorial SPN cipher) is shown in Figure 1.

The cipher operates on 8-bit blocks. Key mixing is simple bitwise XOR. The 8-bit plaintext block P is XOR-ed bitwise with the 8-bit key K1 before the resulting 8-bit block enters the two first-round S-boxes. The remaining key mixing operations for K2, K3, and K4 are handled similarly. (They are all bitwise XOR operations over 8 bits.)

A substitution box (S-box) is shown in Figure 2. This S-box is used throughout the cipher shown in Figure 1, i.e., the six S-boxes are identical. The S-box is identical to that given in the Heys’ Tutorial SPN Cipher.

The permutation part of the first two rounds is as shown in Figure 1. The final (third) round does not implement any permutation; the outputs from the final round S-boxes are simply XOR-ed bitwise with the key K4 to produce ciphertext C. The permutation is obviously different to that given in the Heys’ Tutorial SPN cipher since the cipher in this assessment operates over 8-bit blocks and that of the Heys’ Tutorial SPN cipher operates over 16-bit blocks.

A file “Encryptions256-2024-25.txt” has been provided containing the 256 possible plaintext-ciphertext (PC) pairs derived using a specific set of four keys. In each line of the file the plaintext P and corresponding ciphertext C appear as the natural decimal integer interpretations (from 0 to 255) of 8-bit values. For example, the value 129 is the interpretation of the 8 bits 10000001.

You are required to develop a 2-round linear approximation (i.e., suitably approximating the first two rounds) and use it to recover the final key K4, documenting your efforts in a report. Then you are required similarly to recover the key K3. You are then required to reflect on what you have done and consider an analogous key recovery strategy.

Answer all question parts below in your report.

a) Develop a suitable 2-round linear approximation for the cipher. You should:

i. state clearly what the 2-round linear approximation is, i.e. give its expression as an equation. The approximation should involve bits of P and bits of U3. Your single approximation must target ALL 8 bits of K4. [5 Marks]

ii. indicate the active S-boxes used in your 2-round approximation and indicate the linear approximation used in each active S-box.  Give the associated biases of each such active S-box approximation and indicate how/from where they were obtained. [8 Marks]

iii.&nbs Fundamental Security Properties and Mechanisms Assignment I (Cryptographic Analysis Task)R p;calculate the bias of your 2-round linear approximation and show your calculations.  [5 Marks]

iv. present an annotated copy of Figure 1, summarizing the work above. [2 Marks]

v. justify the choices you have made in constructing your 2-round approximation. [5 Marks]

Note: you should not overcomplicate your answers. You are NOT expected to do any step-by-step algebraic manipulations given in the lecture on linear cryptanalysis or in the Heys’ tutorial (which serve to show why linear cryptanalysis works).

b) Implement linear cryptanalysis to recover K4. Your implementation (code) should contain:

i. functionality to read in the 256 PC pairs from the provided file. [5 Marks]

ii. a function reverseCK(C, K) that returns a value of U3, given ciphertext C and a key value K as inputs. It should also contain code to verify that this reversal code is correctly implemented. [10 Marks]

iii. functionality to determine, when evaluated using the 256 P-C pairs, how many times your given approximation holds for each possible key guess for K4. [10 Marks]

iv. functionality to rank and display appropriately the counts derived in (iii). [5 Marks]

v. appropriate comments in-line to help the reader understand code. [5 Marks]

c) You should:

i. run your code and present the results appropriately in your report. [5 Marks]

ii. indicate, based on your results, what is the most likely value for K4 [5 Marks]

d) Assuming the K4 value your approach above has identified is correct, proceed in an analogous fashion to recover K3. You should:

i. indicate the approximation to be used to recover K3, and what its bias is etc. [3 Marks]

ii. implement code to identify a candidate for K3. [12 Marks]

iii. run your code and present results in an analogous fashion, indicating the most likely candidate for K3 [5 Marks]

You should be able to reuse much of your previously developed code. You might anticipate the requirements of this question part when you develop your code in part b) above (but you are not obliged to do so).

e) Above the first key to be recovered was K4.  Explain how you could instead have recovered K1 (or part of it) in an analogous manner. (You are not expected to implement this.) [10 Marks]

Submission Details. Your report should be in pdf format and submission is online via the COM6014 Blackboard website.  Your report should include your code.

Figure 1. Simple Very Small SPN Cipher

Figure 2         

提供了基于BP(Back Propagation)神经网络结合PID(比例-积分-微分)控制策略的Simulink仿真模型。该模型旨在实现对杨艺所著论文《基于S函数的BP神经网络PID控制器及Simulink仿真》中的理论进行实践验证。在Matlab 2016b环境下开发,经过测试,确保能够正常运行,适合学习和研究神经网络在控制系统中的应用。 特点 集成BP神经网络:模型中集成了BP神经网络用于提升PID控制器的性能,使之能更好地适应复杂控制环境。 PID控制优化:利用神经网络的自学习能力,对传统的PID控制算法进行了智能调整,提高控制精度和稳定性。 S函数应用:展示了如何在Simulink中通过S函数嵌入MATLAB代码,实现BP神经网络的定制化逻辑。 兼容性说明:虽然开发于Matlab 2016b,但理论上兼容后续版本,可能会需要调整少量配置以适配不同版本的Matlab。 使用指南 环境要求:确保你的电脑上安装有Matlab 2016b或更高版本。 模型加载: 下载本仓库到本地。 在Matlab中打开.slx文件。 运行仿真: 调整模型参数前,请先熟悉各模块功能和输入输出设置。 运行整个模型,观察控制效果。 参数调整: 用户可以自由调节神经网络的层数、节点数以及PID控制器的参数,探索不同的控制性能。 学习和修改: 通过阅读模型中的注释和查阅相关文献,加深对BP神经网络与PID控制结合的理解。 如需修改S函数内的MATLAB代码,建议有一定的MATLAB编程基础。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值