Danny-1223 commited on
Commit
833db58
·
verified ·
1 Parent(s): ad499f2

Upload CREBench benchmark corpus (48 algorithms, 432 instances) (part 13)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__fprintf_chk_decompiled +10 -0
  3. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__gmon_start___decompiled +10 -0
  4. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__libc_start_main_decompiled +10 -0
  5. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__printf_chk_decompiled +10 -0
  6. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__stack_chk_fail_decompiled +10 -0
  7. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/entry_decompiled +13 -0
  8. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/memcmp_decompiled +11 -0
  9. CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/strlen_decompiled +11 -0
  10. CREBench/LOKI97/public-weak_prng_seeded-constxor/address.json +33 -0
  11. CREBench/LOKI97/public-weak_prng_seeded-constxor/challenge +0 -0
  12. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101020_decompiled +9 -0
  13. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_001010e0_decompiled +368 -0
  14. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_001019c0_decompiled +10 -0
  15. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_001019f0_decompiled +10 -0
  16. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101a80_decompiled +17 -0
  17. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101b10_decompiled +13 -0
  18. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101b30_decompiled +47 -0
  19. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101dc0_decompiled +7 -0
  20. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101dd0_decompiled +15 -0
  21. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101e10_decompiled +14 -0
  22. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_DT_FINI_decompiled +7 -0
  23. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_DT_INIT_decompiled +10 -0
  24. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_FINI_0_decompiled +15 -0
  25. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_INIT_0_decompiled +8 -0
  26. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_ITM_deregisterTMCloneTable_decompiled +10 -0
  27. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_ITM_registerTMCloneTable_decompiled +10 -0
  28. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__cxa_finalize_decompiled +10 -0
  29. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__fprintf_chk_decompiled +10 -0
  30. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__gmon_start___decompiled +10 -0
  31. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__libc_start_main_decompiled +10 -0
  32. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__printf_chk_decompiled +10 -0
  33. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__stack_chk_fail_decompiled +10 -0
  34. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/entry_decompiled +13 -0
  35. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/memcmp_decompiled +11 -0
  36. CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/strlen_decompiled +11 -0
  37. CREBench/LOKI97/src/loki97.c +315 -0
  38. CREBench/LOKI97/src/loki97.h +57 -0
  39. CREBench/LOKI97/test_vectors-fragmented_build.json +37 -0
  40. CREBench/LOKI97/test_vectors-hardcode_plain.json +37 -0
  41. CREBench/LOKI97/test_vectors-weak_prng_seeded.json +37 -0
  42. CREBench/Lucifer-128-ECB/Makefile +9 -0
  43. CREBench/Lucifer-128-ECB/challenge_src/Makefile +22 -0
  44. CREBench/Lucifer-128-ECB/challenge_src/challenge.c +66 -0
  45. CREBench/Lucifer-128-ECB/challenge_src/constxor_tables.c +199 -0
  46. CREBench/Lucifer-128-ECB/challenge_src/constxor_tables.h +10 -0
  47. CREBench/Lucifer-128-ECB/challenge_src/generated/fragmented_build/challenge.c +68 -0
  48. CREBench/Lucifer-128-ECB/challenge_src/generated/fragmented_build/key_source.c +34 -0
  49. CREBench/Lucifer-128-ECB/challenge_src/generated/fragmented_build/metadata.json +10 -0
  50. CREBench/Lucifer-128-ECB/challenge_src/generated/hardcode_plain/challenge.c +68 -0
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ CREBench/MAGENTA-128/magenta.pdf filter=lfs diff=lfs merge=lfs -text
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__fprintf_chk_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __fprintf_chk(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__gmon_start___decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __gmon_start__(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__libc_start_main_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __libc_start_main(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__printf_chk_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __printf_chk(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/__stack_chk_fail_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __stack_chk_fail(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/entry_decompiled ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void processEntry entry(undefined8 param_1,undefined8 param_2)
3
+
4
+ {
5
+ undefined auStack_8 [8];
6
+
7
+ (*(code *)PTR___libc_start_main_00103fd0)
8
+ (FUN_001010e0,param_2,&stack0x00000008,0,0,param_1,auStack_8);
9
+ do {
10
+ /* WARNING: Do nothing block with infinite loop */
11
+ } while( true );
12
+ }
13
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/memcmp_decompiled ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+ /* WARNING: Unknown calling convention -- yet parameter storage is locked */
4
+
5
+ int memcmp(void *__s1,void *__s2,size_t __n)
6
+
7
+ {
8
+ /* WARNING: Bad instruction - Truncating control flow here */
9
+ halt_baddata();
10
+ }
11
+
CREBench/LOKI97/public-weak_prng_seeded-O3/decompile/strlen_decompiled ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+ /* WARNING: Unknown calling convention -- yet parameter storage is locked */
4
+
5
+ size_t strlen(char *__s)
6
+
7
+ {
8
+ /* WARNING: Bad instruction - Truncating control flow here */
9
+ halt_baddata();
10
+ }
11
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/address.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "00101020": "FUN_00101020",
3
+ "00108018": "__stack_chk_fail",
4
+ "00101000": "_DT_INIT",
5
+ "00101dd0": "FUN_00101dd0",
6
+ "00108038": "__fprintf_chk",
7
+ "001019c0": "FUN_001019c0",
8
+ "00108010": "strlen",
9
+ "00101080": "__cxa_finalize",
10
+ "00108030": "__printf_chk",
11
+ "00108050": "__cxa_finalize",
12
+ "001010a0": "__stack_chk_fail",
13
+ "001010e0": "FUN_001010e0",
14
+ "001010c0": "__printf_chk",
15
+ "00101a80": "FUN_00101a80",
16
+ "00108008": "_ITM_deregisterTMCloneTable",
17
+ "00101990": "entry",
18
+ "00101dc0": "FUN_00101dc0",
19
+ "00108028": "__gmon_start__",
20
+ "00108000": "__libc_start_main",
21
+ "00101090": "strlen",
22
+ "00108020": "memcmp",
23
+ "00108040": "_ITM_registerTMCloneTable",
24
+ "001019f0": "FUN_001019f0",
25
+ "00101e10": "FUN_00101e10",
26
+ "00101e54": "_DT_FINI",
27
+ "001010b0": "memcmp",
28
+ "00101b30": "FUN_00101b30",
29
+ "00101a30": "_FINI_0",
30
+ "00101b10": "FUN_00101b10",
31
+ "00101a70": "_INIT_0",
32
+ "001010d0": "__fprintf_chk"
33
+ }
CREBench/LOKI97/public-weak_prng_seeded-constxor/challenge ADDED
Binary file (14.5 kB). View file
 
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101020_decompiled ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void FUN_00101020(void)
3
+
4
+ {
5
+ /* WARNING: Treating indirect jump as call */
6
+ (*(code *)PTR_00103fa0)();
7
+ return;
8
+ }
9
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_001010e0_decompiled ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
3
+
4
+ bool FUN_001010e0(int param_1,undefined8 *param_2)
5
+
6
+ {
7
+ char cVar1;
8
+ int iVar2;
9
+ int iVar3;
10
+ uint uVar4;
11
+ uint uVar5;
12
+ uint uVar6;
13
+ uint uVar7;
14
+ uint uVar8;
15
+ uint uVar9;
16
+ undefined uVar10;
17
+ int iVar11;
18
+ uint uVar12;
19
+ size_t sVar13;
20
+ uint *puVar14;
21
+ ulong uVar15;
22
+ ulong uVar16;
23
+ undefined8 uVar17;
24
+ uint uVar18;
25
+ uint uVar19;
26
+ uint uVar20;
27
+ uint uVar21;
28
+ int iVar22;
29
+ long lVar23;
30
+ char *pcVar24;
31
+ undefined1 *puVar25;
32
+ uint *puVar26;
33
+ uint uVar27;
34
+ ulong *puVar28;
35
+ long in_FS_OFFSET;
36
+ bool bVar29;
37
+ undefined8 extraout_XMM0_Qb;
38
+ int iVar30;
39
+ int iVar31;
40
+ int iVar32;
41
+ int iVar33;
42
+ ulong uVar34;
43
+ undefined auVar35 [16];
44
+ undefined auVar36 [16];
45
+ ulong uVar37;
46
+ undefined auVar38 [16];
47
+ byte local_288;
48
+ ulong *local_268;
49
+ ulong *local_260;
50
+ byte local_254;
51
+ ulong local_238 [48];
52
+ ulong local_b8 [4];
53
+ ulong local_98 [4];
54
+ undefined4 local_78;
55
+ undefined4 uStack_74;
56
+ undefined4 uStack_70;
57
+ undefined4 uStack_6c;
58
+ undefined4 local_68;
59
+ undefined4 uStack_64;
60
+ undefined4 uStack_60;
61
+ undefined4 uStack_5c;
62
+ undefined local_58 [8];
63
+ undefined local_50 [8];
64
+ undefined local_48 [8];
65
+ undefined local_40 [16];
66
+ long local_30;
67
+
68
+ local_30 = *(long *)(in_FS_OFFSET + 0x28);
69
+ if (param_1 == 2) {
70
+ FUN_00101a80(local_58);
71
+ pcVar24 = (char *)param_2[1];
72
+ local_78 = _DAT_00102130;
73
+ uStack_74 = _UNK_00102134;
74
+ uStack_70 = _UNK_00102138;
75
+ uStack_6c = _UNK_0010213c;
76
+ local_68 = _DAT_00102140;
77
+ uStack_64 = _UNK_00102144;
78
+ uStack_60 = _UNK_00102148;
79
+ uStack_5c = _UNK_0010214c;
80
+ sVar13 = strlen(pcVar24);
81
+ if (sVar13 == 0x40) {
82
+ lVar23 = 0;
83
+ do {
84
+ cVar1 = pcVar24[lVar23 * 2];
85
+ iVar11 = (int)cVar1;
86
+ if ((byte)(cVar1 - 0x30U) < 10) {
87
+ uVar21 = iVar11 - 0x30;
88
+ }
89
+ else if ((byte)(cVar1 + 0x9fU) < 6) {
90
+ uVar21 = iVar11 - 0x57;
91
+ }
92
+ else {
93
+ uVar21 = iVar11 - 0x37;
94
+ if (5 < (byte)(cVar1 + 0xbfU)) {
95
+ uVar21 = 0xffffffff;
96
+ }
97
+ }
98
+ cVar1 = pcVar24[lVar23 * 2 + 1];
99
+ iVar11 = (int)cVar1;
100
+ if ((byte)(cVar1 - 0x30U) < 10) {
101
+ uVar18 = iVar11 - 0x30;
102
+ }
103
+ else if ((byte)(cVar1 + 0x9fU) < 6) {
104
+ uVar18 = iVar11 - 0x57;
105
+ }
106
+ else {
107
+ if (5 < (byte)(cVar1 + 0xbfU)) goto LAB_0010122a;
108
+ uVar18 = iVar11 - 0x37;
109
+ }
110
+ if ((int)(uVar21 | uVar18) < 0) goto LAB_0010122a;
111
+ local_268 = local_98;
112
+ *(byte *)((long)local_98 + lVar23) = (byte)(uVar21 << 4) | (byte)uVar18;
113
+ lVar23 = lVar23 + 1;
114
+ } while (lVar23 != 0x20);
115
+ if (DAT_00107060 == 0) {
116
+ lVar23 = 0;
117
+ puVar26 = &DAT_00104050;
118
+ puVar25 = &DAT_00105060;
119
+ do {
120
+ FUN_00101e10();
121
+ uVar10 = 0;
122
+ if (lVar23 != 0x1fff) {
123
+ uVar19 = 0;
124
+ uVar21 = (uint)lVar23 ^ 0x1fff;
125
+ uVar18 = uVar21;
126
+ uVar12 = uVar21;
127
+ do {
128
+ if ((uVar12 & 1) != 0) {
129
+ uVar19 = uVar19 ^ uVar18;
130
+ }
131
+ uVar18 = uVar18 * 2;
132
+ if (0x1fff < (int)uVar18) {
133
+ uVar18 = uVar18 ^ *puVar26;
134
+ }
135
+ uVar12 = (int)uVar12 >> 1;
136
+ } while (uVar12 != 0);
137
+ if (uVar19 == 0) {
138
+ uVar10 = 0;
139
+ }
140
+ else {
141
+ uVar18 = 0;
142
+ do {
143
+ if ((uVar19 & 1) != 0) {
144
+ uVar18 = uVar18 ^ uVar21;
145
+ }
146
+ uVar10 = (undefined)uVar18;
147
+ uVar21 = uVar21 * 2;
148
+ if (0x1fff < (int)uVar21) {
149
+ uVar21 = uVar21 ^ *puVar26;
150
+ }
151
+ uVar19 = (int)uVar19 >> 1;
152
+ } while (uVar19 != 0);
153
+ }
154
+ }
155
+ puVar25[lVar23] = uVar10;
156
+ lVar23 = lVar23 + 1;
157
+ } while (lVar23 != 0x2000);
158
+ lVar23 = 0;
159
+ puVar25 = &DAT_00104860;
160
+ do {
161
+ FUN_00101e10();
162
+ uVar10 = 0;
163
+ if (lVar23 != 0x7ff) {
164
+ uVar19 = 0;
165
+ uVar21 = (uint)lVar23 ^ 0x7ff;
166
+ uVar18 = uVar21;
167
+ uVar12 = uVar21;
168
+ do {
169
+ if ((uVar12 & 1) != 0) {
170
+ uVar19 = uVar19 ^ uVar18;
171
+ }
172
+ uVar18 = uVar18 * 2;
173
+ if (0x7ff < (int)uVar18) {
174
+ uVar18 = uVar18 ^ DAT_00104054;
175
+ }
176
+ uVar12 = (int)uVar12 >> 1;
177
+ } while (uVar12 != 0);
178
+ if (uVar19 == 0) {
179
+ uVar10 = 0;
180
+ }
181
+ else {
182
+ uVar18 = 0;
183
+ do {
184
+ if ((uVar19 & 1) != 0) {
185
+ uVar18 = uVar18 ^ uVar21;
186
+ }
187
+ uVar10 = (undefined)uVar18;
188
+ uVar21 = uVar21 * 2;
189
+ if (0x7ff < (int)uVar21) {
190
+ uVar21 = uVar21 ^ DAT_00104054;
191
+ }
192
+ uVar19 = (int)uVar19 >> 1;
193
+ } while (uVar19 != 0);
194
+ }
195
+ }
196
+ puVar25[lVar23] = uVar10;
197
+ uVar9 = _UNK_0010212c;
198
+ uVar8 = _UNK_00102128;
199
+ uVar7 = _UNK_00102124;
200
+ uVar6 = _DAT_00102120;
201
+ uVar5 = _UNK_0010211c;
202
+ uVar4 = _UNK_00102118;
203
+ uVar27 = _UNK_00102114;
204
+ uVar20 = _DAT_00102110;
205
+ uVar19 = _UNK_0010210c;
206
+ uVar12 = _UNK_00102108;
207
+ uVar18 = _UNK_00102104;
208
+ uVar21 = _DAT_00102100;
209
+ iVar3 = _UNK_001020fc;
210
+ iVar2 = _UNK_001020f8;
211
+ iVar22 = _UNK_001020f4;
212
+ iVar11 = _DAT_001020f0;
213
+ lVar23 = lVar23 + 1;
214
+ } while (lVar23 != 0x800);
215
+ puVar26 = (uint *)&DAT_00104060;
216
+ iVar30 = _DAT_001020e0;
217
+ iVar31 = _UNK_001020e4;
218
+ iVar32 = _UNK_001020e8;
219
+ iVar33 = _UNK_001020ec;
220
+ do {
221
+ puVar14 = puVar26 + 8;
222
+ puVar26[4] = (iVar32 >> 5) << 0xf & uVar4 | (iVar32 >> 4) << 7 & uVar8 |
223
+ (iVar32 >> 7) << 0x1f | (iVar32 >> 6) << 0x17 & uVar12;
224
+ puVar26[5] = (iVar32 >> 2) << 0x17 & uVar12 | (iVar32 >> 1) << 0xf & uVar4 |
225
+ (iVar32 >> 3) << 0x1f | iVar32 << 7 & uVar8;
226
+ puVar26[6] = (iVar33 >> 5) << 0xf & uVar5 | (iVar33 >> 4) << 7 & uVar9 |
227
+ (iVar33 >> 7) << 0x1f | (iVar33 >> 6) << 0x17 & uVar19;
228
+ puVar26[7] = (iVar33 >> 2) << 0x17 & uVar19 | (iVar33 >> 1) << 0xf & uVar5 |
229
+ (iVar33 >> 3) << 0x1f | iVar33 << 7 & uVar9;
230
+ *puVar26 = (iVar30 >> 5) << 0xf & uVar20 | (iVar30 >> 4) << 7 & uVar6 |
231
+ (iVar30 >> 7) << 0x1f | (iVar30 >> 6) << 0x17 & uVar21;
232
+ puVar26[1] = (iVar30 >> 2) << 0x17 & uVar21 | (iVar30 >> 1) << 0xf & uVar20 |
233
+ (iVar30 >> 3) << 0x1f | iVar30 << 7 & uVar6;
234
+ puVar26[2] = (iVar31 >> 5) << 0xf & uVar27 | (iVar31 >> 4) << 7 & uVar7 |
235
+ (iVar31 >> 7) << 0x1f | (iVar31 >> 6) << 0x17 & uVar18;
236
+ puVar26[3] = (iVar31 >> 2) << 0x17 & uVar18 | (iVar31 >> 1) << 0xf & uVar27 |
237
+ (iVar31 >> 3) << 0x1f | iVar31 << 7 & uVar7;
238
+ puVar26 = puVar14;
239
+ iVar30 = iVar30 + iVar11;
240
+ iVar31 = iVar31 + iVar22;
241
+ iVar32 = iVar32 + iVar2;
242
+ iVar33 = iVar33 + iVar3;
243
+ } while (puVar14 != (uint *)&DAT_00104860);
244
+ DAT_00107060 = 1;
245
+ }
246
+ uVar15 = FUN_00101b10(local_58);
247
+ auVar38._8_8_ = 0;
248
+ auVar38._0_8_ = uVar15;
249
+ uVar15 = FUN_00101b10(local_50);
250
+ auVar36._8_8_ = 0;
251
+ auVar36._0_8_ = uVar15;
252
+ uVar15 = FUN_00101b10(local_48);
253
+ uVar16 = FUN_00101b10(local_40);
254
+ auVar35._8_8_ = 0;
255
+ auVar35._0_8_ = uVar16;
256
+ FUN_00101e10();
257
+ iVar11 = DAT_00104058;
258
+ FUN_00101e10();
259
+ puVar28 = local_238;
260
+ uVar21 = DAT_0010405c;
261
+ while( true ) {
262
+ uVar34 = auVar35._0_8_;
263
+ uVar37 = auVar38._0_8_;
264
+ uVar18 = auVar36._4_4_ + auVar35._4_4_;
265
+ uVar16 = FUN_00101b30(CONCAT44(uVar18 + uVar21,
266
+ ((auVar35._0_4_ + auVar36._0_4_ + 1) -
267
+ (uint)(CARRY4(auVar36._4_4_,auVar35._4_4_) == false)) +
268
+ iVar11 + (uint)CARRY4(uVar18,uVar21)),uVar15);
269
+ *puVar28 = uVar16 ^ uVar37;
270
+ FUN_00101e10();
271
+ auVar38 = auVar36;
272
+ iVar22 = DAT_00104058;
273
+ auVar35._0_8_ = FUN_00101e10();
274
+ auVar35._8_8_ = extraout_XMM0_Qb;
275
+ bVar29 = CARRY4(uVar21,DAT_0010405c);
276
+ uVar21 = uVar21 + DAT_0010405c;
277
+ iVar11 = (iVar11 + iVar22 + 1) - (uint)(bVar29 == false);
278
+ puVar28 = puVar28 + 1;
279
+ if (local_b8 == puVar28) break;
280
+ auVar36._8_8_ = 0;
281
+ auVar36._0_8_ = uVar15;
282
+ uVar15 = uVar34;
283
+ }
284
+ uVar16 = 0xaae434d8c779ec9a;
285
+ uVar15 = 0xcf39801b6a4b1c33;
286
+ local_260 = local_b8;
287
+ do {
288
+ uVar19 = ((uint)*(byte *)(local_268 + 1) ^ (uint)uVar15) << 0x18 |
289
+ (uint)(byte)((byte)(uVar15 >> 8) ^ *(byte *)((long)local_268 + 9)) << 0x10 |
290
+ (uint)(byte)((byte)(uVar15 >> 0x18) ^ *(byte *)((long)local_268 + 0xb)) |
291
+ (uint)(byte)((byte)(uVar15 >> 0x10) ^ *(byte *)((long)local_268 + 10)) << 8;
292
+ uVar12 = (uint)(byte)((byte)(uVar15 >> 0x20) ^ *(byte *)((long)local_268 + 0xc)) << 0x18 |
293
+ (uint)(byte)((byte)(uVar15 >> 0x28) ^ *(byte *)((long)local_268 + 0xd)) << 0x10 |
294
+ (uint)(byte)((byte)(uVar15 >> 0x38) ^ *(byte *)((long)local_268 + 0xf)) |
295
+ (uint)(byte)((byte)(uVar15 >> 0x30) ^ *(byte *)((long)local_268 + 0xe)) << 8;
296
+ iVar11 = 1;
297
+ puVar28 = local_238;
298
+ uVar21 = ((uint)*(byte *)local_268 ^ (uint)uVar16) << 0x18 |
299
+ (uint)(byte)((byte)(uVar16 >> 8) ^ *(byte *)((long)local_268 + 1)) << 0x10 |
300
+ (uint)(byte)((byte)(uVar16 >> 0x18) ^ *(byte *)((long)local_268 + 3)) |
301
+ (uint)(byte)((byte)(uVar16 >> 0x10) ^ *(byte *)((long)local_268 + 2)) << 8;
302
+ uVar18 = (uint)(byte)((byte)(uVar16 >> 0x20) ^ *(byte *)((long)local_268 + 4)) << 0x18 |
303
+ (uint)(byte)((byte)(uVar16 >> 0x28) ^ *(byte *)((long)local_268 + 5)) << 0x10 |
304
+ (uint)(byte)((byte)(uVar16 >> 0x38) ^ *(byte *)((long)local_268 + 7)) |
305
+ (uint)(byte)((byte)(uVar16 >> 0x30) ^ *(byte *)((long)local_268 + 6)) << 8;
306
+ do {
307
+ uVar27 = uVar12 + *(uint *)((long)puVar28 + 4);
308
+ iVar22 = uVar19 + *(int *)puVar28 + (uint)CARRY4(uVar12,*(uint *)((long)puVar28 + 4));
309
+ uVar17 = FUN_00101b30(CONCAT44(uVar27,iVar22),local_238[iVar11]);
310
+ uVar20 = uVar27 + *(uint *)((long)puVar28 + 0x14);
311
+ uVar27 = iVar22 + *(int *)(puVar28 + 2) +
312
+ (uint)CARRY4(uVar27,*(uint *)((long)puVar28 + 0x14));
313
+ puVar28 = puVar28 + 3;
314
+ iVar11 = iVar11 + 3;
315
+ uVar19 = uVar21 ^ (uint)uVar17;
316
+ uVar12 = uVar18 ^ (uint)((ulong)uVar17 >> 0x20);
317
+ uVar21 = uVar27;
318
+ uVar18 = uVar20;
319
+ } while (local_b8 != puVar28);
320
+ local_254 = (byte)(uVar20 >> 0x10);
321
+ local_288 = (byte)(uVar20 >> 0x18);
322
+ uVar16 = (((((((ulong)(uVar12 & 0xff) << 8 | (ulong)(uVar12 >> 8 & 0xff)) << 8 |
323
+ (ulong)(uVar12 >> 0x10 & 0xff)) << 8 | (ulong)(uVar12 >> 0x18)) << 8 |
324
+ (ulong)(uVar19 & 0xff)) << 8 | (ulong)(uVar19 >> 8 & 0xff)) << 8 |
325
+ (ulong)(uVar19 >> 0x10 & 0xff)) << 8 | (ulong)(uVar19 >> 0x18);
326
+ local_268 = local_268 + 2;
327
+ *local_260 = uVar16;
328
+ local_260[1] = (((((((ulong)(byte)uVar20 << 8 | (ulong)(uVar20 >> 8 & 0xff)) << 8 |
329
+ (ulong)local_254) << 8 | (ulong)local_288) << 8 | (ulong)(uVar27 & 0xff))
330
+ << 8 | (ulong)(uVar27 >> 8 & 0xff)) << 8 | (ulong)(uVar27 >> 0x10 & 0xff))
331
+ << 8 | (ulong)(uVar27 >> 0x18);
332
+ uVar15 = local_260[1];
333
+ local_260 = local_260 + 2;
334
+ } while (local_268 != (ulong *)&local_78);
335
+ __printf_chk(1,"Ciphertext(hex): ");
336
+ puVar28 = local_b8;
337
+ do {
338
+ uVar10 = *(undefined *)puVar28;
339
+ puVar28 = (ulong *)((long)puVar28 + 1);
340
+ __printf_chk(1,&DAT_0010203b,uVar10);
341
+ } while (puVar28 != local_98);
342
+ __printf_chk(1,"\n");
343
+ iVar11 = memcmp(local_b8,&local_78,0x20);
344
+ pcVar24 = "True";
345
+ if (iVar11 != 0) {
346
+ pcVar24 = "False";
347
+ }
348
+ __printf_chk(1,"Match: %s\n",pcVar24);
349
+ bVar29 = iVar11 != 0;
350
+ }
351
+ else {
352
+ LAB_0010122a:
353
+ __fprintf_chk(*(undefined8 *)PTR_stderr_00103ff8,1,
354
+ "Bad input hex. Expecting 64 hex chars (32 bytes).\n");
355
+ bVar29 = true;
356
+ }
357
+ }
358
+ else {
359
+ __fprintf_chk(*(undefined8 *)PTR_stderr_00103ff8,1,"Usage: %s <64-hex-chars>\n",*param_2);
360
+ bVar29 = true;
361
+ }
362
+ if (local_30 != *(long *)(in_FS_OFFSET + 0x28)) {
363
+ /* WARNING: Subroutine does not return */
364
+ __stack_chk_fail();
365
+ }
366
+ return bVar29;
367
+ }
368
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_001019c0_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Removing unreachable block (ram,0x001019d3) */
3
+ /* WARNING: Removing unreachable block (ram,0x001019df) */
4
+
5
+ void FUN_001019c0(void)
6
+
7
+ {
8
+ return;
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_001019f0_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Removing unreachable block (ram,0x00101a14) */
3
+ /* WARNING: Removing unreachable block (ram,0x00101a20) */
4
+
5
+ void FUN_001019f0(void)
6
+
7
+ {
8
+ return;
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101a80_decompiled ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void FUN_00101a80(long param_1,ulong param_2)
3
+
4
+ {
5
+ uint local_1c;
6
+ ulong local_18;
7
+
8
+ local_1c = 0x4ed90b4c;
9
+ for (local_18 = 0; local_18 < param_2; local_18 = local_18 + 1) {
10
+ local_1c = local_1c * 0x19660d + 0x3c6ef35f;
11
+ *(byte *)(local_18 + param_1) =
12
+ (byte)(local_1c >> (sbyte)(((uint)local_18 & 3) << 3)) ^
13
+ (&DAT_001020c0)[(uint)local_18 & 0x1f];
14
+ }
15
+ return;
16
+ }
17
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101b10_decompiled ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ undefined8 FUN_00101b10(uint *param_1)
3
+
4
+ {
5
+ uint uVar1;
6
+ uint uVar2;
7
+
8
+ uVar1 = *param_1;
9
+ uVar2 = param_1[1];
10
+ return CONCAT44(uVar2 >> 0x18 | (uVar2 & 0xff0000) >> 8 | (uVar2 & 0xff00) << 8 | uVar2 << 0x18,
11
+ uVar1 >> 0x18 | (uVar1 & 0xff0000) >> 8 | (uVar1 & 0xff00) << 8 | uVar1 << 0x18);
12
+ }
13
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101b30_decompiled ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ulong FUN_00101b30(undefined8 param_1,ulong param_2)
3
+
4
+ {
5
+ uint uVar1;
6
+ uint uVar2;
7
+ uint uVar3;
8
+ uint uVar4;
9
+
10
+ uVar1 = (uint)((ulong)param_1 >> 0x20);
11
+ uVar4 = (uVar1 ^ (uint)param_1) & (uint)(param_2 >> 0x20);
12
+ uVar3 = (uint)param_1 ^ uVar4;
13
+ uVar4 = uVar4 ^ uVar1;
14
+ uVar2 = *(uint *)(&DAT_00104060 + (ulong)(byte)(&DAT_00104860)[uVar3 & 0x7ff] * 8) >> 4 |
15
+ *(uint *)(&DAT_00104060 + (ulong)(byte)(&DAT_00105060)[uVar4 & 0x1fff] * 8) |
16
+ *(uint *)(&DAT_00104060 + (ulong)(byte)(&DAT_00104860)[uVar3 >> 0x10 & 0x7ff] * 8) >> 6 |
17
+ *(uint *)(&DAT_00104060 + (ulong)(byte)(&DAT_00105060)[uVar3 >> 8 & 0x1fff] * 8) >> 5 |
18
+ *(uint *)(&DAT_00104060 + (ulong)(byte)(&DAT_00105060)[uVar4 >> 0x10 & 0x1fff] * 8) >> 2 |
19
+ *(uint *)(&DAT_00104060 + (ulong)(byte)(&DAT_00104860)[uVar4 >> 8 & 0x7ff] * 8) >> 1 |
20
+ *(uint *)(&DAT_00104060 +
21
+ (ulong)(byte)(&DAT_00105060)[uVar3 >> 0x18 | (uVar4 & 0x1f) << 8] * 8) >> 7 |
22
+ *(uint *)(&DAT_00104060 +
23
+ (ulong)(byte)(&DAT_00104860)[(uVar3 & 7) << 8 | uVar4 >> 0x18] * 8) >> 3;
24
+ uVar1 = *(uint *)(&DAT_00104064 + (ulong)(byte)(&DAT_00104860)[uVar3 & 0x7ff] * 8) >> 4 |
25
+ *(uint *)(&DAT_00104064 + (ulong)(byte)(&DAT_00105060)[uVar4 & 0x1fff] * 8) |
26
+ *(uint *)(&DAT_00104064 + (ulong)(byte)(&DAT_00104860)[uVar3 >> 0x10 & 0x7ff] * 8) >> 6 |
27
+ *(uint *)(&DAT_00104064 + (ulong)(byte)(&DAT_00105060)[uVar3 >> 8 & 0x1fff] * 8) >> 5 |
28
+ *(uint *)(&DAT_00104064 + (ulong)(byte)(&DAT_00105060)[uVar4 >> 0x10 & 0x1fff] * 8) >> 2 |
29
+ *(uint *)(&DAT_00104064 + (ulong)(byte)(&DAT_00104860)[uVar4 >> 8 & 0x7ff] * 8) >> 1 |
30
+ *(uint *)(&DAT_00104064 +
31
+ (ulong)(byte)(&DAT_00105060)[uVar3 >> 0x18 | (uVar4 & 0x1f) << 8] * 8) >> 7 |
32
+ *(uint *)(&DAT_00104064 +
33
+ (ulong)(byte)(&DAT_00104860)[(uVar3 & 7) << 8 | uVar4 >> 0x18] * 8) >> 3;
34
+ return CONCAT44((uint)(byte)(&DAT_00105060)[uVar1 >> 8 & 0xff | (uint)param_2 * 8 & 0x1f00] << 8,
35
+ (uint)(byte)(&DAT_00105060)[uVar2 >> 8 & 0xff | (uint)(param_2 >> 0xd) & 0x1f00]
36
+ << 8) |
37
+ CONCAT44((uint)(byte)(&DAT_00104860)[uVar1 >> 0x10 & 0xff | (uint)(param_2 >> 2) & 0x700]
38
+ << 0x10,(uint)(byte)(&DAT_00104860)
39
+ [uVar2 >> 0x10 & 0xff | (uint)(param_2 >> 0x12) & 0x700] <<
40
+ 0x10) |
41
+ (ulong)CONCAT41((uint)(byte)(&DAT_00104860)[(uint)(param_2 >> 5) & 0x700 | uVar1 >> 0x18]
42
+ << 0x18,(&DAT_00104860)[(uint)(param_2 >> 0x15) & 0x700 | uVar2 >> 0x18])
43
+ << 0x18 | (ulong)CONCAT14((&DAT_00105060)[uVar1 & 0xff | ((uint)param_2 & 0x1f) << 8],
44
+ (uint)(byte)(&DAT_00105060)
45
+ [uVar2 & 0xff | (uint)(param_2 >> 8) & 0x1f00]);
46
+ }
47
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101dc0_decompiled ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+
2
+ void FUN_00101dc0(void)
3
+
4
+ {
5
+ return;
6
+ }
7
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101dd0_decompiled ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void FUN_00101dd0(uint *param_1,uint *param_2)
3
+
4
+ {
5
+ uint *extraout_RDX;
6
+
7
+ FUN_00101dc0();
8
+ *extraout_RDX = *param_1 ^ *param_2;
9
+ extraout_RDX[1] = param_1[1] ^ param_2[1];
10
+ extraout_RDX[2] = param_1[2] ^ param_2[2];
11
+ extraout_RDX[3] = param_1[3] ^ param_2[3];
12
+ FUN_00101dc0();
13
+ return;
14
+ }
15
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/FUN_00101e10_decompiled ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void FUN_00101e10(undefined8 param_1)
3
+
4
+ {
5
+ if (DAT_00104040 != 0) {
6
+ return;
7
+ }
8
+ FUN_00101dc0(param_1,&DAT_001020a0,&DAT_00104050,4);
9
+ FUN_00101dd0(&DAT_001020b0);
10
+ FUN_00101dc0();
11
+ DAT_00104040 = 1;
12
+ return;
13
+ }
14
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_DT_FINI_decompiled ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+
2
+ void _DT_FINI(void)
3
+
4
+ {
5
+ return;
6
+ }
7
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_DT_INIT_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void _DT_INIT(void)
3
+
4
+ {
5
+ if (PTR___gmon_start___00103fe0 != (undefined *)0x0) {
6
+ (*(code *)PTR___gmon_start___00103fe0)();
7
+ }
8
+ return;
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_FINI_0_decompiled ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void _FINI_0(void)
3
+
4
+ {
5
+ if (DAT_00104020 == '\0') {
6
+ if (PTR___cxa_finalize_00103ff0 != (undefined *)0x0) {
7
+ __cxa_finalize(PTR_LOOP_00104008);
8
+ }
9
+ FUN_001019c0();
10
+ DAT_00104020 = 1;
11
+ return;
12
+ }
13
+ return;
14
+ }
15
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_INIT_0_decompiled ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ void _INIT_0(void)
3
+
4
+ {
5
+ FUN_001019f0();
6
+ return;
7
+ }
8
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_ITM_deregisterTMCloneTable_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void _ITM_deregisterTMCloneTable(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/_ITM_registerTMCloneTable_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void _ITM_registerTMCloneTable(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__cxa_finalize_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __cxa_finalize(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__fprintf_chk_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __fprintf_chk(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__gmon_start___decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __gmon_start__(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__libc_start_main_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __libc_start_main(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__printf_chk_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __printf_chk(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/__stack_chk_fail_decompiled ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+
4
+ void __stack_chk_fail(void)
5
+
6
+ {
7
+ /* WARNING: Bad instruction - Truncating control flow here */
8
+ halt_baddata();
9
+ }
10
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/entry_decompiled ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ void processEntry entry(undefined8 param_1,undefined8 param_2)
3
+
4
+ {
5
+ undefined auStack_8 [8];
6
+
7
+ (*(code *)PTR___libc_start_main_00103fd0)
8
+ (FUN_001010e0,param_2,&stack0x00000008,0,0,param_1,auStack_8);
9
+ do {
10
+ /* WARNING: Do nothing block with infinite loop */
11
+ } while( true );
12
+ }
13
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/memcmp_decompiled ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+ /* WARNING: Unknown calling convention -- yet parameter storage is locked */
4
+
5
+ int memcmp(void *__s1,void *__s2,size_t __n)
6
+
7
+ {
8
+ /* WARNING: Bad instruction - Truncating control flow here */
9
+ halt_baddata();
10
+ }
11
+
CREBench/LOKI97/public-weak_prng_seeded-constxor/decompile/strlen_decompiled ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* WARNING: Control flow encountered bad instruction data */
3
+ /* WARNING: Unknown calling convention -- yet parameter storage is locked */
4
+
5
+ size_t strlen(char *__s)
6
+
7
+ {
8
+ /* WARNING: Bad instruction - Truncating control flow here */
9
+ halt_baddata();
10
+ }
11
+
CREBench/LOKI97/src/loki97.c ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Adapted for CREBench from the public LOKI97 reference implementations.
3
+ *
4
+ * Credits:
5
+ * LOKI97 was written by Lawrie Brown, Josef Pieprzyk, and Jennifer Seberry.
6
+ * Copyright (c) 1998 by Lawrie Brown and ITRACE (UNSW).
7
+ * All rights reserved.
8
+ */
9
+
10
+ #include "loki97.h"
11
+
12
+ #include <string.h>
13
+
14
+ #define LOKI97_ROUNDS 16
15
+ #define LOKI97_NUM_SUBKEYS (3 * LOKI97_ROUNDS)
16
+
17
+ #define S1_SIZE 0x2000
18
+ #define S2_SIZE 0x0800
19
+
20
+ static uint8_t s1[S1_SIZE];
21
+ static uint8_t s2[S2_SIZE];
22
+ static loki97_u64 perm_p[0x100];
23
+ static int loki97_init_done = 0;
24
+
25
+ #ifdef CONSTXOR_LOKI97_TABLES
26
+ #include "constxor_tables.h"
27
+ #define LOKI97_MAGIC_TABLE (constxor_loki97_magic())
28
+ #else
29
+ static const uint32_t loki97_magic[4] = {0x2911U, 0x0AA7U, 0x9E3779B9U, 0x7F4A7C15U};
30
+ #define LOKI97_MAGIC_TABLE (loki97_magic)
31
+ #endif
32
+
33
+ #define LOKI97_S1_GEN_VALUE ((int)LOKI97_MAGIC_TABLE[0])
34
+ #define LOKI97_S2_GEN_VALUE ((int)LOKI97_MAGIC_TABLE[1])
35
+ #define LOKI97_DELTA_VALUE ((loki97_u64){LOKI97_MAGIC_TABLE[2], LOKI97_MAGIC_TABLE[3]})
36
+
37
+ static int mult(int a, int b, int g, int n)
38
+ {
39
+ int p = 0;
40
+ while (b != 0) {
41
+ if ((b & 0x01) != 0) {
42
+ p ^= a;
43
+ }
44
+ a <<= 1;
45
+ if (a >= n) {
46
+ a ^= g;
47
+ }
48
+ b >>= 1;
49
+ }
50
+ return p;
51
+ }
52
+
53
+ static int exp3(int b, int g, int n)
54
+ {
55
+ int r = b;
56
+ if (b == 0) {
57
+ return 0;
58
+ }
59
+ b = mult(r, b, g, n);
60
+ r = mult(r, b, g, n);
61
+ return r;
62
+ }
63
+
64
+ static void loki97_init_tables(void)
65
+ {
66
+ if (loki97_init_done) {
67
+ return;
68
+ }
69
+
70
+ const int s1_mask = S1_SIZE - 1;
71
+ const int s2_mask = S2_SIZE - 1;
72
+
73
+ for (int i = 0; i < S1_SIZE; i++) {
74
+ int b = i ^ s1_mask;
75
+ s1[i] = (uint8_t)exp3(b, LOKI97_S1_GEN_VALUE, S1_SIZE);
76
+ }
77
+
78
+ for (int i = 0; i < S2_SIZE; i++) {
79
+ int b = i ^ s2_mask;
80
+ s2[i] = (uint8_t)exp3(b, LOKI97_S2_GEN_VALUE, S2_SIZE);
81
+ }
82
+
83
+ for (int i = 0; i < 0x100; i++) {
84
+ uint32_t pval = 0;
85
+ for (int j = 0, k = 7; j < 4; j++, k += 8) {
86
+ pval |= ((uint32_t)((i >> j) & 0x1) << k);
87
+ }
88
+ perm_p[i].r = pval;
89
+ pval = 0;
90
+ for (int j = 4, k = 7; j < 8; j++, k += 8) {
91
+ pval |= ((uint32_t)((i >> j) & 0x1) << k);
92
+ }
93
+ perm_p[i].l = pval;
94
+ }
95
+
96
+ loki97_init_done = 1;
97
+ }
98
+
99
+ static loki97_u64 add64(loki97_u64 a, loki97_u64 b)
100
+ {
101
+ loki97_u64 sum;
102
+ sum.r = a.r + b.r;
103
+ sum.l = a.l + b.l;
104
+ if (sum.r < b.r) {
105
+ sum.l++;
106
+ }
107
+ return sum;
108
+ }
109
+
110
+ static loki97_u64 sub64(loki97_u64 a, loki97_u64 b)
111
+ {
112
+ loki97_u64 diff;
113
+ diff.r = a.r - b.r;
114
+ diff.l = a.l - b.l;
115
+ if (diff.r > a.r) {
116
+ diff.l--;
117
+ }
118
+ return diff;
119
+ }
120
+
121
+ static loki97_u64 xor64(loki97_u64 a, loki97_u64 b)
122
+ {
123
+ loki97_u64 out;
124
+ out.l = a.l ^ b.l;
125
+ out.r = a.r ^ b.r;
126
+ return out;
127
+ }
128
+
129
+ static loki97_u64 load_u64(const uint8_t *in)
130
+ {
131
+ loki97_u64 v;
132
+ v.l = ((uint32_t)in[0] << 24) | ((uint32_t)in[1] << 16) | ((uint32_t)in[2] << 8) | (uint32_t)in[3];
133
+ v.r = ((uint32_t)in[4] << 24) | ((uint32_t)in[5] << 16) | ((uint32_t)in[6] << 8) | (uint32_t)in[7];
134
+ return v;
135
+ }
136
+
137
+ static void store_u64(uint8_t *out, loki97_u64 v)
138
+ {
139
+ out[0] = (uint8_t)(v.l >> 24);
140
+ out[1] = (uint8_t)(v.l >> 16);
141
+ out[2] = (uint8_t)(v.l >> 8);
142
+ out[3] = (uint8_t)v.l;
143
+ out[4] = (uint8_t)(v.r >> 24);
144
+ out[5] = (uint8_t)(v.r >> 16);
145
+ out[6] = (uint8_t)(v.r >> 8);
146
+ out[7] = (uint8_t)v.r;
147
+ }
148
+
149
+ static loki97_u64 f_func(loki97_u64 A, loki97_u64 B)
150
+ {
151
+ loki97_u64 d, e, f;
152
+ uint32_t s;
153
+
154
+ d.l = (A.l & ~B.r) | (A.r & B.r);
155
+ d.r = (A.r & ~B.r) | (A.l & B.r);
156
+
157
+ s = s1[((d.l >> 24) | (d.r << 8)) & 0x1FFF];
158
+ e.l = perm_p[s].l >> 7;
159
+ e.r = perm_p[s].r >> 7;
160
+ s = s2[(d.l >> 16) & 0x7FF];
161
+ e.l |= perm_p[s].l >> 6;
162
+ e.r |= perm_p[s].r >> 6;
163
+ s = s1[(d.l >> 8) & 0x1FFF];
164
+ e.l |= perm_p[s].l >> 5;
165
+ e.r |= perm_p[s].r >> 5;
166
+ s = s2[d.l & 0x7FF];
167
+ e.l |= perm_p[s].l >> 4;
168
+ e.r |= perm_p[s].r >> 4;
169
+ s = s2[((d.r >> 24) | (d.l << 8)) & 0x7FF];
170
+ e.l |= perm_p[s].l >> 3;
171
+ e.r |= perm_p[s].r >> 3;
172
+ s = s1[(d.r >> 16) & 0x1FFF];
173
+ e.l |= perm_p[s].l >> 2;
174
+ e.r |= perm_p[s].r >> 2;
175
+ s = s2[(d.r >> 8) & 0x7FF];
176
+ e.l |= perm_p[s].l >> 1;
177
+ e.r |= perm_p[s].r >> 1;
178
+ s = s1[d.r & 0x1FFF];
179
+ e.l |= perm_p[s].l;
180
+ e.r |= perm_p[s].r;
181
+
182
+ f.l = ((uint32_t)s2[((e.l >> 24) & 0xFF) | ((B.l >> 21) & 0x700)] << 24)
183
+ | ((uint32_t)s2[((e.l >> 16) & 0xFF) | ((B.l >> 18) & 0x700)] << 16)
184
+ | ((uint32_t)s1[((e.l >> 8) & 0xFF) | ((B.l >> 13) & 0x1F00)] << 8)
185
+ | ((uint32_t)s1[(e.l & 0xFF) | ((B.l >> 8) & 0x1F00)]);
186
+
187
+ f.r = ((uint32_t)s2[((e.r >> 24) & 0xFF) | ((B.l >> 5) & 0x700)] << 24)
188
+ | ((uint32_t)s2[((e.r >> 16) & 0xFF) | ((B.l >> 2) & 0x700)] << 16)
189
+ | ((uint32_t)s1[((e.r >> 8) & 0xFF) | ((B.l << 3) & 0x1F00)] << 8)
190
+ | ((uint32_t)s1[(e.r & 0xFF) | ((B.l << 8) & 0x1F00)]);
191
+
192
+ return f;
193
+ }
194
+
195
+ int loki97_set_key(loki97_ctx *ctx, const uint8_t *key, size_t key_len)
196
+ {
197
+ if (!ctx || !key) {
198
+ return -1;
199
+ }
200
+ if (key_len != 16 && key_len != 24 && key_len != 32) {
201
+ return -1;
202
+ }
203
+
204
+ loki97_init_tables();
205
+
206
+ loki97_u64 k4 = load_u64(key);
207
+ loki97_u64 k3 = load_u64(key + 8);
208
+ loki97_u64 k2;
209
+ loki97_u64 k1;
210
+
211
+ if (key_len == 16) {
212
+ k2 = f_func(k3, k4);
213
+ k1 = f_func(k4, k3);
214
+ } else {
215
+ k2 = load_u64(key + 16);
216
+ if (key_len == 24) {
217
+ k1 = f_func(k4, k3);
218
+ } else {
219
+ k1 = load_u64(key + 24);
220
+ }
221
+ }
222
+
223
+ loki97_u64 deltan = LOKI97_DELTA_VALUE;
224
+ for (int i = 0; i < LOKI97_NUM_SUBKEYS; i++) {
225
+ loki97_u64 t1 = add64(k1, k3);
226
+ loki97_u64 t2 = add64(t1, deltan);
227
+ loki97_u64 f_out = f_func(t2, k2);
228
+ ctx->sk[i] = xor64(k4, f_out);
229
+ k4 = k3;
230
+ k3 = k2;
231
+ k2 = k1;
232
+ k1 = ctx->sk[i];
233
+ deltan = add64(deltan, LOKI97_DELTA_VALUE);
234
+ }
235
+
236
+ return 0;
237
+ }
238
+
239
+ void loki97_encrypt_block(const loki97_ctx *ctx, const uint8_t *in, uint8_t *out)
240
+ {
241
+ loki97_u64 L = load_u64(in);
242
+ loki97_u64 R = load_u64(in + 8);
243
+ loki97_u64 nR;
244
+ loki97_u64 f_out;
245
+ int k = 0;
246
+
247
+ for (int i = 0; i < LOKI97_ROUNDS; i++) {
248
+ nR = add64(R, ctx->sk[k++]);
249
+ f_out = f_func(nR, ctx->sk[k++]);
250
+ nR = add64(nR, ctx->sk[k++]);
251
+ R = xor64(L, f_out);
252
+ L = nR;
253
+ }
254
+
255
+ store_u64(out, R);
256
+ store_u64(out + 8, L);
257
+ }
258
+
259
+ void loki97_decrypt_block(const loki97_ctx *ctx, const uint8_t *in, uint8_t *out)
260
+ {
261
+ loki97_u64 L = load_u64(in);
262
+ loki97_u64 R = load_u64(in + 8);
263
+ loki97_u64 nR;
264
+ loki97_u64 f_out;
265
+ int k = LOKI97_NUM_SUBKEYS - 1;
266
+
267
+ for (int i = 0; i < LOKI97_ROUNDS; i++) {
268
+ nR = sub64(R, ctx->sk[k--]);
269
+ f_out = f_func(nR, ctx->sk[k--]);
270
+ nR = sub64(nR, ctx->sk[k--]);
271
+ R = xor64(L, f_out);
272
+ L = nR;
273
+ }
274
+
275
+ store_u64(out, R);
276
+ store_u64(out + 8, L);
277
+ }
278
+
279
+ void loki97_cbc_encrypt(const loki97_ctx *ctx,
280
+ const uint8_t *iv,
281
+ const uint8_t *in,
282
+ uint8_t *out,
283
+ size_t len)
284
+ {
285
+ uint8_t prev[LOKI97_BLOCK_SIZE];
286
+ memcpy(prev, iv, sizeof(prev));
287
+
288
+ for (size_t offset = 0; offset < len; offset += LOKI97_BLOCK_SIZE) {
289
+ uint8_t block[LOKI97_BLOCK_SIZE];
290
+ for (size_t i = 0; i < LOKI97_BLOCK_SIZE; i++) {
291
+ block[i] = (uint8_t)(in[offset + i] ^ prev[i]);
292
+ }
293
+ loki97_encrypt_block(ctx, block, out + offset);
294
+ memcpy(prev, out + offset, LOKI97_BLOCK_SIZE);
295
+ }
296
+ }
297
+
298
+ void loki97_cbc_decrypt(const loki97_ctx *ctx,
299
+ const uint8_t *iv,
300
+ const uint8_t *in,
301
+ uint8_t *out,
302
+ size_t len)
303
+ {
304
+ uint8_t prev[LOKI97_BLOCK_SIZE];
305
+ memcpy(prev, iv, sizeof(prev));
306
+
307
+ for (size_t offset = 0; offset < len; offset += LOKI97_BLOCK_SIZE) {
308
+ uint8_t block[LOKI97_BLOCK_SIZE];
309
+ loki97_decrypt_block(ctx, in + offset, block);
310
+ for (size_t i = 0; i < LOKI97_BLOCK_SIZE; i++) {
311
+ out[offset + i] = (uint8_t)(block[i] ^ prev[i]);
312
+ }
313
+ memcpy(prev, in + offset, LOKI97_BLOCK_SIZE);
314
+ }
315
+ }
CREBench/LOKI97/src/loki97.h ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Adapted for CREBench from the public LOKI97 reference implementations.
3
+ *
4
+ * Credits:
5
+ * LOKI97 was written by Lawrie Brown, Josef Pieprzyk, and Jennifer Seberry.
6
+ * Copyright (c) 1998 by Lawrie Brown and ITRACE (UNSW).
7
+ * All rights reserved.
8
+ *
9
+ * LOKI97 Block Cipher - C implementation
10
+ *
11
+ * Block size: 128 bits (16 bytes)
12
+ * Key size: 128/192/256 bits (16/24/32 bytes)
13
+ */
14
+ #ifndef LOKI97_H
15
+ #define LOKI97_H
16
+
17
+ #include <stddef.h>
18
+ #include <stdint.h>
19
+
20
+ #define LOKI97_BLOCK_SIZE 16
21
+ #define LOKI97_MAX_KEY_SIZE 32
22
+
23
+ #ifdef __cplusplus
24
+ extern "C" {
25
+ #endif
26
+
27
+ typedef struct {
28
+ uint32_t l;
29
+ uint32_t r;
30
+ } loki97_u64;
31
+
32
+ typedef struct {
33
+ loki97_u64 sk[48];
34
+ } loki97_ctx;
35
+
36
+ int loki97_set_key(loki97_ctx *ctx, const uint8_t *key, size_t key_len);
37
+
38
+ void loki97_encrypt_block(const loki97_ctx *ctx, const uint8_t *in, uint8_t *out);
39
+ void loki97_decrypt_block(const loki97_ctx *ctx, const uint8_t *in, uint8_t *out);
40
+
41
+ void loki97_cbc_encrypt(const loki97_ctx *ctx,
42
+ const uint8_t *iv,
43
+ const uint8_t *in,
44
+ uint8_t *out,
45
+ size_t len);
46
+
47
+ void loki97_cbc_decrypt(const loki97_ctx *ctx,
48
+ const uint8_t *iv,
49
+ const uint8_t *in,
50
+ uint8_t *out,
51
+ size_t len);
52
+
53
+ #ifdef __cplusplus
54
+ }
55
+ #endif
56
+
57
+ #endif /* LOKI97_H */
CREBench/LOKI97/test_vectors-fragmented_build.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "plaintext": "b71bd2fa62e987bd5ed5e227ffe7d8d992fca702ac1e627e1352745e1bfb857d",
4
+ "key": "7e93756fb6efde96745e10fe9e01d40fdc547f09b762ba8d0a502db6309d7bd2",
5
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
6
+ "ciphertext": "fbdc6537f80c0fe3bff894f6cbb7a4821a8c3b0027fa9ae0e5fabe9a2dadf030",
7
+ "block_size": 16
8
+ },
9
+ {
10
+ "plaintext": "389f5c725ef0e9ef719ff5f0c5e054be80b1496193e75e04794ef16b9b934e7d",
11
+ "key": "7e93756fb6efde96745e10fe9e01d40fdc547f09b762ba8d0a502db6309d7bd2",
12
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
13
+ "ciphertext": "bd220c8ea5052b8367e9b2f0dfd0df3ab52e093d2b1c2531efed5033b2033e93",
14
+ "block_size": 16
15
+ },
16
+ {
17
+ "plaintext": "6feb5fe16d74493abe5f6bd6211dbbf46f38f17592bb31198cb3faaf5d80f36b",
18
+ "key": "7e93756fb6efde96745e10fe9e01d40fdc547f09b762ba8d0a502db6309d7bd2",
19
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
20
+ "ciphertext": "630023819f74bde6250004d766103c327b99488d0b9c500b4a6ce89da03b3578",
21
+ "block_size": 16
22
+ },
23
+ {
24
+ "plaintext": "099af1b541b236d7a8910813f98950b6c420fa2001282c0c25deba0d803e95b7",
25
+ "key": "7e93756fb6efde96745e10fe9e01d40fdc547f09b762ba8d0a502db6309d7bd2",
26
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
27
+ "ciphertext": "08cd8e2974f008b81957160cd2d534a3f27b10b78638e4ffd64f96935d936cf6",
28
+ "block_size": 16
29
+ },
30
+ {
31
+ "plaintext": "0ac36cfe0a12e57adfecdb76bf791f9dcda7c4b653cddc2a3782149372d9261b",
32
+ "key": "7e93756fb6efde96745e10fe9e01d40fdc547f09b762ba8d0a502db6309d7bd2",
33
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
34
+ "ciphertext": "6cb6e0904c2552ebc23d002262e4c29f1262ac72aeec671c52f1020ee9f8769c",
35
+ "block_size": 16
36
+ }
37
+ ]
CREBench/LOKI97/test_vectors-hardcode_plain.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "plaintext": "b71bd2fa62e987bd5ed5e227ffe7d8d992fca702ac1e627e1352745e1bfb857d",
4
+ "key": "37323cdc36471c5fa77253bb148eb5571a29cdcdf1527b968a151679f76eec7e",
5
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
6
+ "ciphertext": "98d58c2ee69053048ad22767c55b4c7cf31bf81d7f731f1da1ca770b5cef5c8f",
7
+ "block_size": 16
8
+ },
9
+ {
10
+ "plaintext": "389f5c725ef0e9ef719ff5f0c5e054be80b1496193e75e04794ef16b9b934e7d",
11
+ "key": "37323cdc36471c5fa77253bb148eb5571a29cdcdf1527b968a151679f76eec7e",
12
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
13
+ "ciphertext": "272248f095c76d76fe3e80814080bdabe10753a6e91a605a40a343dc7e215ef8",
14
+ "block_size": 16
15
+ },
16
+ {
17
+ "plaintext": "6feb5fe16d74493abe5f6bd6211dbbf46f38f17592bb31198cb3faaf5d80f36b",
18
+ "key": "37323cdc36471c5fa77253bb148eb5571a29cdcdf1527b968a151679f76eec7e",
19
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
20
+ "ciphertext": "e9aee36e22ad62963baa7951bc4a4d2ccde43c3794dba98f31e5c2af56c54e30",
21
+ "block_size": 16
22
+ },
23
+ {
24
+ "plaintext": "099af1b541b236d7a8910813f98950b6c420fa2001282c0c25deba0d803e95b7",
25
+ "key": "37323cdc36471c5fa77253bb148eb5571a29cdcdf1527b968a151679f76eec7e",
26
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
27
+ "ciphertext": "1d2380255e22750c7a57a17415b6e63c8f22fcfba567897bace1fc4c3124f41e",
28
+ "block_size": 16
29
+ },
30
+ {
31
+ "plaintext": "0ac36cfe0a12e57adfecdb76bf791f9dcda7c4b653cddc2a3782149372d9261b",
32
+ "key": "37323cdc36471c5fa77253bb148eb5571a29cdcdf1527b968a151679f76eec7e",
33
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
34
+ "ciphertext": "50f518f16432541536efc564cd33472f47afd269e0716dfa9e59da8c0302f3ab",
35
+ "block_size": 16
36
+ }
37
+ ]
CREBench/LOKI97/test_vectors-weak_prng_seeded.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "plaintext": "b71bd2fa62e987bd5ed5e227ffe7d8d992fca702ac1e627e1352745e1bfb857d",
4
+ "key": "177940216765e177aeb26dc3fe6998d8cb0a3477bc80a5cfabff8c3dc99c04c5",
5
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
6
+ "ciphertext": "f1cf0f5345310900ce4a43f68dcaeb5bd502cf0ed00852086b88b8fa12546120",
7
+ "block_size": 16
8
+ },
9
+ {
10
+ "plaintext": "389f5c725ef0e9ef719ff5f0c5e054be80b1496193e75e04794ef16b9b934e7d",
11
+ "key": "177940216765e177aeb26dc3fe6998d8cb0a3477bc80a5cfabff8c3dc99c04c5",
12
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
13
+ "ciphertext": "7a74e1333cf71ca051115831b85849329137214938898c248e019cb1a1773cef",
14
+ "block_size": 16
15
+ },
16
+ {
17
+ "plaintext": "6feb5fe16d74493abe5f6bd6211dbbf46f38f17592bb31198cb3faaf5d80f36b",
18
+ "key": "177940216765e177aeb26dc3fe6998d8cb0a3477bc80a5cfabff8c3dc99c04c5",
19
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
20
+ "ciphertext": "6052e319b50aa0c8066bd77a495865988089728de79197a7392ae74ad5123396",
21
+ "block_size": 16
22
+ },
23
+ {
24
+ "plaintext": "099af1b541b236d7a8910813f98950b6c420fa2001282c0c25deba0d803e95b7",
25
+ "key": "177940216765e177aeb26dc3fe6998d8cb0a3477bc80a5cfabff8c3dc99c04c5",
26
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
27
+ "ciphertext": "ab1167a2e108d4498da691a68c71815388c560cc0a9fc7224a4b4f7d2278e0c3",
28
+ "block_size": 16
29
+ },
30
+ {
31
+ "plaintext": "0ac36cfe0a12e57adfecdb76bf791f9dcda7c4b653cddc2a3782149372d9261b",
32
+ "key": "177940216765e177aeb26dc3fe6998d8cb0a3477bc80a5cfabff8c3dc99c04c5",
33
+ "iv": "9aec79c7d834e4aa331c4b6a1b8039cf",
34
+ "ciphertext": "501ab3cb34799f39046794ce3ecb255ec3fd29c0074fe0c019d4272357ef8ccf",
35
+ "block_size": 16
36
+ }
37
+ ]
CREBench/Lucifer-128-ECB/Makefile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: all challenge clean
2
+
3
+ all: challenge
4
+
5
+ challenge:
6
+ $(MAKE) -C challenge_src
7
+
8
+ clean:
9
+ $(MAKE) -C challenge_src clean
CREBench/Lucifer-128-ECB/challenge_src/Makefile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CC := cc
2
+ CFLAGS := -O3 -Wall -Wextra -std=c11
3
+ CPPFLAGS := -I../src
4
+ LTO ?= -flto
5
+ STRIP_CMD ?= strip
6
+
7
+ SRCS := challenge.c key_source.c ../src/lucifer.c
8
+ OBJS := $(SRCS:.c=.o)
9
+
10
+ TARGET := ../public/challenge
11
+
12
+ all: $(TARGET)
13
+
14
+ $(TARGET): $(OBJS)
15
+ @mkdir -p ../public
16
+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(LTO)
17
+ $(STRIP_CMD) $@
18
+
19
+ clean:
20
+ rm -f $(OBJS) $(TARGET)
21
+
22
+ .PHONY: all clean
CREBench/Lucifer-128-ECB/challenge_src/challenge.c ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include <stdio.h>
2
+ #include <string.h>
3
+ #include <stdlib.h>
4
+ #include "../src/lucifer.h"
5
+
6
+ extern void insecure_key_generate(uint8_t *key, size_t key_len);
7
+
8
+ static int hex_char_to_nibble(char c) {
9
+ if (c >= '0' && c <= '9') return c - '0';
10
+ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
11
+ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
12
+ return -1;
13
+ }
14
+
15
+ static int parse_hex(const char *hex, uint8_t *out, size_t out_len) {
16
+ size_t hex_len = strlen(hex);
17
+ if (hex_len != out_len * 2) return 0;
18
+ for (size_t i = 0; i < out_len; i++) {
19
+ int hi = hex_char_to_nibble(hex[2 * i]);
20
+ int lo = hex_char_to_nibble(hex[2 * i + 1]);
21
+ if (hi < 0 || lo < 0) return 0;
22
+ out[i] = (uint8_t)((hi << 4) | lo);
23
+ }
24
+ return 1;
25
+ }
26
+
27
+ static void print_hex(const unsigned char *buf, size_t len) {
28
+ for (size_t i = 0; i < len; i++) printf("%02x", buf[i]);
29
+ }
30
+
31
+ int main(int argc, char **argv) {
32
+ if (argc != 2) {
33
+ fprintf(stderr, "Usage: %s <64-hex-chars>\n", argv[0]);
34
+ return 1;
35
+ }
36
+
37
+ uint8_t key[LUCIFER_KEY_SIZE];
38
+ insecure_key_generate((uint8_t *)key, sizeof(key));
39
+
40
+ const uint8_t target_ciphertext[32] = {
41
+ 0x01, 0xab, 0xc4, 0x7a, 0x7d, 0x6a, 0x1c, 0x98,
42
+ 0xeb, 0xc9, 0xe1, 0x97, 0xdd, 0x58, 0x89, 0xfb,
43
+ 0xb6, 0x87, 0x46, 0x1e, 0xcc, 0x80, 0xad, 0x32,
44
+ 0xc3, 0xbf, 0xe0, 0xc6, 0x37, 0x24, 0x58, 0xbc
45
+ };
46
+
47
+ uint8_t plaintext[32];
48
+ if (!parse_hex(argv[1], plaintext, sizeof(plaintext))) {
49
+ fprintf(stderr, "Bad input hex. Expecting 64 hex chars (32 bytes).\n");
50
+ return 1;
51
+ }
52
+
53
+ lucifer_ctx ctx;
54
+ lucifer_set_encrypt_key(&ctx, key);
55
+
56
+ uint8_t ciphertext[32];
57
+ lucifer_ecb_encrypt(&ctx, plaintext, ciphertext, sizeof(ciphertext));
58
+
59
+ printf("Ciphertext(hex): ");
60
+ print_hex(ciphertext, sizeof(ciphertext));
61
+ printf("\n");
62
+
63
+ int same = memcmp(ciphertext, target_ciphertext, sizeof(ciphertext)) == 0;
64
+ printf("Match: %s\n", same ? "True" : "False");
65
+ return same ? 0 : 2;
66
+ }
CREBench/Lucifer-128-ECB/challenge_src/constxor_tables.c ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #include "constxor_tables.h"
2
+
3
+ #include <stddef.h>
4
+
5
+ __attribute__((noinline, noclone))
6
+ static void constxor_compiler_barrier(void) {
7
+ __asm__ __volatile__("" ::: "memory");
8
+ }
9
+
10
+ __attribute__((noinline, noclone))
11
+ static void materialize_u8_table(const uint8_t *lhs_raw, const uint8_t *rhs_raw, uint8_t *out, size_t count) {
12
+ const volatile uint8_t *lhs = (const volatile uint8_t *)lhs_raw;
13
+ const volatile uint8_t *rhs = (const volatile uint8_t *)rhs_raw;
14
+ constxor_compiler_barrier();
15
+ for (size_t i = 0; i < count; ++i) {
16
+ out[i] = (uint8_t)(lhs[i] ^ rhs[i]);
17
+ }
18
+ constxor_compiler_barrier();
19
+ }
20
+
21
+ __attribute__((noinline, noclone))
22
+ static void materialize_u16_table(const uint16_t *lhs_raw, const uint16_t *rhs_raw, uint16_t *out, size_t count) {
23
+ const volatile uint16_t *lhs = (const volatile uint16_t *)lhs_raw;
24
+ const volatile uint16_t *rhs = (const volatile uint16_t *)rhs_raw;
25
+ constxor_compiler_barrier();
26
+ for (size_t i = 0; i < count; ++i) {
27
+ out[i] = (uint16_t)(lhs[i] ^ rhs[i]);
28
+ }
29
+ constxor_compiler_barrier();
30
+ }
31
+
32
+ __attribute__((noinline, noclone))
33
+ static void materialize_u64_table(const uint64_t *lhs_raw, const uint64_t *rhs_raw, uint64_t *out, size_t count) {
34
+ const volatile uint64_t *lhs = (const volatile uint64_t *)lhs_raw;
35
+ const volatile uint64_t *rhs = (const volatile uint64_t *)rhs_raw;
36
+ constxor_compiler_barrier();
37
+ for (size_t i = 0; i < count; ++i) {
38
+ out[i] = lhs[i] ^ rhs[i];
39
+ }
40
+ constxor_compiler_barrier();
41
+ }
42
+
43
+ __attribute__((noinline, noclone))
44
+ static void materialize_u32_table(const uint32_t *lhs_raw, const uint32_t *rhs_raw, uint32_t *out, size_t count) {
45
+ const volatile uint32_t *lhs = (const volatile uint32_t *)lhs_raw;
46
+ const volatile uint32_t *rhs = (const volatile uint32_t *)rhs_raw;
47
+ constxor_compiler_barrier();
48
+ for (size_t i = 0; i < count; ++i) {
49
+ out[i] = lhs[i] ^ rhs[i];
50
+ }
51
+ constxor_compiler_barrier();
52
+ }
53
+
54
+ static const uint8_t Dps_xor_lhs[64] = {
55
+ 0x30, 0x86, 0x85, 0x0C, 0xB9, 0xC7, 0xC4, 0xEC, 0x76, 0xCF, 0xB0, 0xA2, 0xFE, 0x43, 0x55, 0x96,
56
+ 0xC3, 0x8B, 0x5B, 0x24, 0x0C, 0x33, 0x97, 0xB5, 0x19, 0x34, 0x0B, 0x28, 0x34, 0xE2, 0x21, 0x4D,
57
+ 0x52, 0xFB, 0x0E, 0xD3, 0x6A, 0xEB, 0xF6, 0xC0, 0x9D, 0x33, 0xDE, 0xBB, 0x2B, 0x3D, 0x4B, 0x16,
58
+ 0x06, 0xAF, 0x84, 0xC2, 0xA6, 0xB9, 0xDE, 0x09, 0xE7, 0x38, 0x8C, 0x11, 0x32, 0x04, 0xF8, 0x55
59
+ };
60
+
61
+ static const uint8_t Dps_xor_rhs[64] = {
62
+ 0x34, 0x96, 0xA5, 0x0E, 0xB8, 0xCF, 0x84, 0x6C, 0xF6, 0xCB, 0xA0, 0x82, 0xFC, 0x42, 0x5D, 0xD6,
63
+ 0x83, 0x0B, 0x5F, 0x34, 0x2C, 0x31, 0x96, 0xBD, 0x11, 0x74, 0x8B, 0x2C, 0x24, 0xC2, 0x23, 0x4C,
64
+ 0x53, 0xF3, 0x4E, 0x53, 0x6E, 0xFB, 0xD6, 0xC2, 0x9F, 0x32, 0xD6, 0xFB, 0xAB, 0x39, 0x5B, 0x36,
65
+ 0x26, 0xAD, 0x85, 0xCA, 0xE6, 0x39, 0xDA, 0x19, 0xF7, 0x18, 0x8E, 0x10, 0x3A, 0x44, 0x78, 0x51
66
+ };
67
+
68
+ static uint8_t Dps_decoded[64];
69
+ static int Dps_ready;
70
+
71
+ __attribute__((noinline, noclone))
72
+ static void ensure_Dps_decoded(void) {
73
+ if (Dps_ready) {
74
+ return;
75
+ }
76
+ constxor_compiler_barrier();
77
+ materialize_u8_table(Dps_xor_lhs, Dps_xor_rhs, Dps_decoded, 64);
78
+ constxor_compiler_barrier();
79
+ Dps_ready = 1;
80
+ }
81
+
82
+ const uint8_t *constxor_lucifer_dps(void) {
83
+ ensure_Dps_decoded();
84
+ return Dps_decoded;
85
+ }
86
+
87
+ static const uint8_t TCB0_xor_lhs[256] = {
88
+ 0xA6, 0x37, 0xC7, 0x39, 0x66, 0xCE, 0x11, 0x67, 0x37, 0x16, 0x68, 0x5F, 0x9C, 0x3F, 0xDA, 0xF8,
89
+ 0xE7, 0xA7, 0xB5, 0xC4, 0x1D, 0xCF, 0x0F, 0x22, 0x22, 0x78, 0xE0, 0xE8, 0x9E, 0x5F, 0xD0, 0x30,
90
+ 0xA6, 0xAD, 0x14, 0xB6, 0xD7, 0x51, 0x9C, 0xBA, 0x47, 0xA5, 0x7A, 0x48, 0x1A, 0x62, 0x52, 0xCD,
91
+ 0x12, 0xB5, 0xEA, 0xFA, 0x8C, 0xA0, 0xE0, 0x8C, 0xE5, 0xF0, 0x59, 0x90, 0x4D, 0xDB, 0xF2, 0x5C,
92
+ 0xE7, 0x96, 0x43, 0x21, 0x0A, 0x1F, 0x7F, 0x7B, 0x0C, 0xE0, 0x4E, 0x56, 0x8A, 0xB3, 0x99, 0x9E,
93
+ 0x43, 0x6C, 0xB5, 0xAA, 0x7F, 0x36, 0x58, 0xA6, 0x22, 0x86, 0x28, 0x29, 0xC2, 0xFA, 0xEA, 0x0B,
94
+ 0x84, 0x11, 0x18, 0x73, 0xE3, 0x6D, 0x47, 0xAF, 0x27, 0x03, 0x07, 0xCF, 0x4C, 0xAD, 0x8F, 0x81,
95
+ 0x18, 0x92, 0xE4, 0xB1, 0x11, 0x8C, 0x4B, 0xAC, 0xD9, 0x90, 0x31, 0x91, 0x64, 0x7C, 0x5C, 0xB1,
96
+ 0xEB, 0x0A, 0xA2, 0xC2, 0x71, 0xEB, 0x4C, 0x08, 0xCC, 0xF5, 0xD4, 0xE1, 0x2E, 0x58, 0xE2, 0xAC,
97
+ 0x97, 0x7E, 0x8D, 0xE2, 0x34, 0x0F, 0x6F, 0xED, 0x46, 0x7F, 0xB6, 0x8D, 0xE1, 0x44, 0xC5, 0x07,
98
+ 0x48, 0x82, 0x60, 0x33, 0x1E, 0x10, 0x03, 0x0B, 0x46, 0xF3, 0xFB, 0x9C, 0x35, 0x66, 0x02, 0x7D,
99
+ 0x64, 0xA6, 0x47, 0xCE, 0x3E, 0x5A, 0x05, 0xD0, 0xD0, 0x8D, 0xE5, 0x95, 0x45, 0x3F, 0x7C, 0xB9,
100
+ 0xE3, 0xD2, 0xFC, 0xE3, 0x08, 0x4D, 0x3E, 0x88, 0x58, 0x30, 0x77, 0xE2, 0xC2, 0xAF, 0x5B, 0x1A,
101
+ 0xEC, 0x30, 0xB0, 0x9D, 0x85, 0xE6, 0x8C, 0x4D, 0x6A, 0xAF, 0xFB, 0x2F, 0xC1, 0xB8, 0x82, 0xD1,
102
+ 0x95, 0x4E, 0x29, 0x3F, 0x23, 0x28, 0x32, 0x8F, 0x02, 0x68, 0x19, 0xB9, 0x71, 0x49, 0xCE, 0x87,
103
+ 0x2E, 0x98, 0xEF, 0xD8, 0xC0, 0xD0, 0xBC, 0x44, 0x9A, 0x29, 0x28, 0x81, 0xC6, 0xCE, 0xA2, 0x80
104
+ };
105
+
106
+ static const uint8_t TCB0_xor_rhs[256] = {
107
+ 0xF1, 0x22, 0xB2, 0x0F, 0x71, 0xF9, 0x05, 0x33, 0x43, 0x60, 0x7E, 0x6A, 0xC9, 0x48, 0xEE, 0xAE,
108
+ 0x38, 0x3A, 0x48, 0x7A, 0x82, 0x70, 0x93, 0xFE, 0xDE, 0x86, 0x7E, 0x55, 0x43, 0xA0, 0x6C, 0xEE,
109
+ 0x69, 0x20, 0xF9, 0x18, 0x58, 0xFE, 0x10, 0x76, 0xAB, 0x4B, 0xF4, 0xE5, 0xD7, 0x8D, 0xFE, 0x03,
110
+ 0xC1, 0x24, 0x1B, 0x48, 0x1F, 0x13, 0x70, 0x5C, 0x15, 0x02, 0xCB, 0x21, 0x9C, 0x28, 0x42, 0x8E,
111
+ 0x30, 0x03, 0xB6, 0x97, 0x9D, 0xA8, 0xEB, 0xAF, 0xF8, 0x16, 0xD8, 0xE3, 0x5F, 0x44, 0x2D, 0x48,
112
+ 0x1C, 0x71, 0xC8, 0x94, 0x60, 0x09, 0x44, 0xFA, 0x5E, 0xF8, 0x36, 0x14, 0x9F, 0x85, 0xD6, 0x55,
113
+ 0x5F, 0x88, 0xE1, 0xC9, 0x78, 0xD6, 0xDF, 0x77, 0xDF, 0xF9, 0x9D, 0x76, 0x95, 0x56, 0x37, 0x5B,
114
+ 0x5B, 0x93, 0x85, 0x93, 0x12, 0xAF, 0x4B, 0xEC, 0xB9, 0xF2, 0x33, 0xB0, 0x25, 0x1F, 0x7C, 0xF3,
115
+ 0x28, 0x8B, 0x43, 0x60, 0xF2, 0x48, 0xCC, 0xC8, 0x2C, 0x17, 0x56, 0x40, 0xEF, 0xBB, 0x42, 0x6E,
116
+ 0x50, 0xFB, 0x68, 0x44, 0xB3, 0xA8, 0xEB, 0x29, 0xA2, 0x99, 0x30, 0x28, 0x24, 0xA3, 0x61, 0xC1,
117
+ 0x83, 0x0B, 0x89, 0x99, 0x95, 0xBB, 0x8B, 0xC3, 0xAE, 0x19, 0x71, 0x35, 0xFC, 0x8D, 0xAA, 0xB7,
118
+ 0x2F, 0xAF, 0x2E, 0xE4, 0x35, 0x71, 0x0D, 0x98, 0xB8, 0xE7, 0xEF, 0xBC, 0x0C, 0x54, 0x54, 0xF3,
119
+ 0xB8, 0xCB, 0x85, 0xD9, 0x13, 0x76, 0x26, 0xD0, 0x20, 0x4A, 0x6D, 0xDB, 0x9B, 0xD4, 0x63, 0x40,
120
+ 0xAB, 0x35, 0xD5, 0xBB, 0x82, 0xC1, 0x88, 0x09, 0x0E, 0xC9, 0xFD, 0x0A, 0x84, 0xDF, 0xA6, 0x97,
121
+ 0xDA, 0x43, 0x44, 0x11, 0x2C, 0x07, 0x3E, 0xC3, 0x6E, 0x06, 0x17, 0x94, 0x3C, 0x26, 0xE2, 0xC9,
122
+ 0x7D, 0x89, 0x9E, 0xEA, 0xD3, 0xE3, 0xAC, 0x14, 0xEA, 0x5B, 0x3A, 0xB0, 0x97, 0xBD, 0x92, 0xD2
123
+ };
124
+
125
+ static uint8_t TCB0_decoded[256];
126
+ static int TCB0_ready;
127
+
128
+ __attribute__((noinline, noclone))
129
+ static void ensure_TCB0_decoded(void) {
130
+ if (TCB0_ready) {
131
+ return;
132
+ }
133
+ constxor_compiler_barrier();
134
+ materialize_u8_table(TCB0_xor_lhs, TCB0_xor_rhs, TCB0_decoded, 256);
135
+ constxor_compiler_barrier();
136
+ TCB0_ready = 1;
137
+ }
138
+
139
+ const uint8_t *constxor_lucifer_tcb0(void) {
140
+ ensure_TCB0_decoded();
141
+ return TCB0_decoded;
142
+ }
143
+
144
+ static const uint8_t TCB1_xor_lhs[256] = {
145
+ 0x38, 0x21, 0x2E, 0x9B, 0xAD, 0x6F, 0xE8, 0x58, 0x05, 0x03, 0xD0, 0x4A, 0xD2, 0xAE, 0x72, 0xE1,
146
+ 0xC1, 0x57, 0xAC, 0x01, 0xE8, 0x8C, 0xE4, 0xE9, 0x7F, 0x3E, 0x39, 0x8D, 0x3A, 0xA1, 0xD6, 0x61,
147
+ 0x5A, 0xFE, 0xA4, 0xCC, 0x04, 0x92, 0xDF, 0x80, 0x2D, 0xA2, 0xAC, 0xC9, 0xBE, 0x21, 0x1D, 0xC7,
148
+ 0xD1, 0xD8, 0x9A, 0xD0, 0x7D, 0x87, 0x7F, 0xDE, 0xD9, 0x10, 0x87, 0x3A, 0x19, 0x4E, 0xA2, 0xA8,
149
+ 0x86, 0x41, 0xDF, 0x9E, 0x31, 0x4F, 0xF4, 0xDF, 0x5C, 0x27, 0xB8, 0x32, 0x0C, 0x6A, 0x00, 0x41,
150
+ 0xE2, 0x8F, 0xBB, 0x15, 0x0E, 0xE8, 0x3A, 0xD9, 0xBE, 0x99, 0x46, 0xD0, 0x4B, 0x50, 0xE1, 0x37,
151
+ 0xE8, 0xAF, 0xA0, 0xB0, 0x21, 0x8A, 0x0A, 0xC5, 0x82, 0x6B, 0x93, 0x26, 0xFC, 0xF3, 0x92, 0xF6,
152
+ 0x1B, 0x28, 0x9F, 0x0C, 0xB3, 0x7A, 0x9C, 0x11, 0x73, 0xE1, 0xCD, 0x02, 0x1B, 0xAC, 0xA1, 0x9C,
153
+ 0xFF, 0x2C, 0xCF, 0xFB, 0xA2, 0x9B, 0x08, 0x98, 0xD5, 0xBA, 0x20, 0x3A, 0x39, 0x11, 0x56, 0x84,
154
+ 0xD3, 0x52, 0x15, 0x6F, 0x76, 0xAC, 0x14, 0x24, 0xEC, 0xDC, 0xD2, 0x02, 0x55, 0x55, 0x1E, 0xA6,
155
+ 0x9C, 0xC0, 0xC8, 0x75, 0x31, 0x04, 0x72, 0xB8, 0xEF, 0x37, 0x04, 0x70, 0xB6, 0x32, 0x89, 0xF1,
156
+ 0x06, 0xA2, 0x1C, 0x6E, 0x57, 0xC9, 0x93, 0x79, 0xD8, 0xCC, 0xE6, 0xB3, 0xB6, 0xA2, 0x8C, 0x46,
157
+ 0x92, 0xD6, 0x29, 0x95, 0xD2, 0xF6, 0x95, 0x99, 0xAA, 0x66, 0xFF, 0x5D, 0xC8, 0x1D, 0xA3, 0xC2,
158
+ 0x79, 0x0A, 0x0C, 0xCC, 0x31, 0xEA, 0xEB, 0x91, 0xE8, 0x5D, 0xC0, 0x37, 0xFC, 0xBC, 0x92, 0xC4,
159
+ 0x4D, 0x43, 0x01, 0x28, 0xFD, 0x35, 0x3C, 0x7B, 0x35, 0x45, 0x46, 0x80, 0x06, 0x51, 0x8E, 0xE2,
160
+ 0x93, 0x0B, 0x62, 0x05, 0xC0, 0x3C, 0x83, 0xBE, 0xE3, 0xCC, 0x05, 0x85, 0x3D, 0x2F, 0xE3, 0x40
161
+ };
162
+
163
+ static const uint8_t TCB1_xor_rhs[256] = {
164
+ 0x6F, 0xFE, 0xE1, 0x48, 0x7A, 0x30, 0x33, 0x1B, 0xC6, 0xC4, 0x1B, 0x01, 0x89, 0xE9, 0x3D, 0xB2,
165
+ 0xD4, 0xCA, 0x21, 0x90, 0x7D, 0x91, 0x7D, 0xE8, 0xFE, 0xBB, 0xB0, 0x84, 0x23, 0xA4, 0xDB, 0x70,
166
+ 0x2F, 0x03, 0x49, 0x3D, 0xF1, 0xEF, 0x26, 0xE1, 0xCC, 0x47, 0x45, 0xA0, 0xC7, 0x44, 0x70, 0xB6,
167
+ 0xE7, 0x66, 0x34, 0x62, 0xCB, 0xB9, 0xC5, 0xFC, 0x7B, 0xB6, 0x2D, 0x10, 0x23, 0x68, 0x8C, 0x9A,
168
+ 0x91, 0xDE, 0x50, 0x0D, 0xA6, 0x50, 0x6F, 0xDC, 0xDF, 0xA0, 0x33, 0x39, 0x17, 0x6D, 0x0F, 0x52,
169
+ 0xD5, 0x30, 0x14, 0xA6, 0xB9, 0xD7, 0x81, 0xFA, 0x1D, 0x3E, 0xED, 0xFB, 0x70, 0x77, 0xCE, 0x04,
170
+ 0xFC, 0x33, 0x2C, 0x20, 0xB5, 0x96, 0x92, 0xC5, 0x02, 0xEF, 0x1B, 0x2E, 0xE4, 0xF7, 0x9E, 0xE6,
171
+ 0x4F, 0xF4, 0x53, 0xDC, 0x67, 0x26, 0x44, 0x51, 0xB3, 0x25, 0x05, 0x4A, 0x43, 0xE8, 0xED, 0xCC,
172
+ 0x8B, 0xD0, 0x23, 0x0B, 0x56, 0xE7, 0xF0, 0xF8, 0x35, 0x5E, 0xC8, 0x52, 0x41, 0x75, 0x3A, 0xF4,
173
+ 0xA5, 0xAC, 0xFB, 0x9D, 0x80, 0xD2, 0xEE, 0x46, 0x0E, 0x3A, 0x38, 0x68, 0x2F, 0x33, 0x70, 0xD4,
174
+ 0x8A, 0x5E, 0x46, 0xE7, 0xA7, 0x1A, 0xE8, 0xBA, 0x6D, 0xB1, 0x8E, 0x7A, 0xAC, 0x34, 0x87, 0xE3,
175
+ 0x33, 0x1F, 0xB1, 0xDF, 0xE2, 0xF4, 0x2A, 0x58, 0x79, 0x69, 0x4F, 0x9A, 0x8F, 0x87, 0xA1, 0x77,
176
+ 0xC7, 0x0B, 0xE4, 0x44, 0x07, 0xAB, 0x4C, 0xD8, 0x6B, 0xA3, 0x36, 0x14, 0x91, 0x58, 0xEE, 0x93,
177
+ 0x0E, 0xF5, 0xE3, 0x3F, 0xC6, 0x95, 0x10, 0xF2, 0x0B, 0xBA, 0x2B, 0x5C, 0x87, 0xDB, 0xFD, 0xB7,
178
+ 0x79, 0xFF, 0xAD, 0x98, 0x49, 0x09, 0x84, 0x5B, 0x95, 0xE1, 0xEE, 0xA8, 0x3E, 0x75, 0xA2, 0xD2,
179
+ 0xC5, 0xD5, 0xAC, 0xD7, 0x16, 0x62, 0x59, 0xFC, 0x21, 0x0A, 0xCF, 0xCF, 0x67, 0x69, 0xAD, 0x12
180
+ };
181
+
182
+ static uint8_t TCB1_decoded[256];
183
+ static int TCB1_ready;
184
+
185
+ __attribute__((noinline, noclone))
186
+ static void ensure_TCB1_decoded(void) {
187
+ if (TCB1_ready) {
188
+ return;
189
+ }
190
+ constxor_compiler_barrier();
191
+ materialize_u8_table(TCB1_xor_lhs, TCB1_xor_rhs, TCB1_decoded, 256);
192
+ constxor_compiler_barrier();
193
+ TCB1_ready = 1;
194
+ }
195
+
196
+ const uint8_t *constxor_lucifer_tcb1(void) {
197
+ ensure_TCB1_decoded();
198
+ return TCB1_decoded;
199
+ }
CREBench/Lucifer-128-ECB/challenge_src/constxor_tables.h ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef CONSTXOR_TABLES_H
2
+ #define CONSTXOR_TABLES_H
3
+
4
+ #include <stdint.h>
5
+
6
+ const uint8_t *constxor_lucifer_dps(void);
7
+ const uint8_t *constxor_lucifer_tcb0(void);
8
+ const uint8_t *constxor_lucifer_tcb1(void);
9
+
10
+ #endif /* CONSTXOR_TABLES_H */
CREBench/Lucifer-128-ECB/challenge_src/generated/fragmented_build/challenge.c ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* key_mode=fragmented_build variant=randomized challenge=Lucifer-128-ECB */
2
+ /* canonical_flag=4cde8c3e531d8400971b8e064f31e7c627fb6bd1ece498fb510b10fb2756fb21 */
3
+ #include <stdio.h>
4
+ #include <string.h>
5
+ #include <stdlib.h>
6
+ #include "../src/lucifer.h"
7
+
8
+ extern void insecure_key_generate(uint8_t *key, size_t key_len);
9
+
10
+ static int hex_char_to_nibble(char c) {
11
+ if (c >= '0' && c <= '9') return c - '0';
12
+ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
13
+ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
14
+ return -1;
15
+ }
16
+
17
+ static int parse_hex(const char *hex, uint8_t *out, size_t out_len) {
18
+ size_t hex_len = strlen(hex);
19
+ if (hex_len != out_len * 2) return 0;
20
+ for (size_t i = 0; i < out_len; i++) {
21
+ int hi = hex_char_to_nibble(hex[2 * i]);
22
+ int lo = hex_char_to_nibble(hex[2 * i + 1]);
23
+ if (hi < 0 || lo < 0) return 0;
24
+ out[i] = (uint8_t)((hi << 4) | lo);
25
+ }
26
+ return 1;
27
+ }
28
+
29
+ static void print_hex(const unsigned char *buf, size_t len) {
30
+ for (size_t i = 0; i < len; i++) printf("%02x", buf[i]);
31
+ }
32
+
33
+ int main(int argc, char **argv) {
34
+ if (argc != 2) {
35
+ fprintf(stderr, "Usage: %s <64-hex-chars>\n", argv[0]);
36
+ return 1;
37
+ }
38
+
39
+ uint8_t key[LUCIFER_KEY_SIZE];
40
+ insecure_key_generate((uint8_t *)key, sizeof(key));
41
+
42
+ const uint8_t target_ciphertext[32] = {
43
+ 0x16, 0xda, 0xa6, 0xec, 0xe6, 0x55, 0xc8, 0x97,
44
+ 0xbb, 0x3e, 0x93, 0x92, 0x28, 0xf2, 0x7a, 0x98,
45
+ 0x78, 0xd0, 0x9d, 0xf2, 0x29, 0x3e, 0xe4, 0xf3,
46
+ 0xcf, 0x9e, 0x27, 0x12, 0xb0, 0x92, 0x43, 0xd5
47
+ };
48
+
49
+ uint8_t plaintext[32];
50
+ if (!parse_hex(argv[1], plaintext, sizeof(plaintext))) {
51
+ fprintf(stderr, "Bad input hex. Expecting 64 hex chars (32 bytes).\n");
52
+ return 1;
53
+ }
54
+
55
+ lucifer_ctx ctx;
56
+ lucifer_set_encrypt_key(&ctx, key);
57
+
58
+ uint8_t ciphertext[32];
59
+ lucifer_ecb_encrypt(&ctx, plaintext, ciphertext, sizeof(ciphertext));
60
+
61
+ printf("Ciphertext(hex): ");
62
+ print_hex(ciphertext, sizeof(ciphertext));
63
+ printf("\n");
64
+
65
+ int same = memcmp(ciphertext, target_ciphertext, sizeof(ciphertext)) == 0;
66
+ printf("Match: %s\n", same ? "True" : "False");
67
+ return same ? 0 : 1;
68
+ }
CREBench/Lucifer-128-ECB/challenge_src/generated/fragmented_build/key_source.c ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* instance_label=Lucifer-128-ECB-fragmented_build-random variant=even_odd_xor */
2
+ #include <stddef.h>
3
+ #include <stdint.h>
4
+
5
+ #define INSECURE_KEY_NOOPT __attribute__((noinline, noclone, optimize("O0")))
6
+
7
+
8
+ static const uint8_t FRAG_EVEN[] = {
9
+ 0x87, 0xc7, 0xca, 0xe5, 0xc6, 0x01, 0x97, 0x33
10
+ };
11
+
12
+ static const uint8_t FRAG_ODD[] = {
13
+ 0xe2, 0x5b, 0xb1, 0xc6, 0xe0, 0xc7, 0x06, 0xf2
14
+ };
15
+
16
+ INSECURE_KEY_NOOPT
17
+ static uint8_t rebuild_byte(size_t index) {
18
+ volatile const uint8_t *even = FRAG_EVEN;
19
+ volatile const uint8_t *odd = FRAG_ODD;
20
+ volatile uint8_t value;
21
+ if ((index & 1U) == 0U) {
22
+ value = (uint8_t)(even[index / 2] ^ 0xd9);
23
+ } else {
24
+ value = (uint8_t)(odd[index / 2] ^ 0xd9);
25
+ }
26
+ return value;
27
+ }
28
+
29
+ INSECURE_KEY_NOOPT
30
+ void insecure_key_generate(uint8_t *key, size_t key_len) {
31
+ for (size_t i = 0; i < key_len; i++) {
32
+ key[i] = rebuild_byte(i % 16);
33
+ }
34
+ }
CREBench/Lucifer-128-ECB/challenge_src/generated/fragmented_build/metadata.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "challenge": "Lucifer-128-ECB",
3
+ "key_mode": "fragmented_build",
4
+ "variant": "randomized",
5
+ "flag": "4cde8c3e531d8400971b8e064f31e7c627fb6bd1ece498fb510b10fb2756fb21",
6
+ "key": "5e3b1e8213683c1f1f39d81e4edfea2b",
7
+ "iv": "",
8
+ "target_ciphertext": "16daa6ece655c897bb3e939228f27a9878d09df2293ee4f3cf9e2712b09243d5",
9
+ "test_vectors_path": "CREBench/Lucifer-128-ECB/test_vectors-fragmented_build.json"
10
+ }
CREBench/Lucifer-128-ECB/challenge_src/generated/hardcode_plain/challenge.c ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* key_mode=hardcode_plain variant=randomized challenge=Lucifer-128-ECB */
2
+ /* canonical_flag=4cde8c3e531d8400971b8e064f31e7c627fb6bd1ece498fb510b10fb2756fb21 */
3
+ #include <stdio.h>
4
+ #include <string.h>
5
+ #include <stdlib.h>
6
+ #include "../src/lucifer.h"
7
+
8
+ extern void insecure_key_generate(uint8_t *key, size_t key_len);
9
+
10
+ static int hex_char_to_nibble(char c) {
11
+ if (c >= '0' && c <= '9') return c - '0';
12
+ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
13
+ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
14
+ return -1;
15
+ }
16
+
17
+ static int parse_hex(const char *hex, uint8_t *out, size_t out_len) {
18
+ size_t hex_len = strlen(hex);
19
+ if (hex_len != out_len * 2) return 0;
20
+ for (size_t i = 0; i < out_len; i++) {
21
+ int hi = hex_char_to_nibble(hex[2 * i]);
22
+ int lo = hex_char_to_nibble(hex[2 * i + 1]);
23
+ if (hi < 0 || lo < 0) return 0;
24
+ out[i] = (uint8_t)((hi << 4) | lo);
25
+ }
26
+ return 1;
27
+ }
28
+
29
+ static void print_hex(const unsigned char *buf, size_t len) {
30
+ for (size_t i = 0; i < len; i++) printf("%02x", buf[i]);
31
+ }
32
+
33
+ int main(int argc, char **argv) {
34
+ if (argc != 2) {
35
+ fprintf(stderr, "Usage: %s <64-hex-chars>\n", argv[0]);
36
+ return 1;
37
+ }
38
+
39
+ uint8_t key[LUCIFER_KEY_SIZE];
40
+ insecure_key_generate((uint8_t *)key, sizeof(key));
41
+
42
+ const uint8_t target_ciphertext[32] = {
43
+ 0x33, 0xc2, 0x7c, 0x4f, 0xd0, 0xee, 0x40, 0x3a,
44
+ 0x11, 0xe2, 0x6a, 0x9e, 0x03, 0xd7, 0x69, 0x42,
45
+ 0xdd, 0x20, 0xab, 0xe1, 0xbc, 0x93, 0x37, 0xe8,
46
+ 0xbd, 0xb3, 0x2c, 0xde, 0x0c, 0x7a, 0x84, 0xc5
47
+ };
48
+
49
+ uint8_t plaintext[32];
50
+ if (!parse_hex(argv[1], plaintext, sizeof(plaintext))) {
51
+ fprintf(stderr, "Bad input hex. Expecting 64 hex chars (32 bytes).\n");
52
+ return 1;
53
+ }
54
+
55
+ lucifer_ctx ctx;
56
+ lucifer_set_encrypt_key(&ctx, key);
57
+
58
+ uint8_t ciphertext[32];
59
+ lucifer_ecb_encrypt(&ctx, plaintext, ciphertext, sizeof(ciphertext));
60
+
61
+ printf("Ciphertext(hex): ");
62
+ print_hex(ciphertext, sizeof(ciphertext));
63
+ printf("\n");
64
+
65
+ int same = memcmp(ciphertext, target_ciphertext, sizeof(ciphertext)) == 0;
66
+ printf("Match: %s\n", same ? "True" : "False");
67
+ return same ? 0 : 1;
68
+ }