cyberchef 11.1.0 → 11.3.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/AGENTS.md +75 -0
- package/CHANGELOG.md +173 -2
- package/Dockerfile +2 -2
- package/Gruntfile.js +1 -0
- package/README.md +7 -6
- package/SECURITY.md +3 -1
- package/package.json +22 -21
- package/src/core/Chef.mjs +2 -0
- package/src/core/Dish.mjs +1 -5
- package/src/core/Ingredient.mjs +92 -0
- package/src/core/Operation.mjs +19 -0
- package/src/core/Recipe.mjs +4 -0
- package/src/core/Utils.mjs +48 -0
- package/src/core/config/Categories.json +22 -6
- package/src/core/config/OperationConfig.json +4774 -1228
- package/src/core/config/modules/Ciphers.mjs +20 -0
- package/src/core/config/modules/Crypto.mjs +10 -0
- package/src/core/config/modules/Default.mjs +8 -0
- package/src/core/config/modules/File.mjs +16 -0
- package/src/core/config/modules/OpModules.mjs +2 -0
- package/src/core/config/scripts/generateHTMLEntities.mjs +139 -0
- package/src/core/config/scripts/htmlEntityOverrides.mjs +86 -0
- package/src/core/dishTypes/DishType.mjs +1 -1
- package/src/core/errors/ExcludedOperationError.mjs +1 -1
- package/src/core/lib/Arithmetic.mjs +21 -5
- package/src/core/lib/BigIntUtils.mjs +0 -1
- package/src/core/lib/COBS.mjs +86 -0
- package/src/core/lib/Charts.mjs +3 -3
- package/src/core/lib/Decimal.mjs +5 -5
- package/src/core/lib/HTMLEntities.mjs +2068 -0
- package/src/core/lib/Present.mjs +422 -0
- package/src/core/lib/Protocol.mjs +8 -6
- package/src/core/lib/TEA.mjs +494 -0
- package/src/core/lib/TLVParser.mjs +16 -7
- package/src/core/lib/Twofish.mjs +608 -0
- package/src/core/operations/AsconDecrypt.mjs +112 -0
- package/src/core/operations/AsconEncrypt.mjs +108 -0
- package/src/core/operations/AsconHash.mjs +49 -0
- package/src/core/operations/AsconMAC.mjs +68 -0
- package/src/core/operations/AutomatedValidationTestOp.mjs +84 -0
- package/src/core/operations/AvroToJSON.mjs +1 -1
- package/src/core/operations/BLAKE3.mjs +5 -1
- package/src/core/operations/BcryptCompare.mjs +11 -5
- package/src/core/operations/BitShiftLeft.mjs +4 -1
- package/src/core/operations/Bzip2Compress.mjs +1 -1
- package/src/core/operations/DechunkHTTPResponse.mjs +4 -1
- package/src/core/operations/ExtendedGCD.mjs +101 -0
- package/src/core/operations/FromBase.mjs +2 -1
- package/src/core/operations/FromCOBS.mjs +38 -0
- package/src/core/operations/FromDecimal.mjs +6 -1
- package/src/core/operations/FromHTMLEntity.mjs +2 -1458
- package/src/core/operations/GenerateDeBruijnSequence.mjs +8 -0
- package/src/core/operations/GenerateHOTP.mjs +21 -6
- package/src/core/operations/GenerateImage.mjs +22 -10
- package/src/core/operations/GeneratePrime.mjs +154 -0
- package/src/core/operations/GenerateTOTP.mjs +24 -7
- package/src/core/operations/Gzip.mjs +1 -3
- package/src/core/operations/Jsonata.mjs +12 -0
- package/src/core/operations/MIMEDecoding.mjs +1 -1
- package/src/core/operations/MOD.mjs +62 -0
- package/src/core/operations/ModularInverse.mjs +107 -0
- package/src/core/operations/PRESENTDecrypt.mjs +94 -0
- package/src/core/operations/PRESENTEncrypt.mjs +94 -0
- package/src/core/operations/ParityBit.mjs +1 -1
- package/src/core/operations/ParseIPv4Header.mjs +1 -1
- package/src/core/operations/ParseURI.mjs +18 -5
- package/src/core/operations/PseudoRandomNumberGenerator.mjs +2 -1
- package/src/core/operations/RandomPrime.mjs +154 -0
- package/src/core/operations/RenderPDF.mjs +100 -0
- package/src/core/operations/SHA2.mjs +1 -1
- package/src/core/operations/SM4Encrypt.mjs +1 -1
- package/src/core/operations/SetDifference.mjs +8 -1
- package/src/core/operations/SetIntersection.mjs +8 -1
- package/src/core/operations/ShowOnMap.mjs +14 -2
- package/src/core/operations/TEADecrypt.mjs +98 -0
- package/src/core/operations/TEAEncrypt.mjs +98 -0
- package/src/core/operations/ToBase.mjs +4 -4
- package/src/core/operations/ToBase32.mjs +20 -4
- package/src/core/operations/ToBinary.mjs +4 -1
- package/src/core/operations/ToCOBS.mjs +38 -0
- package/src/core/operations/ToHTMLEntity.mjs +7 -1430
- package/src/core/operations/ToHexdump.mjs +7 -1
- package/src/core/operations/TwofishDecrypt.mjs +94 -0
- package/src/core/operations/TwofishEncrypt.mjs +94 -0
- package/src/core/operations/URLEncode.mjs +22 -18
- package/src/core/operations/UnescapeUnicodeCharacters.mjs +2 -1
- package/src/core/operations/ViewBitPlane.mjs +9 -3
- package/src/core/operations/Wrap.mjs +5 -0
- package/src/core/operations/XORBruteForce.mjs +4 -1
- package/src/core/operations/XORChecksum.mjs +10 -3
- package/src/core/operations/XTEADecrypt.mjs +110 -0
- package/src/core/operations/XTEAEncrypt.mjs +110 -0
- package/src/core/operations/index.mjs +42 -0
- package/src/core/vendor/ascon.mjs +162 -0
- package/src/core/vendor/htmlEntities/entity.json +2233 -0
- package/src/core/vendor/htmlEntities/entity.txt +14 -0
- package/src/node/api.mjs +4 -1
- package/src/node/index.mjs +105 -0
- package/src/web/HTMLOperation.mjs +2 -1
- package/src/web/stylesheets/layout/_io.css +8 -0
- package/tests/browser/00_nightwatch.js +26 -0
- package/tests/browser/02_ops.js +20 -4
- package/tests/node/index.mjs +2 -0
- package/tests/node/tests/Dish.mjs +19 -0
- package/tests/node/tests/NodeDish.mjs +36 -0
- package/tests/node/tests/ToHTMLEntity.mjs +82 -0
- package/tests/node/tests/Utils.mjs +77 -0
- package/tests/node/tests/lib/ChartsProtocolPrototypePollution.mjs +90 -0
- package/tests/node/tests/nodeApi.mjs +33 -1
- package/tests/node/tests/operations.mjs +26 -1
- package/tests/operations/index.mjs +17 -0
- package/tests/operations/tests/Arithmetic.mjs +33 -0
- package/tests/operations/tests/Ascon.mjs +501 -0
- package/tests/operations/tests/AutomatedValidation.mjs +154 -0
- package/tests/operations/tests/BLAKE3.mjs +39 -1
- package/tests/operations/tests/Base32.mjs +22 -0
- package/tests/operations/tests/COBS.mjs +476 -0
- package/tests/operations/tests/CharEnc.mjs +2 -2
- package/tests/operations/tests/DechunkHTTPResponse.mjs +66 -0
- package/tests/operations/tests/ExtendedGCD.mjs +78 -0
- package/tests/operations/tests/FromBase.mjs +66 -0
- package/tests/operations/tests/FromDecimal.mjs +55 -0
- package/tests/operations/tests/GenerateLoremIpsum.mjs +2 -2
- package/tests/operations/tests/Gzip.mjs +60 -0
- package/tests/operations/tests/HTMLEntity.mjs +126 -0
- package/tests/operations/tests/Hash.mjs +44 -0
- package/tests/operations/tests/Hexdump.mjs +11 -0
- package/tests/operations/tests/Image.mjs +26 -0
- package/tests/operations/tests/Jsonata.mjs +23 -0
- package/tests/operations/tests/MIMEDecoding.mjs +33 -0
- package/tests/operations/tests/MOD.mjs +208 -0
- package/tests/operations/tests/Median.mjs +33 -0
- package/tests/operations/tests/ModularInverse.mjs +78 -0
- package/tests/operations/tests/OTP.mjs +167 -2
- package/tests/operations/tests/PRESENT.mjs +465 -0
- package/tests/operations/tests/ParseIPv4Header.mjs +11 -0
- package/tests/operations/tests/ParseTLV.mjs +41 -0
- package/tests/operations/tests/RenderPDF.mjs +55 -0
- package/tests/operations/tests/SM2.mjs +1 -1
- package/tests/operations/tests/SetDifference.mjs +22 -0
- package/tests/operations/tests/SetIntersection.mjs +23 -1
- package/tests/operations/tests/ShowOnMap.mjs +61 -0
- package/tests/operations/tests/TEA.mjs +566 -0
- package/tests/operations/tests/Twofish.mjs +486 -0
- package/tests/operations/tests/URLEncodeDecode.mjs +26 -0
- package/tests/operations/tests/UnescapeUnicodeCharacters.mjs +88 -0
- package/tests/operations/tests/Wrap.mjs +44 -0
- package/webpack.config.js +3 -3
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ascon tests.
|
|
3
|
+
*
|
|
4
|
+
* Test vectors include official NIST ACVP vectors from:
|
|
5
|
+
* https://github.com/usnistgov/ACVP-Server/tree/master/gen-val/json-files/Ascon-Hash256-SP800-232
|
|
6
|
+
* https://github.com/ascon/ascon-c (LWC_AEAD_KAT files)
|
|
7
|
+
*
|
|
8
|
+
* @author Medjedtxm
|
|
9
|
+
* @copyright Crown Copyright 2025
|
|
10
|
+
* @license Apache-2.0
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import TestRegister from "../../lib/TestRegister.mjs";
|
|
14
|
+
|
|
15
|
+
TestRegister.addTests([
|
|
16
|
+
// ============= Ascon Hash Tests (NIST SP 800-232) =============
|
|
17
|
+
// Official NIST ACVP test vector
|
|
18
|
+
{
|
|
19
|
+
name: "Ascon Hash: NIST ACVP vector (msg=0x50)",
|
|
20
|
+
input: "P", // 0x50
|
|
21
|
+
expectedOutput: "b96da347d720272533a87f5a94a356155f49cdf7c0c10a3e6f346d8a2293e480",
|
|
22
|
+
recipeConfig: [
|
|
23
|
+
{
|
|
24
|
+
"op": "Ascon Hash",
|
|
25
|
+
"args": []
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "Ascon Hash: empty input",
|
|
31
|
+
input: "",
|
|
32
|
+
expectedOutput: "0b3be5850f2f6b98caf29f8fdea89b64a1fa70aa249b8f839bd53baa304d92b2",
|
|
33
|
+
recipeConfig: [
|
|
34
|
+
{
|
|
35
|
+
"op": "Ascon Hash",
|
|
36
|
+
"args": []
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "Ascon Hash: Hello",
|
|
42
|
+
input: "Hello",
|
|
43
|
+
expectedOutput: "c1beebe1251d562c4526d6b947cefb932998499424f6cd186e764aa0a36cddb7",
|
|
44
|
+
recipeConfig: [
|
|
45
|
+
{
|
|
46
|
+
"op": "Ascon Hash",
|
|
47
|
+
"args": []
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "Ascon Hash: Hello, World!",
|
|
53
|
+
input: "Hello, World!",
|
|
54
|
+
expectedOutput: "f40e1ce8d4272e628e9535193f196f4ff2a720b00f6380c5d6f16b975f3a7777",
|
|
55
|
+
recipeConfig: [
|
|
56
|
+
{
|
|
57
|
+
"op": "Ascon Hash",
|
|
58
|
+
"args": []
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// ============= Ascon MAC Tests (NIST LWC_MAC_KAT_128_128.txt) =============
|
|
64
|
+
// Official test vectors from ascon-c: https://github.com/ascon/ascon-c/blob/main/crypto_auth/asconmacv13/LWC_MAC_KAT_128_128.txt
|
|
65
|
+
{
|
|
66
|
+
name: "Ascon MAC: NIST KAT Count=1 (empty message)",
|
|
67
|
+
input: "",
|
|
68
|
+
expectedOutput: "eac9d74bbedf8bf1eba2862b26aa6d39",
|
|
69
|
+
recipeConfig: [
|
|
70
|
+
{
|
|
71
|
+
"op": "Ascon MAC",
|
|
72
|
+
"args": [
|
|
73
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "Ascon MAC: NIST KAT Count=2 (Msg=0x10)",
|
|
80
|
+
input: "\x10",
|
|
81
|
+
expectedOutput: "e5be5b6dfb7b0e3eae00a070791947a8",
|
|
82
|
+
recipeConfig: [
|
|
83
|
+
{
|
|
84
|
+
"op": "Ascon MAC",
|
|
85
|
+
"args": [
|
|
86
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "Ascon MAC: NIST KAT Count=5 (Msg=0x10111213)",
|
|
93
|
+
input: "\x10\x11\x12\x13",
|
|
94
|
+
expectedOutput: "727f6386405a52ad7ca0669a6a885294",
|
|
95
|
+
recipeConfig: [
|
|
96
|
+
{
|
|
97
|
+
"op": "Ascon MAC",
|
|
98
|
+
"args": [
|
|
99
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "Ascon MAC: invalid key length",
|
|
106
|
+
input: "test",
|
|
107
|
+
expectedOutput: "Invalid key length: 8 bytes.\n\nAscon-Mac requires a key of exactly 16 bytes (128 bits).",
|
|
108
|
+
recipeConfig: [
|
|
109
|
+
{
|
|
110
|
+
"op": "Ascon MAC",
|
|
111
|
+
"args": [
|
|
112
|
+
{"option": "Hex", "string": "0001020304050607"}
|
|
113
|
+
]
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
// ============= Ascon Encrypt Tests (NIST SP 800-232) =============
|
|
119
|
+
// Official NIST ascon-c KAT test vector (Count=1)
|
|
120
|
+
// https://github.com/ascon/ascon-c/blob/main/crypto_aead/asconaead128/LWC_AEAD_KAT_128_128.txt
|
|
121
|
+
{
|
|
122
|
+
name: "Ascon Encrypt: NIST KAT Count=1 (empty PT, empty AD)",
|
|
123
|
+
input: "",
|
|
124
|
+
expectedOutput: "4f9c278211bec9316bf68f46ee8b2ec6",
|
|
125
|
+
recipeConfig: [
|
|
126
|
+
{
|
|
127
|
+
"op": "Ascon Encrypt",
|
|
128
|
+
"args": [
|
|
129
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
130
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
131
|
+
{"option": "Hex", "string": ""},
|
|
132
|
+
"Raw", "Hex"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
// Official NIST ascon-c KAT test vector (Count=2)
|
|
138
|
+
{
|
|
139
|
+
name: "Ascon Encrypt: NIST KAT Count=2 (empty PT, AD=0x30)",
|
|
140
|
+
input: "",
|
|
141
|
+
expectedOutput: "cccb674fe18a09a285d6ab11b35675c0",
|
|
142
|
+
recipeConfig: [
|
|
143
|
+
{
|
|
144
|
+
"op": "Ascon Encrypt",
|
|
145
|
+
"args": [
|
|
146
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
147
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
148
|
+
{"option": "Hex", "string": "30"},
|
|
149
|
+
"Raw", "Hex"
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
// Official NIST ascon-c KAT test vector (Count=34) - PT=0x20
|
|
155
|
+
{
|
|
156
|
+
name: "Ascon Encrypt: NIST KAT Count=34 (PT=0x20, empty AD)",
|
|
157
|
+
input: "\x20",
|
|
158
|
+
expectedOutput: "e8dd576aba1cd3e6fc704de02aedb79588",
|
|
159
|
+
recipeConfig: [
|
|
160
|
+
{
|
|
161
|
+
"op": "Ascon Encrypt",
|
|
162
|
+
"args": [
|
|
163
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
164
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
165
|
+
{"option": "Hex", "string": ""},
|
|
166
|
+
"Raw", "Hex"
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
// Official NIST ascon-c KAT test vector (Count=341) - PT + AD
|
|
172
|
+
{
|
|
173
|
+
name: "Ascon Encrypt: NIST KAT Count=341 (PT=10 bytes, AD=10 bytes)",
|
|
174
|
+
input: "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29",
|
|
175
|
+
expectedOutput: "12042996da42b4536e5a0e64692cf6041ff8c367e1423253c84c",
|
|
176
|
+
recipeConfig: [
|
|
177
|
+
{
|
|
178
|
+
"op": "Ascon Encrypt",
|
|
179
|
+
"args": [
|
|
180
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
181
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
182
|
+
{"option": "Hex", "string": "30313233343536373839"},
|
|
183
|
+
"Raw", "Hex"
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
// Official NIST ascon-c KAT test vector (PT=16 bytes, AD=16 bytes)
|
|
189
|
+
{
|
|
190
|
+
name: "Ascon Encrypt: NIST KAT (PT=16 bytes, AD=16 bytes)",
|
|
191
|
+
input: "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f",
|
|
192
|
+
expectedOutput: "6373ebb28be97c9bac090cf399c13ef13abfc0d209e8f4844c90814d13f32c59",
|
|
193
|
+
recipeConfig: [
|
|
194
|
+
{
|
|
195
|
+
"op": "Ascon Encrypt",
|
|
196
|
+
"args": [
|
|
197
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
198
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
199
|
+
{"option": "Hex", "string": "303132333435363738393a3b3c3d3e3f"},
|
|
200
|
+
"Raw", "Hex"
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
],
|
|
204
|
+
},
|
|
205
|
+
// https://github.com/ascon/ascon-c/blob/main/crypto_aead/asconaead128/LWC_AEAD_KAT_128_128.txt
|
|
206
|
+
{
|
|
207
|
+
name: "Ascon Encrypt: no key",
|
|
208
|
+
input: "test message",
|
|
209
|
+
expectedOutput: `Invalid key length: 0 bytes.
|
|
210
|
+
|
|
211
|
+
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`,
|
|
212
|
+
recipeConfig: [
|
|
213
|
+
{
|
|
214
|
+
"op": "Ascon Encrypt",
|
|
215
|
+
"args": [
|
|
216
|
+
{"option": "Hex", "string": ""},
|
|
217
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
218
|
+
{"option": "Hex", "string": ""},
|
|
219
|
+
"Raw", "Hex"
|
|
220
|
+
]
|
|
221
|
+
}
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: "Ascon Encrypt: invalid key length",
|
|
226
|
+
input: "test message",
|
|
227
|
+
expectedOutput: `Invalid key length: 8 bytes.
|
|
228
|
+
|
|
229
|
+
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`,
|
|
230
|
+
recipeConfig: [
|
|
231
|
+
{
|
|
232
|
+
"op": "Ascon Encrypt",
|
|
233
|
+
"args": [
|
|
234
|
+
{"option": "Hex", "string": "0001020304050607"},
|
|
235
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
236
|
+
{"option": "Hex", "string": ""},
|
|
237
|
+
"Raw", "Hex"
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: "Ascon Encrypt: no nonce",
|
|
244
|
+
input: "test message",
|
|
245
|
+
expectedOutput: `Invalid nonce length: 0 bytes.
|
|
246
|
+
|
|
247
|
+
Ascon-AEAD128 requires a nonce of exactly 16 bytes (128 bits).`,
|
|
248
|
+
recipeConfig: [
|
|
249
|
+
{
|
|
250
|
+
"op": "Ascon Encrypt",
|
|
251
|
+
"args": [
|
|
252
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
253
|
+
{"option": "Hex", "string": ""},
|
|
254
|
+
{"option": "Hex", "string": ""},
|
|
255
|
+
"Raw", "Hex"
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "Ascon Encrypt: invalid nonce length",
|
|
262
|
+
input: "test message",
|
|
263
|
+
expectedOutput: `Invalid nonce length: 12 bytes.
|
|
264
|
+
|
|
265
|
+
Ascon-AEAD128 requires a nonce of exactly 16 bytes (128 bits).`,
|
|
266
|
+
recipeConfig: [
|
|
267
|
+
{
|
|
268
|
+
"op": "Ascon Encrypt",
|
|
269
|
+
"args": [
|
|
270
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
271
|
+
{"option": "Hex", "string": "000102030405060708090a0b"},
|
|
272
|
+
{"option": "Hex", "string": ""},
|
|
273
|
+
"Raw", "Hex"
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: "Ascon Encrypt: basic encryption",
|
|
280
|
+
input: "Hello",
|
|
281
|
+
expectedOutput: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
|
282
|
+
recipeConfig: [
|
|
283
|
+
{
|
|
284
|
+
"op": "Ascon Encrypt",
|
|
285
|
+
"args": [
|
|
286
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
287
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
288
|
+
{"option": "Hex", "string": ""},
|
|
289
|
+
"Raw", "Hex"
|
|
290
|
+
]
|
|
291
|
+
}
|
|
292
|
+
],
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
name: "Ascon Encrypt: with associated data",
|
|
296
|
+
input: "Hello",
|
|
297
|
+
expectedOutput: "351880c09f9dee12c20c4ba973066bc10dd26000b6",
|
|
298
|
+
recipeConfig: [
|
|
299
|
+
{
|
|
300
|
+
"op": "Ascon Encrypt",
|
|
301
|
+
"args": [
|
|
302
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
303
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
304
|
+
{"option": "UTF8", "string": "metadata"},
|
|
305
|
+
"Raw", "Hex"
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: "Ascon Encrypt: longer message",
|
|
312
|
+
input: "test message",
|
|
313
|
+
expectedOutput: "9314a3fef6cc299a07b8c9e0f9e479ca0d1187e87345cf590adc572b",
|
|
314
|
+
recipeConfig: [
|
|
315
|
+
{
|
|
316
|
+
"op": "Ascon Encrypt",
|
|
317
|
+
"args": [
|
|
318
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
319
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
320
|
+
{"option": "Hex", "string": ""},
|
|
321
|
+
"Raw", "Hex"
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
],
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "Ascon Encrypt: empty plaintext",
|
|
328
|
+
input: "",
|
|
329
|
+
expectedOutput: "4427d64b8e1e1451fc445960f0839bb0",
|
|
330
|
+
recipeConfig: [
|
|
331
|
+
{
|
|
332
|
+
"op": "Ascon Encrypt",
|
|
333
|
+
"args": [
|
|
334
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
335
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
336
|
+
{"option": "Hex", "string": ""},
|
|
337
|
+
"Raw", "Hex"
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: "Ascon Encrypt: zero key and nonce",
|
|
344
|
+
input: "Hello",
|
|
345
|
+
expectedOutput: "403281e117ebb087e2d9196552b2d123bccb7b5500",
|
|
346
|
+
recipeConfig: [
|
|
347
|
+
{
|
|
348
|
+
"op": "Ascon Encrypt",
|
|
349
|
+
"args": [
|
|
350
|
+
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
|
351
|
+
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
|
352
|
+
{"option": "Hex", "string": ""},
|
|
353
|
+
"Raw", "Hex"
|
|
354
|
+
]
|
|
355
|
+
}
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
// ============= Ascon Decrypt Tests =============
|
|
360
|
+
{
|
|
361
|
+
name: "Ascon Decrypt: no key",
|
|
362
|
+
input: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
|
363
|
+
expectedOutput: `Invalid key length: 0 bytes.
|
|
364
|
+
|
|
365
|
+
Ascon-AEAD128 requires a key of exactly 16 bytes (128 bits).`,
|
|
366
|
+
recipeConfig: [
|
|
367
|
+
{
|
|
368
|
+
"op": "Ascon Decrypt",
|
|
369
|
+
"args": [
|
|
370
|
+
{"option": "Hex", "string": ""},
|
|
371
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
372
|
+
{"option": "Hex", "string": ""},
|
|
373
|
+
"Hex", "Raw"
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
],
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
name: "Ascon Decrypt: basic decryption",
|
|
380
|
+
input: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
|
381
|
+
expectedOutput: "Hello",
|
|
382
|
+
recipeConfig: [
|
|
383
|
+
{
|
|
384
|
+
"op": "Ascon Decrypt",
|
|
385
|
+
"args": [
|
|
386
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
387
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
388
|
+
{"option": "Hex", "string": ""},
|
|
389
|
+
"Hex", "Raw"
|
|
390
|
+
]
|
|
391
|
+
}
|
|
392
|
+
],
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
name: "Ascon Decrypt: with associated data",
|
|
396
|
+
input: "351880c09f9dee12c20c4ba973066bc10dd26000b6",
|
|
397
|
+
expectedOutput: "Hello",
|
|
398
|
+
recipeConfig: [
|
|
399
|
+
{
|
|
400
|
+
"op": "Ascon Decrypt",
|
|
401
|
+
"args": [
|
|
402
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
403
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
404
|
+
{"option": "UTF8", "string": "metadata"},
|
|
405
|
+
"Hex", "Raw"
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "Ascon Decrypt: longer message",
|
|
412
|
+
input: "9314a3fef6cc299a07b8c9e0f9e479ca0d1187e87345cf590adc572b",
|
|
413
|
+
expectedOutput: "test message",
|
|
414
|
+
recipeConfig: [
|
|
415
|
+
{
|
|
416
|
+
"op": "Ascon Decrypt",
|
|
417
|
+
"args": [
|
|
418
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
419
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
420
|
+
{"option": "Hex", "string": ""},
|
|
421
|
+
"Hex", "Raw"
|
|
422
|
+
]
|
|
423
|
+
}
|
|
424
|
+
],
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: "Ascon Decrypt: authentication failure (tampered ciphertext)",
|
|
428
|
+
input: "bf14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
|
429
|
+
expectedOutput: "Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.",
|
|
430
|
+
recipeConfig: [
|
|
431
|
+
{
|
|
432
|
+
"op": "Ascon Decrypt",
|
|
433
|
+
"args": [
|
|
434
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
435
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
436
|
+
{"option": "Hex", "string": ""},
|
|
437
|
+
"Hex", "Raw"
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
],
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: "Ascon Decrypt: authentication failure (wrong key)",
|
|
444
|
+
input: "af14bce6b9b6588c3aa63f9ddc5a0cf5f565f358b0",
|
|
445
|
+
expectedOutput: "Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.",
|
|
446
|
+
recipeConfig: [
|
|
447
|
+
{
|
|
448
|
+
"op": "Ascon Decrypt",
|
|
449
|
+
"args": [
|
|
450
|
+
{"option": "Hex", "string": "ff0102030405060708090a0b0c0d0e0f"},
|
|
451
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
452
|
+
{"option": "Hex", "string": ""},
|
|
453
|
+
"Hex", "Raw"
|
|
454
|
+
]
|
|
455
|
+
}
|
|
456
|
+
],
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
name: "Ascon Decrypt: authentication failure (wrong associated data)",
|
|
460
|
+
input: "351880c09f9dee12c20c4ba973066bc10dd26000b6",
|
|
461
|
+
expectedOutput: "Unable to decrypt: authentication failed. The ciphertext, key, nonce, or associated data may be incorrect or tampered with.",
|
|
462
|
+
recipeConfig: [
|
|
463
|
+
{
|
|
464
|
+
"op": "Ascon Decrypt",
|
|
465
|
+
"args": [
|
|
466
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
467
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
468
|
+
{"option": "UTF8", "string": "wrong data"},
|
|
469
|
+
"Hex", "Raw"
|
|
470
|
+
]
|
|
471
|
+
}
|
|
472
|
+
],
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
// ============= Round-trip Tests =============
|
|
476
|
+
{
|
|
477
|
+
name: "Ascon: encrypt then decrypt round-trip",
|
|
478
|
+
input: "This is a test message for Ascon AEAD encryption!",
|
|
479
|
+
expectedOutput: "This is a test message for Ascon AEAD encryption!",
|
|
480
|
+
recipeConfig: [
|
|
481
|
+
{
|
|
482
|
+
"op": "Ascon Encrypt",
|
|
483
|
+
"args": [
|
|
484
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
485
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
486
|
+
{"option": "UTF8", "string": "additional data"},
|
|
487
|
+
"Raw", "Hex"
|
|
488
|
+
]
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"op": "Ascon Decrypt",
|
|
492
|
+
"args": [
|
|
493
|
+
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
|
494
|
+
{"option": "Hex", "string": "101112131415161718191a1b1c1d1e1f"},
|
|
495
|
+
{"option": "UTF8", "string": "additional data"},
|
|
496
|
+
"Hex", "Raw"
|
|
497
|
+
]
|
|
498
|
+
}
|
|
499
|
+
],
|
|
500
|
+
},
|
|
501
|
+
]);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automated Parameter Validation tests
|
|
3
|
+
*
|
|
4
|
+
* @author CyberChef
|
|
5
|
+
* @copyright Crown Copyright 2026
|
|
6
|
+
* @license Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
import TestRegister from "../../lib/TestRegister.mjs";
|
|
9
|
+
|
|
10
|
+
TestRegister.addTests([
|
|
11
|
+
{
|
|
12
|
+
name: "Automated Validation: Valid values",
|
|
13
|
+
input: "test",
|
|
14
|
+
expectedOutput: "Success",
|
|
15
|
+
recipeConfig: [
|
|
16
|
+
{
|
|
17
|
+
op: "Automated Validation Test Op",
|
|
18
|
+
args: [5, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "Automated Validation: Integer Number under min limit",
|
|
24
|
+
input: "test",
|
|
25
|
+
expectedOutput: "Integer Number must be greater than or equal to 5.",
|
|
26
|
+
recipeConfig: [
|
|
27
|
+
{
|
|
28
|
+
op: "Automated Validation Test Op",
|
|
29
|
+
args: [4, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "Automated Validation: Integer Number over max limit",
|
|
35
|
+
input: "test",
|
|
36
|
+
expectedOutput: "Integer Number must be less than or equal to 10.",
|
|
37
|
+
recipeConfig: [
|
|
38
|
+
{
|
|
39
|
+
op: "Automated Validation Test Op",
|
|
40
|
+
args: [11, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "Automated Validation: Integer Number not an integer",
|
|
46
|
+
input: "test",
|
|
47
|
+
expectedOutput: "Integer Number must be an integer.",
|
|
48
|
+
recipeConfig: [
|
|
49
|
+
{
|
|
50
|
+
op: "Automated Validation Test Op",
|
|
51
|
+
args: [5.5, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "Automated Validation: Real Number under min limit",
|
|
57
|
+
input: "test",
|
|
58
|
+
expectedOutput: "Real Number must be greater than or equal to 1.5.",
|
|
59
|
+
recipeConfig: [
|
|
60
|
+
{
|
|
61
|
+
op: "Automated Validation Test Op",
|
|
62
|
+
args: [5, 1.4, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "Automated Validation: Real Number over max limit",
|
|
68
|
+
input: "test",
|
|
69
|
+
expectedOutput: "Real Number must be less than or equal to 5.5.",
|
|
70
|
+
recipeConfig: [
|
|
71
|
+
{
|
|
72
|
+
op: "Automated Validation Test Op",
|
|
73
|
+
args: [5, 5.6, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "Automated Validation: Non Empty String over maxLength limit",
|
|
79
|
+
input: "test",
|
|
80
|
+
expectedOutput: "Non Empty String length cannot exceed 5.",
|
|
81
|
+
recipeConfig: [
|
|
82
|
+
{
|
|
83
|
+
op: "Automated Validation Test Op",
|
|
84
|
+
args: [5, 1.5, "helloooo", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "Automated Validation: Non Empty String is empty",
|
|
90
|
+
input: "test",
|
|
91
|
+
expectedOutput: "Non Empty String cannot be empty.",
|
|
92
|
+
recipeConfig: [
|
|
93
|
+
{
|
|
94
|
+
op: "Automated Validation Test Op",
|
|
95
|
+
args: [5, 1.5, "", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: "Automated Validation: Empty Allowed String is empty (allowed)",
|
|
101
|
+
input: "test",
|
|
102
|
+
expectedOutput: "Success",
|
|
103
|
+
recipeConfig: [
|
|
104
|
+
{
|
|
105
|
+
op: "Automated Validation Test Op",
|
|
106
|
+
args: [5, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "Option 1"]
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "Automated Validation: Non Empty Toggle String is empty",
|
|
112
|
+
input: "test",
|
|
113
|
+
expectedOutput: "Non Empty Toggle String cannot be empty.",
|
|
114
|
+
recipeConfig: [
|
|
115
|
+
{
|
|
116
|
+
op: "Automated Validation Test Op",
|
|
117
|
+
args: [5, 1.5, "hello", "", { "option": "Option A", "string": "" }, "Option 1"]
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "Automated Validation: Invalid Option value",
|
|
123
|
+
input: "test",
|
|
124
|
+
expectedOutput: "Option Ingredient must be one of the following: Option 1, Option 2, Option 3.",
|
|
125
|
+
recipeConfig: [
|
|
126
|
+
{
|
|
127
|
+
op: "Automated Validation Test Op",
|
|
128
|
+
args: [5, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "Option 4"]
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "Automated Validation: Option value as optgroup heading (invalid)",
|
|
134
|
+
input: "test",
|
|
135
|
+
expectedOutput: "Option Ingredient must be one of the following: Option 1, Option 2, Option 3.",
|
|
136
|
+
recipeConfig: [
|
|
137
|
+
{
|
|
138
|
+
op: "Automated Validation Test Op",
|
|
139
|
+
args: [5, 1.5, "hello", "", { "option": "Option A", "string": "test" }, "[Group 1]"]
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "Automated Validation: Option value empty (invalid)",
|
|
145
|
+
input: "test",
|
|
146
|
+
expectedOutput: "Option Ingredient cannot be empty.",
|
|
147
|
+
recipeConfig: [
|
|
148
|
+
{
|
|
149
|
+
op: "Automated Validation Test Op",
|
|
150
|
+
args: [5, 1.5, "hello", "", { "option": "Option A", "string": "test" }, ""]
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
]);
|