cyberchef 9.50.11 → 9.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/package.json +1 -1
- package/src/core/Utils.mjs +64 -0
- package/src/core/config/Categories.json +2 -0
- package/src/core/config/OperationConfig.json +95 -0
- package/src/core/config/modules/Crypto.mjs +2 -0
- package/src/core/config/modules/Default.mjs +2 -0
- package/src/core/operations/CMAC.mjs +149 -0
- package/src/core/operations/ChaCha.mjs +234 -0
- package/src/core/operations/Fletcher32Checksum.mjs +11 -3
- package/src/core/operations/Fletcher64Checksum.mjs +15 -3
- package/src/core/operations/index.mjs +4 -0
- package/src/node/index.mjs +10 -0
- package/tests/operations/index.mjs +3 -0
- package/tests/operations/tests/CMAC.mjs +314 -0
- package/tests/operations/tests/ChaCha.mjs +151 -0
- package/tests/operations/tests/FletcherChecksum.mjs +108 -0
- package/tests/operations/tests/GenerateAllHashes.mjs +2 -2
|
@@ -35,10 +35,22 @@ class Fletcher64Checksum extends Operation {
|
|
|
35
35
|
run(input, args) {
|
|
36
36
|
let a = 0,
|
|
37
37
|
b = 0;
|
|
38
|
-
|
|
38
|
+
if (ArrayBuffer.isView(input)) {
|
|
39
|
+
input = new DataView(input.buffer, input.byteOffset, input.byteLength);
|
|
40
|
+
} else {
|
|
41
|
+
input = new DataView(input);
|
|
42
|
+
}
|
|
39
43
|
|
|
40
|
-
for (let i = 0; i < input.
|
|
41
|
-
a = (a + input
|
|
44
|
+
for (let i = 0; i < input.byteLength - 3; i += 4) {
|
|
45
|
+
a = (a + input.getUint32(i, true)) % 0xffffffff;
|
|
46
|
+
b = (b + a) % 0xffffffff;
|
|
47
|
+
}
|
|
48
|
+
if (input.byteLength % 4 !== 0) {
|
|
49
|
+
let lastValue = 0;
|
|
50
|
+
for (let i = 0; i < input.byteLength % 4; i++) {
|
|
51
|
+
lastValue = (lastValue << 8) | input.getUint8(input.byteLength - 1 - i);
|
|
52
|
+
}
|
|
53
|
+
a = (a + lastValue) % 0xffffffff;
|
|
42
54
|
b = (b + a) % 0xffffffff;
|
|
43
55
|
}
|
|
44
56
|
|
|
@@ -40,6 +40,7 @@ import Bzip2Compress from "./Bzip2Compress.mjs";
|
|
|
40
40
|
import Bzip2Decompress from "./Bzip2Decompress.mjs";
|
|
41
41
|
import CBORDecode from "./CBORDecode.mjs";
|
|
42
42
|
import CBOREncode from "./CBOREncode.mjs";
|
|
43
|
+
import CMAC from "./CMAC.mjs";
|
|
43
44
|
import CRC16Checksum from "./CRC16Checksum.mjs";
|
|
44
45
|
import CRC32Checksum from "./CRC32Checksum.mjs";
|
|
45
46
|
import CRC8Checksum from "./CRC8Checksum.mjs";
|
|
@@ -52,6 +53,7 @@ import CaesarBoxCipher from "./CaesarBoxCipher.mjs";
|
|
|
52
53
|
import CartesianProduct from "./CartesianProduct.mjs";
|
|
53
54
|
import CetaceanCipherDecode from "./CetaceanCipherDecode.mjs";
|
|
54
55
|
import CetaceanCipherEncode from "./CetaceanCipherEncode.mjs";
|
|
56
|
+
import ChaCha from "./ChaCha.mjs";
|
|
55
57
|
import ChangeIPFormat from "./ChangeIPFormat.mjs";
|
|
56
58
|
import ChiSquare from "./ChiSquare.mjs";
|
|
57
59
|
import CipherSaber2Decrypt from "./CipherSaber2Decrypt.mjs";
|
|
@@ -432,6 +434,7 @@ export {
|
|
|
432
434
|
Bzip2Decompress,
|
|
433
435
|
CBORDecode,
|
|
434
436
|
CBOREncode,
|
|
437
|
+
CMAC,
|
|
435
438
|
CRC16Checksum,
|
|
436
439
|
CRC32Checksum,
|
|
437
440
|
CRC8Checksum,
|
|
@@ -444,6 +447,7 @@ export {
|
|
|
444
447
|
CartesianProduct,
|
|
445
448
|
CetaceanCipherDecode,
|
|
446
449
|
CetaceanCipherEncode,
|
|
450
|
+
ChaCha,
|
|
447
451
|
ChangeIPFormat,
|
|
448
452
|
ChiSquare,
|
|
449
453
|
CipherSaber2Decrypt,
|
package/src/node/index.mjs
CHANGED
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
Bzip2Decompress as core_Bzip2Decompress,
|
|
51
51
|
CBORDecode as core_CBORDecode,
|
|
52
52
|
CBOREncode as core_CBOREncode,
|
|
53
|
+
CMAC as core_CMAC,
|
|
53
54
|
CRC16Checksum as core_CRC16Checksum,
|
|
54
55
|
CRC32Checksum as core_CRC32Checksum,
|
|
55
56
|
CRC8Checksum as core_CRC8Checksum,
|
|
@@ -62,6 +63,7 @@ import {
|
|
|
62
63
|
CartesianProduct as core_CartesianProduct,
|
|
63
64
|
CetaceanCipherDecode as core_CetaceanCipherDecode,
|
|
64
65
|
CetaceanCipherEncode as core_CetaceanCipherEncode,
|
|
66
|
+
ChaCha as core_ChaCha,
|
|
65
67
|
ChangeIPFormat as core_ChangeIPFormat,
|
|
66
68
|
ChiSquare as core_ChiSquare,
|
|
67
69
|
CipherSaber2Decrypt as core_CipherSaber2Decrypt,
|
|
@@ -442,6 +444,7 @@ function generateChef() {
|
|
|
442
444
|
"bzip2Decompress": _wrap(core_Bzip2Decompress),
|
|
443
445
|
"CBORDecode": _wrap(core_CBORDecode),
|
|
444
446
|
"CBOREncode": _wrap(core_CBOREncode),
|
|
447
|
+
"CMAC": _wrap(core_CMAC),
|
|
445
448
|
"CRC16Checksum": _wrap(core_CRC16Checksum),
|
|
446
449
|
"CRC32Checksum": _wrap(core_CRC32Checksum),
|
|
447
450
|
"CRC8Checksum": _wrap(core_CRC8Checksum),
|
|
@@ -454,6 +457,7 @@ function generateChef() {
|
|
|
454
457
|
"cartesianProduct": _wrap(core_CartesianProduct),
|
|
455
458
|
"cetaceanCipherDecode": _wrap(core_CetaceanCipherDecode),
|
|
456
459
|
"cetaceanCipherEncode": _wrap(core_CetaceanCipherEncode),
|
|
460
|
+
"chaCha": _wrap(core_ChaCha),
|
|
457
461
|
"changeIPFormat": _wrap(core_ChangeIPFormat),
|
|
458
462
|
"chiSquare": _wrap(core_ChiSquare),
|
|
459
463
|
"cipherSaber2Decrypt": _wrap(core_CipherSaber2Decrypt),
|
|
@@ -842,6 +846,7 @@ const bzip2Compress = chef.bzip2Compress;
|
|
|
842
846
|
const bzip2Decompress = chef.bzip2Decompress;
|
|
843
847
|
const CBORDecode = chef.CBORDecode;
|
|
844
848
|
const CBOREncode = chef.CBOREncode;
|
|
849
|
+
const CMAC = chef.CMAC;
|
|
845
850
|
const CRC16Checksum = chef.CRC16Checksum;
|
|
846
851
|
const CRC32Checksum = chef.CRC32Checksum;
|
|
847
852
|
const CRC8Checksum = chef.CRC8Checksum;
|
|
@@ -854,6 +859,7 @@ const caesarBoxCipher = chef.caesarBoxCipher;
|
|
|
854
859
|
const cartesianProduct = chef.cartesianProduct;
|
|
855
860
|
const cetaceanCipherDecode = chef.cetaceanCipherDecode;
|
|
856
861
|
const cetaceanCipherEncode = chef.cetaceanCipherEncode;
|
|
862
|
+
const chaCha = chef.chaCha;
|
|
857
863
|
const changeIPFormat = chef.changeIPFormat;
|
|
858
864
|
const chiSquare = chef.chiSquare;
|
|
859
865
|
const cipherSaber2Decrypt = chef.cipherSaber2Decrypt;
|
|
@@ -1236,6 +1242,7 @@ const operations = [
|
|
|
1236
1242
|
bzip2Decompress,
|
|
1237
1243
|
CBORDecode,
|
|
1238
1244
|
CBOREncode,
|
|
1245
|
+
CMAC,
|
|
1239
1246
|
CRC16Checksum,
|
|
1240
1247
|
CRC32Checksum,
|
|
1241
1248
|
CRC8Checksum,
|
|
@@ -1248,6 +1255,7 @@ const operations = [
|
|
|
1248
1255
|
cartesianProduct,
|
|
1249
1256
|
cetaceanCipherDecode,
|
|
1250
1257
|
cetaceanCipherEncode,
|
|
1258
|
+
chaCha,
|
|
1251
1259
|
changeIPFormat,
|
|
1252
1260
|
chiSquare,
|
|
1253
1261
|
cipherSaber2Decrypt,
|
|
@@ -1634,6 +1642,7 @@ export {
|
|
|
1634
1642
|
bzip2Decompress,
|
|
1635
1643
|
CBORDecode,
|
|
1636
1644
|
CBOREncode,
|
|
1645
|
+
CMAC,
|
|
1637
1646
|
CRC16Checksum,
|
|
1638
1647
|
CRC32Checksum,
|
|
1639
1648
|
CRC8Checksum,
|
|
@@ -1646,6 +1655,7 @@ export {
|
|
|
1646
1655
|
cartesianProduct,
|
|
1647
1656
|
cetaceanCipherDecode,
|
|
1648
1657
|
cetaceanCipherEncode,
|
|
1658
|
+
chaCha,
|
|
1649
1659
|
changeIPFormat,
|
|
1650
1660
|
chiSquare,
|
|
1651
1661
|
cipherSaber2Decrypt,
|
|
@@ -30,6 +30,7 @@ import "./tests/ByteRepr.mjs";
|
|
|
30
30
|
import "./tests/CartesianProduct.mjs";
|
|
31
31
|
import "./tests/CetaceanCipherEncode.mjs";
|
|
32
32
|
import "./tests/CetaceanCipherDecode.mjs";
|
|
33
|
+
import "./tests/ChaCha.mjs";
|
|
33
34
|
import "./tests/CharEnc.mjs";
|
|
34
35
|
import "./tests/ChangeIPFormat.mjs";
|
|
35
36
|
import "./tests/Charts.mjs";
|
|
@@ -125,6 +126,8 @@ import "./tests/LS47.mjs";
|
|
|
125
126
|
import "./tests/LZString.mjs";
|
|
126
127
|
import "./tests/NTLM.mjs";
|
|
127
128
|
import "./tests/Shuffle.mjs";
|
|
129
|
+
import "./tests/FletcherChecksum.mjs";
|
|
130
|
+
import "./tests/CMAC.mjs";
|
|
128
131
|
|
|
129
132
|
// Cannot test operations that use the File type yet
|
|
130
133
|
// import "./tests/SplitColourChannels.mjs";
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author mikecat
|
|
3
|
+
* @copyright Crown Copyright 2022
|
|
4
|
+
* @license Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import TestRegister from "../../lib/TestRegister.mjs";
|
|
7
|
+
|
|
8
|
+
// values in "NIST's CSRC" testcases are taken from here:
|
|
9
|
+
// https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
|
|
10
|
+
|
|
11
|
+
TestRegister.addTests([
|
|
12
|
+
{
|
|
13
|
+
"name": "CMAC-AES128 NIST's CSRC Example #1",
|
|
14
|
+
"input": "",
|
|
15
|
+
"expectedOutput": "bb1d6929e95937287fa37d129b756746",
|
|
16
|
+
"recipeConfig": [
|
|
17
|
+
{
|
|
18
|
+
"op": "CMAC",
|
|
19
|
+
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
|
20
|
+
},
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "CMAC-AES128 NIST's CSRC Example #2",
|
|
25
|
+
"input": "6bc1bee22e409f96e93d7e117393172a",
|
|
26
|
+
"expectedOutput": "070a16b46b4d4144f79bdd9dd04a287c",
|
|
27
|
+
"recipeConfig": [
|
|
28
|
+
{
|
|
29
|
+
"op": "From Hex",
|
|
30
|
+
"args": ["None"]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"op": "CMAC",
|
|
34
|
+
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
|
35
|
+
},
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "CMAC-AES128 NIST's CSRC Example #3",
|
|
40
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
|
41
|
+
"expectedOutput": "7d85449ea6ea19c823a7bf78837dfade",
|
|
42
|
+
"recipeConfig": [
|
|
43
|
+
{
|
|
44
|
+
"op": "From Hex",
|
|
45
|
+
"args": ["None"]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"op": "CMAC",
|
|
49
|
+
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "CMAC-AES128 NIST's CSRC Example #4",
|
|
55
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
|
|
56
|
+
"expectedOutput": "51f0bebf7e3b9d92fc49741779363cfe",
|
|
57
|
+
"recipeConfig": [
|
|
58
|
+
{
|
|
59
|
+
"op": "From Hex",
|
|
60
|
+
"args": ["None"]
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"op": "CMAC",
|
|
64
|
+
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
|
65
|
+
},
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "CMAC-AES192 NIST's CSRC Example #1",
|
|
70
|
+
"input": "",
|
|
71
|
+
"expectedOutput": "d17ddf46adaacde531cac483de7a9367",
|
|
72
|
+
"recipeConfig": [
|
|
73
|
+
{
|
|
74
|
+
"op": "CMAC",
|
|
75
|
+
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "CMAC-AES192 NIST's CSRC Example #2",
|
|
81
|
+
"input": "6bc1bee22e409f96e93d7e117393172a",
|
|
82
|
+
"expectedOutput": "9e99a7bf31e710900662f65e617c5184",
|
|
83
|
+
"recipeConfig": [
|
|
84
|
+
{
|
|
85
|
+
"op": "From Hex",
|
|
86
|
+
"args": ["None"]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"op": "CMAC",
|
|
90
|
+
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "CMAC-AES192 NIST's CSRC Example #3",
|
|
96
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
|
97
|
+
"expectedOutput": "3d75c194ed96070444a9fa7ec740ecf8",
|
|
98
|
+
"recipeConfig": [
|
|
99
|
+
{
|
|
100
|
+
"op": "From Hex",
|
|
101
|
+
"args": ["None"]
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"op": "CMAC",
|
|
105
|
+
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "CMAC-AES192 NIST's CSRC Example #4",
|
|
111
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
|
|
112
|
+
"expectedOutput": "a1d5df0eed790f794d77589659f39a11",
|
|
113
|
+
"recipeConfig": [
|
|
114
|
+
{
|
|
115
|
+
"op": "From Hex",
|
|
116
|
+
"args": ["None"]
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"op": "CMAC",
|
|
120
|
+
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
|
121
|
+
},
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "CMAC-AES256 NIST's CSRC Example #1",
|
|
126
|
+
"input": "",
|
|
127
|
+
"expectedOutput": "028962f61b7bf89efc6b551f4667d983",
|
|
128
|
+
"recipeConfig": [
|
|
129
|
+
{
|
|
130
|
+
"op": "CMAC",
|
|
131
|
+
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
|
132
|
+
},
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "CMAC-AES256 NIST's CSRC Example #2",
|
|
137
|
+
"input": "6bc1bee22e409f96e93d7e117393172a",
|
|
138
|
+
"expectedOutput": "28a7023f452e8f82bd4bf28d8c37c35c",
|
|
139
|
+
"recipeConfig": [
|
|
140
|
+
{
|
|
141
|
+
"op": "From Hex",
|
|
142
|
+
"args": ["None"]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"op": "CMAC",
|
|
146
|
+
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
|
147
|
+
},
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "CMAC-AES256 NIST's CSRC Example #3",
|
|
152
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
|
153
|
+
"expectedOutput": "156727dc0878944a023c1fe03bad6d93",
|
|
154
|
+
"recipeConfig": [
|
|
155
|
+
{
|
|
156
|
+
"op": "From Hex",
|
|
157
|
+
"args": ["None"]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"op": "CMAC",
|
|
161
|
+
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
|
162
|
+
},
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "CMAC-AES256 NIST's CSRC Example #4",
|
|
167
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
|
|
168
|
+
"expectedOutput": "e1992190549f6ed5696a2c056c315410",
|
|
169
|
+
"recipeConfig": [
|
|
170
|
+
{
|
|
171
|
+
"op": "From Hex",
|
|
172
|
+
"args": ["None"]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"op": "CMAC",
|
|
176
|
+
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
|
177
|
+
},
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "CMAC-TDES (1) NIST's CSRC Sample #1",
|
|
182
|
+
"input": "",
|
|
183
|
+
"expectedOutput": "7db0d37df936c550",
|
|
184
|
+
"recipeConfig": [
|
|
185
|
+
{
|
|
186
|
+
"op": "CMAC",
|
|
187
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
|
188
|
+
},
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"name": "CMAC-TDES (1) NIST's CSRC Sample #2",
|
|
193
|
+
"input": "6bc1bee22e409f96e93d7e117393172a",
|
|
194
|
+
"expectedOutput": "30239cf1f52e6609",
|
|
195
|
+
"recipeConfig": [
|
|
196
|
+
{
|
|
197
|
+
"op": "From Hex",
|
|
198
|
+
"args": ["None"]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"op": "CMAC",
|
|
202
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
|
203
|
+
},
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "CMAC-TDES (1) NIST's CSRC Sample #3",
|
|
208
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
|
209
|
+
"expectedOutput": "6c9f3ee4923f6be2",
|
|
210
|
+
"recipeConfig": [
|
|
211
|
+
{
|
|
212
|
+
"op": "From Hex",
|
|
213
|
+
"args": ["None"]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"op": "CMAC",
|
|
217
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
|
218
|
+
},
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "CMAC-TDES (1) NIST's CSRC Sample #4",
|
|
223
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
|
|
224
|
+
"expectedOutput": "99429bd0bf7904e5",
|
|
225
|
+
"recipeConfig": [
|
|
226
|
+
{
|
|
227
|
+
"op": "From Hex",
|
|
228
|
+
"args": ["None"]
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"op": "CMAC",
|
|
232
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
|
233
|
+
},
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"name": "CMAC-TDES (2) NIST's CSRC Sample #1",
|
|
238
|
+
"input": "",
|
|
239
|
+
"expectedOutput": "79ce52a7f786a960",
|
|
240
|
+
"recipeConfig": [
|
|
241
|
+
{
|
|
242
|
+
"op": "CMAC",
|
|
243
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
|
244
|
+
},
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"name": "CMAC-TDES (2) NIST's CSRC Sample #2",
|
|
249
|
+
"input": "6bc1bee22e409f96e93d7e117393172a",
|
|
250
|
+
"expectedOutput": "cc18a0b79af2413b",
|
|
251
|
+
"recipeConfig": [
|
|
252
|
+
{
|
|
253
|
+
"op": "From Hex",
|
|
254
|
+
"args": ["None"]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"op": "CMAC",
|
|
258
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
|
259
|
+
},
|
|
260
|
+
]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"name": "CMAC-TDES (2) NIST's CSRC Sample #3",
|
|
264
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
|
265
|
+
"expectedOutput": "c06d377ecd101969",
|
|
266
|
+
"recipeConfig": [
|
|
267
|
+
{
|
|
268
|
+
"op": "From Hex",
|
|
269
|
+
"args": ["None"]
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"op": "CMAC",
|
|
273
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
|
274
|
+
},
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"name": "CMAC-TDES (2) NIST's CSRC Sample #4",
|
|
279
|
+
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
|
|
280
|
+
"expectedOutput": "9cd33580f9b64dfb",
|
|
281
|
+
"recipeConfig": [
|
|
282
|
+
{
|
|
283
|
+
"op": "From Hex",
|
|
284
|
+
"args": ["None"]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"op": "CMAC",
|
|
288
|
+
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
|
289
|
+
},
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "CMAC-AES: invalid key length",
|
|
294
|
+
"input": "",
|
|
295
|
+
"expectedOutput": "The key for AES must be either 16, 24, or 32 bytes (currently 20 bytes)",
|
|
296
|
+
"recipeConfig": [
|
|
297
|
+
{
|
|
298
|
+
"op": "CMAC",
|
|
299
|
+
"args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "AES"]
|
|
300
|
+
},
|
|
301
|
+
]
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"name": "CMAC-TDES: invalid key length",
|
|
305
|
+
"input": "",
|
|
306
|
+
"expectedOutput": "The key for Triple DES must be 16 or 24 bytes (currently 20 bytes)",
|
|
307
|
+
"recipeConfig": [
|
|
308
|
+
{
|
|
309
|
+
"op": "CMAC",
|
|
310
|
+
"args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "Triple DES"]
|
|
311
|
+
},
|
|
312
|
+
]
|
|
313
|
+
},
|
|
314
|
+
]);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChaCha tests.
|
|
3
|
+
*
|
|
4
|
+
* @author joostrijneveld [joost@joostrijneveld.nl]
|
|
5
|
+
* @copyright Crown Copyright 2022
|
|
6
|
+
* @license Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import TestRegister from "../../lib/TestRegister.mjs";
|
|
10
|
+
|
|
11
|
+
TestRegister.addTests([
|
|
12
|
+
{
|
|
13
|
+
name: "ChaCha: no key",
|
|
14
|
+
input: "",
|
|
15
|
+
expectedOutput: `Invalid key length: 0 bytes.
|
|
16
|
+
|
|
17
|
+
ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`,
|
|
18
|
+
recipeConfig: [
|
|
19
|
+
{
|
|
20
|
+
"op": "ChaCha",
|
|
21
|
+
"args": [
|
|
22
|
+
{"option": "Hex", "string": ""},
|
|
23
|
+
{"option": "Hex", "string": ""},
|
|
24
|
+
0, "20", "Hex", "Hex",
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "ChaCha: no nonce",
|
|
31
|
+
input: "",
|
|
32
|
+
expectedOutput: `Invalid nonce length: 0 bytes.
|
|
33
|
+
|
|
34
|
+
ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).`,
|
|
35
|
+
recipeConfig: [
|
|
36
|
+
{
|
|
37
|
+
"op": "ChaCha",
|
|
38
|
+
"args": [
|
|
39
|
+
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
|
40
|
+
{"option": "Hex", "string": ""},
|
|
41
|
+
0, "20", "Hex", "Hex",
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "ChaCha: RFC8439",
|
|
48
|
+
input: "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.",
|
|
49
|
+
expectedOutput: "6e 2e 35 9a 25 68 f9 80 41 ba 07 28 dd 0d 69 81 e9 7e 7a ec 1d 43 60 c2 0a 27 af cc fd 9f ae 0b f9 1b 65 c5 52 47 33 ab 8f 59 3d ab cd 62 b3 57 16 39 d6 24 e6 51 52 ab 8f 53 0c 35 9f 08 61 d8 07 ca 0d bf 50 0d 6a 61 56 a3 8e 08 8a 22 b6 5e 52 bc 51 4d 16 cc f8 06 81 8c e9 1a b7 79 37 36 5a f9 0b bf 74 a3 5b e6 b4 0b 8e ed f2 78 5e 42 87 4d",
|
|
50
|
+
recipeConfig: [
|
|
51
|
+
{
|
|
52
|
+
"op": "ChaCha",
|
|
53
|
+
"args": [
|
|
54
|
+
{"option": "Hex", "string": "00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f"},
|
|
55
|
+
{"option": "Hex", "string": "00:00:00:00:00:00:00:4a:00:00:00:00"},
|
|
56
|
+
1, "20", "Raw", "Hex",
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.1",
|
|
63
|
+
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
|
|
64
|
+
expectedOutput: "29 56 0d 28 0b 45 28 40 0a 8f 4b 79 53 69 fb 3a 01 10 55 99 e9 f1 ed 58 27 9c fc 9e ce 2d c5 f9 9f 1c 2e 52 c9 82 38 f5 42 a5 c0 a8 81 d8 50 b6 15 d3 ac d9 fb db 02 6e 93 68 56 5d a5 0e 0d 49 dd 5b e8 ef 74 24 8b 3e 25 1d 96 5d 8f cb 21 e7 cf e2 04 d4 00 78 06 fb ee 3c e9 4c 74 bf ba d2 c1 1c 62 1b a0 48 14 7c 5c aa 94 d1 82 cc ff 6f d5 cf 44 ad f9 6e 3d 68 28 1b b4 96 76 af 87 e7",
|
|
65
|
+
recipeConfig: [
|
|
66
|
+
{
|
|
67
|
+
"op": "ChaCha",
|
|
68
|
+
"args": [
|
|
69
|
+
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
|
|
70
|
+
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
|
71
|
+
0, "8", "Hex", "Hex",
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.2",
|
|
78
|
+
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
|
|
79
|
+
expectedOutput: "5e dd c2 d9 42 8f ce ee c5 0a 52 a9 64 ea e0 ff b0 4b 2d e0 06 a9 b0 4c ff 36 8f fa 92 11 16 b2 e8 e2 64 ba bd 2e fa 0d e4 3e f2 e3 b6 d0 65 e8 f7 c0 a1 78 37 b0 a4 0e b0 e2 c7 a3 74 2c 87 53 ed e5 f3 f6 d1 9b e5 54 67 5e 50 6a 77 5c 63 f0 94 d4 96 5c 31 93 19 dc d7 50 6f 45 7b 11 7b 84 b1 0b 24 6e 95 6c 2d a8 89 8a 65 6c ee f3 f7 b7 16 45 b1 9f 70 1d b8 44 85 ce 51 21 f0 f6 17 ef",
|
|
80
|
+
recipeConfig: [
|
|
81
|
+
{
|
|
82
|
+
"op": "ChaCha",
|
|
83
|
+
"args": [
|
|
84
|
+
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
|
|
85
|
+
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
|
86
|
+
0, "12", "Hex", "Hex",
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.3",
|
|
93
|
+
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
|
|
94
|
+
expectedOutput: "d1 ab f6 30 46 7e b4 f6 7f 1c fb 47 cd 62 6a ae 8a fe db be 4f f8 fc 5f e9 cf ae 30 7e 74 ed 45 1f 14 04 42 5a d2 b5 45 69 d5 f1 81 48 93 99 71 ab b8 fa fc 88 ce 4a c7 fe 1c 3d 1f 7a 1e b7 ca e7 6c a8 7b 61 a9 71 35 41 49 77 60 dd 9a e0 59 35 0c ad 0d ce df aa 80 a8 83 11 9a 1a 6f 98 7f d1 ce 91 fd 8e e0 82 80 34 b4 11 20 0a 97 45 a2 85 55 44 75 d1 2a fc 04 88 7f ef 35 16 d1 2a 2c",
|
|
95
|
+
recipeConfig: [
|
|
96
|
+
{
|
|
97
|
+
"op": "ChaCha",
|
|
98
|
+
"args": [
|
|
99
|
+
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
|
|
100
|
+
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
|
101
|
+
0, "20", "Hex", "Hex",
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.4",
|
|
108
|
+
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
|
|
109
|
+
expectedOutput: "db 43 ad 9d 1e 84 2d 12 72 e4 53 0e 27 6b 3f 56 8f 88 59 b3 f7 cf 6d 9d 2c 74 fa 53 80 8c b5 15 7a 8e bf 46 ad 3d cc 4b 6c 7d ad de 13 17 84 b0 12 0e 0e 22 f6 d5 f9 ff a7 40 7d 4a 21 b6 95 d9 c5 dd 30 bf 55 61 2f ab 9b dd 11 89 20 c1 98 16 47 0c 7f 5d cd 42 32 5d bb ed 8c 57 a5 62 81 c1 44 cb 0f 03 e8 1b 30 04 62 4e 06 50 a1 ce 5a fa f9 a7 cd 81 63 f6 db d7 26 02 25 7d d9 6e 47 1e",
|
|
110
|
+
recipeConfig: [
|
|
111
|
+
{
|
|
112
|
+
"op": "ChaCha",
|
|
113
|
+
"args": [
|
|
114
|
+
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ff ee dd cc bb aa 99 88 77 66 55 44 33 22 11 00"},
|
|
115
|
+
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
|
116
|
+
0, "8", "Hex", "Hex",
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.5",
|
|
123
|
+
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
|
|
124
|
+
expectedOutput: "7e d1 2a 3a 63 91 2a e9 41 ba 6d 4c 0d 5e 86 2e 56 8b 0e 55 89 34 69 35 50 5f 06 4b 8c 26 98 db f7 d8 50 66 7d 8e 67 be 63 9f 3b 4f 6a 16 f9 2e 65 ea 80 f6 c7 42 94 45 da 1f c2 c1 b9 36 50 40 e3 2e 50 c4 10 6f 3b 3d a1 ce 7c cb 1e 71 40 b1 53 49 3c 0f 3a d9 a9 bc ff 07 7e c4 59 6f 1d 0f 29 bf 9c ba a5 02 82 0f 73 2a f5 a9 3c 49 ee e3 3d 1c 4f 12 af 3b 42 97 af 91 fe 41 ea 9e 94 a2",
|
|
125
|
+
recipeConfig: [
|
|
126
|
+
{
|
|
127
|
+
"op": "ChaCha",
|
|
128
|
+
"args": [
|
|
129
|
+
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ff ee dd cc bb aa 99 88 77 66 55 44 33 22 11 00"},
|
|
130
|
+
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
|
131
|
+
0, "12", "Hex", "Hex",
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.6",
|
|
138
|
+
input: "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",
|
|
139
|
+
expectedOutput: "9f ad f4 09 c0 08 11 d0 04 31 d6 7e fb d8 8f ba 59 21 8d 5d 67 08 b1 d6 85 86 3f ab bb 0e 96 1e ea 48 0f d6 fb 53 2b fd 49 4b 21 51 01 50 57 42 3a b6 0a 63 fe 4f 55 f7 a2 12 e2 16 7c ca b9 31 fb fd 29 cf 7b c1 d2 79 ed df 25 dd 31 6b b8 84 3d 6e de e0 bd 1e f1 21 d1 2f a1 7c bc 2c 57 4c cc ab 5e 27 51 67 b0 8b d6 86 f8 a0 9d f8 7e c3 ff b3 53 61 b9 4e bf a1 3f ec 0e 48 89 d1 8d a5",
|
|
140
|
+
recipeConfig: [
|
|
141
|
+
{
|
|
142
|
+
"op": "ChaCha",
|
|
143
|
+
"args": [
|
|
144
|
+
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff ff ee dd cc bb aa 99 88 77 66 55 44 33 22 11 00"},
|
|
145
|
+
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
|
146
|
+
0, "20", "Hex", "Hex",
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
]);
|