From 66b6d3a70c0d1e8ff1d755476ea16b9e9c41b47d Mon Sep 17 00:00:00 2001 From: pos3ym7vj <1226255226@qq.com> Date: Fri, 16 Dec 2022 11:01:56 +0800 Subject: [PATCH] ADD file via upload --- 6rnd.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 6rnd.h diff --git a/6rnd.h b/6rnd.h new file mode 100644 index 0000000..1bec33e --- /dev/null +++ b/6rnd.h @@ -0,0 +1,32 @@ +#pragma once +#include "des.h" +#include "hack.h" +using namespace std; + +int main() { + ull inA = 0, inB = 0, outA = 0, outB = 0; + ull inC = 0, inD = 0, outC = 0, outD = 0; + ull key = 0xF0F0F0F0F0F0F0F0; + /* ull key = 0xF1F2F3F4F5F6F7F8; */ + + DesHacker hacker; + for (int i = 0; i < 2; i++) { + constructCipherPlaintexts(key, 1, inA, inB, outA, outB); // 随机生成满足第一种差分特征的两个明密文对 + hacker.addCipherPlaintexts(inA, inB, outA, outB); // 将构造好的明密文对传入DesHacker中 + } + for (int i = 0; i < 2; i++) { + constructCipherPlaintexts(key, 2, inC, inD, outC, outD); // 随机生成满足第二种差分特征的两个明密文对 + hacker.addCipherPlaintexts(inC, inD, outC, outD); + } + + if (hacker.hack()) { // 差分分析 + ull result_key = hacker.getKey(); + printf("Success\n"); + print_long_hex(result_key); + } + else { + printf("Failed...\n"); + } + + return 0; +} \ No newline at end of file