mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-26 01:36:17 -04:00
Merge branch 'gchq:master' into protobufstreamdecode
This commit is contained in:
commit
a51ead9051
77 changed files with 4047 additions and 3407 deletions
|
@ -30,6 +30,7 @@ import "./tests/ByteRepr.mjs";
|
|||
import "./tests/CartesianProduct.mjs";
|
||||
import "./tests/CetaceanCipherEncode.mjs";
|
||||
import "./tests/CetaceanCipherDecode.mjs";
|
||||
import "./tests/ChaCha.mjs";
|
||||
import "./tests/CharEnc.mjs";
|
||||
import "./tests/ChangeIPFormat.mjs";
|
||||
import "./tests/Charts.mjs";
|
||||
|
@ -45,6 +46,7 @@ import "./tests/DateTime.mjs";
|
|||
import "./tests/ExtractEmailAddresses.mjs";
|
||||
import "./tests/Fork.mjs";
|
||||
import "./tests/FromDecimal.mjs";
|
||||
import "./tests/GenerateAllHashes.mjs";
|
||||
import "./tests/Gzip.mjs";
|
||||
import "./tests/Gunzip.mjs";
|
||||
import "./tests/Hash.mjs";
|
||||
|
@ -119,9 +121,15 @@ import "./tests/SIGABA.mjs";
|
|||
import "./tests/ELFInfo.mjs";
|
||||
import "./tests/Subsection.mjs";
|
||||
import "./tests/CaesarBoxCipher.mjs";
|
||||
import "./tests/UnescapeString.mjs";
|
||||
import "./tests/LS47.mjs";
|
||||
import "./tests/LZString.mjs";
|
||||
|
||||
import "./tests/NTLM.mjs";
|
||||
import "./tests/Shuffle.mjs";
|
||||
import "./tests/FletcherChecksum.mjs";
|
||||
import "./tests/CMAC.mjs";
|
||||
import "./tests/AESKeyWrap.mjs";
|
||||
import "./tests/Rabbit.mjs";
|
||||
|
||||
// Cannot test operations that use the File type yet
|
||||
// import "./tests/SplitColourChannels.mjs";
|
||||
|
|
324
tests/operations/tests/AESKeyWrap.mjs
Normal file
324
tests/operations/tests/AESKeyWrap.mjs
Normal file
|
@ -0,0 +1,324 @@
|
|||
/**
|
||||
* @author mikecat
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
"name": "AES Key Wrap: RFC Test Vector, 128-bit data, 128-bit KEK",
|
||||
"input": "00112233445566778899aabbccddeeff",
|
||||
"expectedOutput": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: RFC Test Vector, 128-bit data, 192-bit KEK",
|
||||
"input": "00112233445566778899aabbccddeeff",
|
||||
"expectedOutput": "96778b25ae6ca435f92b5b97c050aed2468ab8a17ad84e5d",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: RFC Test Vector, 128-bit data, 256-bit KEK",
|
||||
"input": "00112233445566778899aabbccddeeff",
|
||||
"expectedOutput": "64e8c3f9ce0f5ba263e9777905818a2a93c8191e7d6e8ae7",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: RFC Test Vector, 192-bit data, 192-bit KEK",
|
||||
"input": "00112233445566778899aabbccddeeff0001020304050607",
|
||||
"expectedOutput": "031d33264e15d33268f24ec260743edce1c6c7ddee725a936ba814915c6762d2",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: RFC Test Vector, 192-bit data, 256-bit KEK",
|
||||
"input": "00112233445566778899aabbccddeeff0001020304050607",
|
||||
"expectedOutput": "a8f9bc1612c68b3ff6e6f4fbe30e71e4769c8b80a32cb8958cd5d17d6b254da1",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: RFC Test Vector, 256-bit data, 256-bit KEK",
|
||||
"input": "00112233445566778899aabbccddeeff000102030405060708090a0b0c0d0e0f",
|
||||
"expectedOutput": "28c9f404c4b810f4cbccb35cfb87f8263f5786e2d80ed326cbc7f0e71a99f43bfb988b9b7a02dd21",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: RFC Test Vector, 128-bit data, 128-bit KEK",
|
||||
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
|
||||
"expectedOutput": "00112233445566778899aabbccddeeff",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: RFC Test Vector, 128-bit data, 192-bit KEK",
|
||||
"input": "96778b25ae6ca435f92b5b97c050aed2468ab8a17ad84e5d",
|
||||
"expectedOutput": "00112233445566778899aabbccddeeff",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: RFC Test Vector, 128-bit data, 256-bit KEK",
|
||||
"input": "64e8c3f9ce0f5ba263e9777905818a2a93c8191e7d6e8ae7",
|
||||
"expectedOutput": "00112233445566778899aabbccddeeff",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: RFC Test Vector, 192-bit data, 192-bit KEK",
|
||||
"input": "031d33264e15d33268f24ec260743edce1c6c7ddee725a936ba814915c6762d2",
|
||||
"expectedOutput": "00112233445566778899aabbccddeeff0001020304050607",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f1011121314151617"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: RFC Test Vector, 192-bit data, 256-bit KEK",
|
||||
"input": "a8f9bc1612c68b3ff6e6f4fbe30e71e4769c8b80a32cb8958cd5d17d6b254da1",
|
||||
"expectedOutput": "00112233445566778899aabbccddeeff0001020304050607",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: RFC Test Vector, 256-bit data, 256-bit KEK",
|
||||
"input": "28c9f404c4b810f4cbccb35cfb87f8263f5786e2d80ed326cbc7f0e71a99f43bfb988b9b7a02dd21",
|
||||
"expectedOutput": "00112233445566778899aabbccddeeff000102030405060708090a0b0c0d0e0f",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: invalid KEK length",
|
||||
"input": "00112233445566778899aabbccddeeff",
|
||||
"expectedOutput": "KEK must be either 16, 24, or 32 bytes (currently 10 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00010203040506070809"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: invalid IV length",
|
||||
"input": "00112233445566778899aabbccddeeff",
|
||||
"expectedOutput": "IV must be 8 bytes (currently 6 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: input length not multiple of 8",
|
||||
"input": "00112233445566778899aabbccddeeff0102",
|
||||
"expectedOutput": "input must be 8n (n>=2) bytes (currently 18 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Wrap: input too short",
|
||||
"input": "0011223344556677",
|
||||
"expectedOutput": "input must be 8n (n>=2) bytes (currently 8 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Wrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: invalid KEK length",
|
||||
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
|
||||
"expectedOutput": "KEK must be either 16, 24, or 32 bytes (currently 10 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00010203040506070809"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: invalid IV length",
|
||||
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5",
|
||||
"expectedOutput": "IV must be 8 bytes (currently 6 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: input length not multiple of 8",
|
||||
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe5e621",
|
||||
"expectedOutput": "input must be 8n (n>=3) bytes (currently 26 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: input too short",
|
||||
"input": "1fa68b0a8112b447aef34bd8fb5a7b82",
|
||||
"expectedOutput": "input must be 8n (n>=3) bytes (currently 16 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"name": "AES Key Unwrap: corrupted input",
|
||||
"input": "1fa68b0a8112b447aef34bd8fb5a7b829d3e862371d2cfe6",
|
||||
"expectedOutput": "IV mismatch",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "AES Key Unwrap",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "000102030405060708090a0b0c0d0e0f"},
|
||||
{"option": "Hex", "string": "a6a6a6a6a6a6a6a6"},
|
||||
"Hex", "Hex"
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
|
@ -16,6 +16,10 @@ DIb:@FD,*)+C]U=@3BN#EcYf8ATD3s@q?d$AftVqCh[NqF<G:8+EV:.+Cf>-FD5W8ARlolDIal(\
|
|||
DId<j@<?3r@:F%a+D58'ATD4$Bl@l3De:,-DJs`8ARoFb/0JMK@qB4^F!,R<AKZ&-DfTqBG%G>u\
|
||||
D.RTpAKYo'+CT/5+Cei#DII?(E,9)oF*2M7/c";
|
||||
|
||||
const allZeroExample = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff";
|
||||
|
||||
const allZeroOutput = "zz!!*-'\"9eu7#RLhG$k3[W&.oNg'GVB\"(`=52*$$(B+<_pR,UFcb-n-Vr/1iJ-0JP==1c70M3&s#]4?Ykm5X@_(6q'R884cEH9MJ8X:f1+h<)lt#=BSg3>[:ZC?t!MSA7]@cBPD3sCi+'.E,fo>FEMbNG^4U^I!pHnJ:W<)KS>/9Ll%\"IN/`jYOHG]iPa.Q$R$jD4S=Q7DTV8*TUnsrdW2ZetXKAY/Yd(L?['d?O\\@K2_]Y2%o^qmn*`5Ta:aN;TJbg\"GZd*^:jeCE.%f\\,!5gtgiEi8N\\UjQ5OekiqBum-X60nF?)@o_%qPq\"ad`r;HWp";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "To Base85",
|
||||
|
@ -45,4 +49,22 @@ TestRegister.addTests([
|
|||
"args": ["!-u", false] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "To Base85",
|
||||
input: allZeroExample,
|
||||
expectedOutput: allZeroOutput,
|
||||
recipeConfig: [
|
||||
{ "op": "To Base85",
|
||||
"args": ["!-u"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "From Base85",
|
||||
input: allZeroOutput,
|
||||
expectedOutput: allZeroExample,
|
||||
recipeConfig: [
|
||||
{ "op": "From Base85",
|
||||
"args": ["!-u", true, "z"] }
|
||||
]
|
||||
},
|
||||
]);
|
||||
|
|
314
tests/operations/tests/CMAC.mjs
Normal file
314
tests/operations/tests/CMAC.mjs
Normal file
|
@ -0,0 +1,314 @@
|
|||
/**
|
||||
* @author mikecat
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
// values in "NIST's CSRC" testcases are taken from here:
|
||||
// https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
"name": "CMAC-AES128 NIST's CSRC Example #1",
|
||||
"input": "",
|
||||
"expectedOutput": "bb1d6929e95937287fa37d129b756746",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES128 NIST's CSRC Example #2",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172a",
|
||||
"expectedOutput": "070a16b46b4d4144f79bdd9dd04a287c",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES128 NIST's CSRC Example #3",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
||||
"expectedOutput": "7d85449ea6ea19c823a7bf78837dfade",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES128 NIST's CSRC Example #4",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
|
||||
"expectedOutput": "51f0bebf7e3b9d92fc49741779363cfe",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "2b7e151628aed2a6abf7158809cf4f3c"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES192 NIST's CSRC Example #1",
|
||||
"input": "",
|
||||
"expectedOutput": "d17ddf46adaacde531cac483de7a9367",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES192 NIST's CSRC Example #2",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172a",
|
||||
"expectedOutput": "9e99a7bf31e710900662f65e617c5184",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES192 NIST's CSRC Example #3",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
||||
"expectedOutput": "3d75c194ed96070444a9fa7ec740ecf8",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES192 NIST's CSRC Example #4",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
|
||||
"expectedOutput": "a1d5df0eed790f794d77589659f39a11",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES256 NIST's CSRC Example #1",
|
||||
"input": "",
|
||||
"expectedOutput": "028962f61b7bf89efc6b551f4667d983",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES256 NIST's CSRC Example #2",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172a",
|
||||
"expectedOutput": "28a7023f452e8f82bd4bf28d8c37c35c",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES256 NIST's CSRC Example #3",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
||||
"expectedOutput": "156727dc0878944a023c1fe03bad6d93",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES256 NIST's CSRC Example #4",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710",
|
||||
"expectedOutput": "e1992190549f6ed5696a2c056c315410",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (1) NIST's CSRC Sample #1",
|
||||
"input": "",
|
||||
"expectedOutput": "7db0d37df936c550",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (1) NIST's CSRC Sample #2",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172a",
|
||||
"expectedOutput": "30239cf1f52e6609",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (1) NIST's CSRC Sample #3",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
||||
"expectedOutput": "6c9f3ee4923f6be2",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (1) NIST's CSRC Sample #4",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
|
||||
"expectedOutput": "99429bd0bf7904e5",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef01456789abcdef0123"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (2) NIST's CSRC Sample #1",
|
||||
"input": "",
|
||||
"expectedOutput": "79ce52a7f786a960",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (2) NIST's CSRC Sample #2",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172a",
|
||||
"expectedOutput": "cc18a0b79af2413b",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (2) NIST's CSRC Sample #3",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a57",
|
||||
"expectedOutput": "c06d377ecd101969",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES (2) NIST's CSRC Sample #4",
|
||||
"input": "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e51",
|
||||
"expectedOutput": "9cd33580f9b64dfb",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "0123456789abcdef23456789abcdef010123456789abcdef"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-AES: invalid key length",
|
||||
"input": "",
|
||||
"expectedOutput": "The key for AES must be either 16, 24, or 32 bytes (currently 20 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "AES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CMAC-TDES: invalid key length",
|
||||
"input": "",
|
||||
"expectedOutput": "The key for Triple DES must be 16 or 24 bytes (currently 20 bytes)",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "CMAC",
|
||||
"args": [{"option": "Hex", "string": "00112233445566778899aabbccddeeff01234567"}, "Triple DES"]
|
||||
},
|
||||
]
|
||||
},
|
||||
]);
|
151
tests/operations/tests/ChaCha.mjs
Normal file
151
tests/operations/tests/ChaCha.mjs
Normal file
|
@ -0,0 +1,151 @@
|
|||
/**
|
||||
* ChaCha tests.
|
||||
*
|
||||
* @author joostrijneveld [joost@joostrijneveld.nl]
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "ChaCha: no key",
|
||||
input: "",
|
||||
expectedOutput: `Invalid key length: 0 bytes.
|
||||
|
||||
ChaCha uses a key of 16 or 32 bytes (128 or 256 bits).`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"option": "Hex", "string": ""},
|
||||
{"option": "Hex", "string": ""},
|
||||
0, "20", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: no nonce",
|
||||
input: "",
|
||||
expectedOutput: `Invalid nonce length: 0 bytes.
|
||||
|
||||
ChaCha uses a nonce of 8 or 12 bytes (64 or 96 bits).`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": ""},
|
||||
0, "20", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: RFC8439",
|
||||
input: "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"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"},
|
||||
{"option": "Hex", "string": "00:00:00:00:00:00:00:4a:00:00:00:00"},
|
||||
1, "20", "Raw", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.1",
|
||||
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",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
|
||||
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
||||
0, "8", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.2",
|
||||
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",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
|
||||
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
||||
0, "12", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.3",
|
||||
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",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff"},
|
||||
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
||||
0, "20", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.4",
|
||||
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",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"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"},
|
||||
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
||||
0, "8", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.5",
|
||||
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",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"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"},
|
||||
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
||||
0, "12", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "ChaCha: draft-strombergson-chacha-test-vectors-01 TC7.6",
|
||||
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",
|
||||
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",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "ChaCha",
|
||||
"args": [
|
||||
{"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"},
|
||||
{"option": "Hex", "string": "0f 1e 2d 3c 4b 5a 69 78"},
|
||||
0, "20", "Hex", "Hex",
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
|
@ -185,11 +185,11 @@ TestRegister.addTests([
|
|||
{
|
||||
name: "JPath Expression: Empty expression",
|
||||
input: JSON.stringify(JSON_TEST_DATA),
|
||||
expectedOutput: "Invalid JPath expression: we need a path",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["", "\n"]
|
||||
"args": ["", "\n", true]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -205,7 +205,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$.store.book[*].author", "\n"]
|
||||
"args": ["$.store.book[*].author", "\n", true]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -223,7 +223,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$..title", "\n"]
|
||||
"args": ["$..title", "\n", true]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -238,7 +238,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$.store.*", "\n"]
|
||||
"args": ["$.store.*", "\n", true]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -249,7 +249,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$..book[-1:]", "\n"]
|
||||
"args": ["$..book[-1:]", "\n", true]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -263,7 +263,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$..book[:2]", "\n"]
|
||||
"args": ["$..book[:2]", "\n", true]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -277,7 +277,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$..book[?(@.isbn)]", "\n"]
|
||||
"args": ["$..book[?(@.isbn)]", "\n", false]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -292,7 +292,7 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$..book[?(@.price<30 && @.category==\"fiction\")]", "\n"]
|
||||
"args": ["$..book[?(@.price<30 && @.category==\"fiction\")]", "\n", false]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
@ -306,10 +306,25 @@ TestRegister.addTests([
|
|||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": ["$..book[?(@.price<10)]", "\n"]
|
||||
"args": ["$..book[?(@.price<10)]", "\n", false]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JPath Expression: Script-based expression",
|
||||
input: "[{}]",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "JPath expression",
|
||||
"args": [
|
||||
"$..[?(({__proto__:[].constructor}).constructor(\"self.postMessage({action:'bakeComplete',data:{bakeId:1,dish:{type:1,value:''},duration:1,error:false,id:undefined,inputNum:2,progress:1,result:'<iframe/onload=debugger>',type: 'html'}});\")();)]",
|
||||
"\n",
|
||||
true
|
||||
]
|
||||
}
|
||||
],
|
||||
expectedOutput: "Invalid JPath expression: Eval [?(expr)] prevented in JSONPath expression."
|
||||
},
|
||||
{
|
||||
name: "CSS selector",
|
||||
input: '<div id="test">\n<p class="a">hello</p>\n<p>world</p>\n<p class="a">again</p>\n</div>',
|
||||
|
|
|
@ -23,4 +23,86 @@ TestRegister.addTests([
|
|||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "LZMA compress & decompress",
|
||||
input: "The cat sat on the mat.",
|
||||
// Generated using command `echo -n "The cat sat on the mat." | lzma -z -6 | xxd -p`
|
||||
expectedOutput: "The cat sat on the mat.",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "LZMA Compress",
|
||||
"args": ["6"]
|
||||
},
|
||||
{
|
||||
"op": "LZMA Decompress",
|
||||
"args": []
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "LZMA decompress: binary",
|
||||
// Generated using command `echo "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10" | xxd -r -p | lzma -z -6 | xxd -p`
|
||||
input: "5d00008000ffffffffffffffff00000052500a84f99bb28021a969d627e03e8a922effffbd160000",
|
||||
expectedOutput: "00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Space"]
|
||||
},
|
||||
{
|
||||
"op": "LZMA Decompress",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"op": "To Hex",
|
||||
"args": ["Space", 0]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "LZMA decompress: string",
|
||||
// Generated using command `echo -n "The cat sat on the mat." | lzma -z -6 | xxd -p`
|
||||
input: "5d00008000ffffffffffffffff002a1a08a202b1a4b814b912c94c4152e1641907d3fd8cd903ffff4fec0000",
|
||||
expectedOutput: "The cat sat on the mat.",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Space"]
|
||||
},
|
||||
{
|
||||
"op": "LZMA Decompress",
|
||||
"args": []
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "LZ4 Compress",
|
||||
input: "The cat sat on the mat.",
|
||||
expectedOutput: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "LZ4 Compress",
|
||||
"args": []
|
||||
},
|
||||
{
|
||||
"op": "To Hex",
|
||||
"args": ["None", 0]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "LZ4 Decompress",
|
||||
input: "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000",
|
||||
expectedOutput: "The cat sat on the mat.",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["None"]
|
||||
},
|
||||
{
|
||||
"op": "LZ4 Decompress",
|
||||
"args": []
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
108
tests/operations/tests/FletcherChecksum.mjs
Normal file
108
tests/operations/tests/FletcherChecksum.mjs
Normal file
|
@ -0,0 +1,108 @@
|
|||
/**
|
||||
* @author mikecat
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Fletcher-16 Checksum: abcde",
|
||||
input: "abcde",
|
||||
expectedOutput: "c8f0",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-16 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-16 Checksum: abcdef",
|
||||
input: "abcdef",
|
||||
expectedOutput: "2057",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-16 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-16 Checksum: abcdefgh",
|
||||
input: "abcdefgh",
|
||||
expectedOutput: "0627",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-16 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-32 Checksum: abcde",
|
||||
input: "abcde",
|
||||
expectedOutput: "f04fc729",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-32 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-32 Checksum: abcdef",
|
||||
input: "abcdef",
|
||||
expectedOutput: "56502d2a",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-32 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-32 Checksum: abcdefgh",
|
||||
input: "abcdefgh",
|
||||
expectedOutput: "ebe19591",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-32 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-64 Checksum: abcde",
|
||||
input: "abcde",
|
||||
expectedOutput: "c8c6c527646362c6",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-64 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-64 Checksum: abcdef",
|
||||
input: "abcdef",
|
||||
expectedOutput: "c8c72b276463c8c6",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-64 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fletcher-64 Checksum: abcdefgh",
|
||||
input: "abcdefgh",
|
||||
expectedOutput: "312e2b28cccac8c6",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Fletcher-64 Checksum",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
115
tests/operations/tests/GenerateAllHashes.mjs
Normal file
115
tests/operations/tests/GenerateAllHashes.mjs
Normal file
|
@ -0,0 +1,115 @@
|
|||
/**
|
||||
* GenerateAllHashes tests.
|
||||
*
|
||||
* @author john19696 [john19696@protonmail.com]
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Full generate all hashes",
|
||||
input: "test",
|
||||
expectedOutput: `MD2: dd34716876364a02d0195e2fb9ae2d1b
|
||||
MD4: db346d691d7acc4dc2625db19f9e3f52
|
||||
MD5: 098f6bcd4621d373cade4e832627b4f6
|
||||
MD6: 93c8a7d0ff132f325138a82b2baa98c12a7c9ac982feb6c5b310a1ca713615bd
|
||||
SHA0: f8d3b312442a67706057aeb45b983221afb4f035
|
||||
SHA1: a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
|
||||
SHA2 224: 90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809
|
||||
SHA2 256: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
||||
SHA2 384: 768412320f7b0aa5812fce428dc4706b3cae50e02a64caa16a782249bfe8efc4b7ef1ccb126255d196047dfedf17a0a9
|
||||
SHA2 512: ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff
|
||||
SHA3 224: 3797bf0afbbfca4a7bbba7602a2b552746876517a7f9b7ce2db0ae7b
|
||||
SHA3 256: 36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
||||
SHA3 384: e516dabb23b6e30026863543282780a3ae0dccf05551cf0295178d7ff0f1b41eecb9db3ff219007c4e097260d58621bd
|
||||
SHA3 512: 9ece086e9bac491fac5c1d1046ca11d737b92a2b2ebd93f005d7b710110c0a678288166e7fbe796883a4f2e9b3ca9f484f521d0ce464345cc1aec96779149c14
|
||||
Keccak 224: 3be30a9ff64f34a5861116c5198987ad780165f8366e67aff4760b5e
|
||||
Keccak 256: 9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658
|
||||
Keccak 384: 53d0ba137307d4c2f9b6674c83edbd58b70c0f4340133ed0adc6fba1d2478a6a03b7788229e775d2de8ae8c0759d0527
|
||||
Keccak 512: 1e2e9fc2002b002d75198b7503210c05a1baac4560916a3c6d93bcce3a50d7f00fd395bf1647b9abb8d1afcc9c76c289b0c9383ba386a956da4b38934417789e
|
||||
Shake 128: d3b0aa9cd8b7255622cebc631e867d4093d6f6010191a53973c45fec9b07c774
|
||||
Shake 256: b54ff7255705a71ee2925e4a3e30e41aed489a579d5595e0df13e32e1e4dd202a7c7f68b31d6418d9845eb4d757adda6ab189e1bb340db818e5b3bc725d992fa
|
||||
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
|
||||
RIPEMD-160: 5e52fee47e6b070565f74372468cdc699de89107
|
||||
RIPEMD-256: fe0289110d07daeee9d9500e14c57787d9083f6ba10e6bcb256f86bb4fe7b981
|
||||
RIPEMD-320: 3b0a2e841e589cf583634a5dd265d2b5d497c4cc44b241e34e0f62d03e98c1b9dc72970b9bc20eb5
|
||||
HAS-160: cb15e491eec6e769771d1f811315139c93071084
|
||||
Whirlpool-0: d50ff71342b521974bae166539871922669afcfc7181250ebbae015c317ebb797173a69e7a05afd11099a9f0918159cd5bc88434d3ca44513d7263caea9244fe
|
||||
Whirlpool-T: e6b4aa087751b4428171777f1893ba585404c7e0171787720eba0d8bccd710dc2c42f874c572bfae4cedabf50f2c80bf923805d4e31c504b86ca3bc59265e7dd
|
||||
Whirlpool: b913d5bbb8e461c2c5961cbe0edcdadfd29f068225ceb37da6defcf89849368f8c6c2eb6a4c4ac75775d032a0ecfdfe8550573062b653fe92fc7b8fb3b7be8d6
|
||||
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
|
||||
BLAKE2b-160: a34fc3b6d2cce8beb3216c2bbb5e55739e8121ed
|
||||
BLAKE2b-256: 928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202
|
||||
BLAKE2b-384: 8a84b8666c8fcfb69f2ec41f578d7c85fbdb504ea6510fb05b50fcbf7ed8153c77943bc2da73abb136834e1a0d4f22cb
|
||||
BLAKE2b-512: a71079d42853dea26e453004338670a53814b78137ffbed07603a41d76a483aa9bc33b582f77d30a65e6f29a896c0411f38312e1d66e0bf16386c86a89bea572
|
||||
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
|
||||
BLAKE2s-160: d6197dabec2bd6f4ff303b8e519e8f15d42a453d
|
||||
BLAKE2s-256: f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
|
||||
Streebog-256: 12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
|
||||
Streebog-512: 7200bf5dea560f0d7960d07fdc8874ad9f3b86ece2e45f5502ae2e176f2c928e0e581152281f5aee818318bed7cbe6aa69999589234723ceb33175598365b5c8
|
||||
GOST: ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
|
||||
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
|
||||
NT Hash: 0CB6948805F797BF2A82807973B89537
|
||||
SSDEEP: 3:Hn:Hn
|
||||
CTPH: A:E:E
|
||||
|
||||
Checksums:
|
||||
Fletcher-8: 3d
|
||||
Fletcher-16: 5dc1
|
||||
Fletcher-32: 3f5cd9e7
|
||||
Fletcher-64: 7473657474736574
|
||||
Adler-32: 045d01c1
|
||||
CRC-8: b9
|
||||
CRC-16: f82e
|
||||
CRC-32: d87f7e0c
|
||||
`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Generate all hashes",
|
||||
"args": ["All", true]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Hashes with length 32",
|
||||
input: "test",
|
||||
expectedOutput: `MD2: dd34716876364a02d0195e2fb9ae2d1b
|
||||
MD4: db346d691d7acc4dc2625db19f9e3f52
|
||||
MD5: 098f6bcd4621d373cade4e832627b4f6
|
||||
RIPEMD-128: f1abb5083c9ff8a9dbbca9cd2b11fead
|
||||
BLAKE2b-128: 44a8995dd50b6657a037a7839304535b
|
||||
BLAKE2s-128: e9ddd9926b9dcb382e09be39ba403d2c
|
||||
LM Hash: 01FC5A6BE7BC6929AAD3B435B51404EE
|
||||
NT Hash: 0CB6948805F797BF2A82807973B89537
|
||||
`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Generate all hashes",
|
||||
"args": ["128", true]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Hashes without names",
|
||||
input: "test",
|
||||
expectedOutput: `93c8a7d0ff132f325138a82b2baa98c12a7c9ac982feb6c5b310a1ca713615bd
|
||||
9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
||||
36f028580bb02cc8272a9a020f4200e346e276ae664e45ee80745574e2f5ab80
|
||||
9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658
|
||||
d3b0aa9cd8b7255622cebc631e867d4093d6f6010191a53973c45fec9b07c774
|
||||
fe0289110d07daeee9d9500e14c57787d9083f6ba10e6bcb256f86bb4fe7b981
|
||||
928b20366943e2afd11ebc0eae2e53a93bf177a4fcf35bcc64d503704e65e202
|
||||
f308fc02ce9172ad02a7d75800ecfc027109bc67987ea32aba9b8dcc7b10150e
|
||||
12a50838191b5504f1e5f2fd078714cf6b592b9d29af99d0b10d8d02881c3857
|
||||
ee67303696d205ddd2b2363e8e01b4b7199a80957d94d7678eaad3fc834c5a27
|
||||
`,
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Generate all hashes",
|
||||
"args": ["256", false]
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
|
@ -46,6 +46,17 @@ TestRegister.addTests([
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: boolean and null as values",
|
||||
input: JSON.stringify({a: false, b: null, c: 3}),
|
||||
expectedOutput: "a,b,c\r\nfalse,null,3\r\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "JSON to CSV",
|
||||
args: [",", "\\r\\n"]
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "JSON to CSV: JSON as an array",
|
||||
input: JSON.stringify([{a: 1, b: "2", c: 3}]),
|
||||
|
|
34
tests/operations/tests/NTLM.mjs
Normal file
34
tests/operations/tests/NTLM.mjs
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* NTLM test.
|
||||
*
|
||||
* @author brun0ne [brunonblok@gmail.com]
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "NT Hash",
|
||||
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
|
||||
expectedOutput: "C5FA1C40E55734A8E528DBFE21766D23",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NT Hash",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "LM Hash",
|
||||
input: "QWERTYUIOPASDFGHJKLZXCVBNM1234567890!@#$%^&*()_+.,?/",
|
||||
expectedOutput: "6D9DF16655336CA75A3C13DD18BA8156",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "LM Hash",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
]);
|
|
@ -49,6 +49,18 @@ Point: 0x046c59592006272250a15070142a6be36d1e45464313f930d985a6e6f0eba3cd39d0367
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "SSH Host Key: Ed25519",
|
||||
input: "AAAAC3NzaC1lZDI1NTE5AAAAIBOF6r99IkvqGu1kwZrHHIqjpTB5w79bpv67B/Aw3+WJ",
|
||||
expectedOutput: `Key type: ssh-ed25519
|
||||
x: 0x1385eabf7d224bea1aed64c19ac71c8aa3a53079c3bf5ba6febb07f030dfe589`,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Parse SSH Host Key",
|
||||
args: ["Base64"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "SSH Host Key: Extract key",
|
||||
input: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiJZ/9W9Ix/Dk9b+K4E+RGCug1AtkGXaJ9vNIY0YHFHLpWsB8DAuh/cGEI9TLbL1gzR2wG+RJNQ2EAQVWe6ypkK63Jm4zw4re+vhEiszpnP889J0h5N9yzyTndesrl4d3cQtv861FcKDPxUJbRALdtl6gwOB7BCL8gsXJLLVLO4EesrbPXD454qpVt7CgJXEXByOFjcIm3XwkdOnXMPHHnMSD7EIN1SvQMD6PfIDrbDd6KQt5QXW/Rc/BsfX5cbUIV1QW5A/GbepXHHKmWRtLC2J/mH3hW2Zq/hITPEaJdG1CtIilQmJaZGXpfGIwFeb0Av9pSL926arZZ6vDi9ctF test@test",
|
||||
|
|
177
tests/operations/tests/Rabbit.mjs
Normal file
177
tests/operations/tests/Rabbit.mjs
Normal file
|
@ -0,0 +1,177 @@
|
|||
/**
|
||||
* @author mikecat
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Rabbit: RFC Test vector, without IV 1",
|
||||
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
expectedOutput: "b15754f036a5d6ecf56b45261c4af70288e8d815c59c0c397b696c4789c68aa7f416a1c3700cd451da68d1881673d696",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: RFC Test vector, without IV 2",
|
||||
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
expectedOutput: "3d2df3c83ef627a1e97fc38487e2519cf576cd61f4405b8896bf53aa8554fc19e5547473fbdb43508ae53b20204d4c5e",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "912813292e3d36fe3bfc62f1dc51c3ac"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: RFC Test vector, without IV 3",
|
||||
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
expectedOutput: "0cb10dcda041cdac32eb5cfd02d0609b95fc9fca0f17015a7b7092114cff3ead9649e5de8bfc7f3f924147ad3a947428",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "8395741587e0c733e9e9ab01c09b0043"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: RFC Test vector, with IV 1",
|
||||
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
expectedOutput: "c6a7275ef85495d87ccd5d376705b7ed5f29a6ac04f5efd47b8f293270dc4a8d2ade822b29de6c1ee52bdb8a47bf8f66",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": "0000000000000000"},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: RFC Test vector, with IV 2",
|
||||
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
expectedOutput: "1fcd4eb9580012e2e0dccc9222017d6da75f4e10d12125017b2499ffed936f2eebc112c393e738392356bdd012029ba7",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": "c373f575c1267e59"},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: RFC Test vector, with IV 3",
|
||||
input: "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
expectedOutput: "445ad8c805858dbf70b6af23a151104d96c8f27947f42c5baeae67c6acc35b039fcbfc895fa71c17313df034f01551cb",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": "a6eb561ad2f41727"},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: generated stream should be XORed with the input",
|
||||
input: "cedda96c054e3ddd93da7ed05e2a4b7bdb0c00fe214f03502e2708b2c2bfc77aa2311b0b9af8aa78d119f92b26db0a6b",
|
||||
expectedOutput: "7f8afd9c33ebeb3166b13bf64260bc7953e4d8ebe4d30f69554e64f54b794ddd5627bac8eaf47e290b7128a330a8dcfd",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: least significant bits should be used for the last block",
|
||||
input: "0000000000000000",
|
||||
expectedOutput: "f56b45261c4af702",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: invalid key length",
|
||||
input: "",
|
||||
expectedOutput: "Invalid key length: 8 bytes (expected: 16)",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "0000000000000000"},
|
||||
{"option": "Hex", "string": ""},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Rabbit: invalid IV length",
|
||||
input: "",
|
||||
expectedOutput: "Invalid IV length: 4 bytes (expected: 0 or 8)",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "00000000000000000000000000000000"},
|
||||
{"option": "Hex", "string": "00000000"},
|
||||
"Big", "Hex", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
// this testcase is taken from the first example on Crypto++ Wiki
|
||||
// https://www.cryptopp.com/wiki/Rabbit
|
||||
name: "Rabbit: little-endian mode (Crypto++ compatible)",
|
||||
input: "Rabbit stream cipher test",
|
||||
expectedOutput: "1ae2d4edcf9b6063b00fd6fda0b223aded157e77031cf0440b",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Rabbit",
|
||||
"args": [
|
||||
{"option": "Hex", "string": "23c2731e8b5469fd8dabb5bc592a0f3a"},
|
||||
{"option": "Hex", "string": "712906405ef03201"},
|
||||
"Little", "Raw", "Hex"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
]);
|
54
tests/operations/tests/Shuffle.mjs
Normal file
54
tests/operations/tests/Shuffle.mjs
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @author mikecat
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
"name": "Shuffle empty",
|
||||
"input": "",
|
||||
"expectedOutput": "",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "Shuffle",
|
||||
"args": ["Comma"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Shuffle bytes",
|
||||
"input": "12345678",
|
||||
"expectedOutput": "31 32 33 34 35 36 37 38",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "Shuffle",
|
||||
"args": ["Nothing (separate chars)"]
|
||||
},
|
||||
{
|
||||
"op": "To Hex",
|
||||
"args": ["Space", 0]
|
||||
},
|
||||
{
|
||||
"op": "Sort",
|
||||
"args": ["Space", false, "Alphabetical (case sensitive)"]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Shuffle lines",
|
||||
"input": "1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf\n",
|
||||
"expectedOutput": "\n1\n2\n3\n4\n5\n6\n7\n8\n9\na\nb\nc\nd\ne\nf",
|
||||
"recipeConfig": [
|
||||
{
|
||||
"op": "Shuffle",
|
||||
"args": ["Line feed"]
|
||||
},
|
||||
{
|
||||
"op": "Sort",
|
||||
"args": ["Line feed", false, "Alphabetical (case sensitive)"]
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
55
tests/operations/tests/UnescapeString.mjs
Normal file
55
tests/operations/tests/UnescapeString.mjs
Normal file
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* UnescapeString tests.
|
||||
*
|
||||
* @copyright Crown Copyright 2022
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "UnescapeString: escape sequences",
|
||||
input: "\\a\\b\\f\\n\\r\\t\\v\\'\\\"",
|
||||
expectedOutput: String.fromCharCode(0x07, 0x08, 0x0c, 0x0a, 0x0d, 0x09,
|
||||
0x0b, 0x27, 0x22),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Unescape string",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "UnescapeString: octals",
|
||||
input: "\\0\\01\\012\\1\\12",
|
||||
expectedOutput: String.fromCharCode(0, 1, 10, 1, 10),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Unescape string",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "UnescapeString: hexadecimals",
|
||||
input: "\\x00\\xAA\\xaa",
|
||||
expectedOutput: String.fromCharCode(0, 170, 170),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Unescape string",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "UnescapeString: unicode",
|
||||
input: "\\u0061\\u{0062}",
|
||||
expectedOutput: "ab",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Unescape string",
|
||||
args: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
|
@ -8,6 +8,22 @@
|
|||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
const CONSOLE_COMPILE_WARNING_RULE = `import "console"
|
||||
rule a
|
||||
{
|
||||
strings:
|
||||
$s=" "
|
||||
condition:
|
||||
$s and console.log("log rule a")
|
||||
}
|
||||
rule b
|
||||
{
|
||||
strings:
|
||||
$s=" "
|
||||
condition:
|
||||
$s and console.hex("log rule b: int8(0)=", int8(0))
|
||||
}`;
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "YARA Match: simple foobar",
|
||||
|
@ -20,5 +36,56 @@ TestRegister.addTests([
|
|||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "YARA Match: hashing rules",
|
||||
input: "Hello World!",
|
||||
expectedOutput: "Input matches rule \"HelloWorldMD5\".\nInput matches rule \"HelloWorldSHA256\".\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "YARA Rules",
|
||||
"args": [
|
||||
`import "hash"
|
||||
rule HelloWorldMD5 {
|
||||
condition:
|
||||
hash.md5(0,filesize) == "ed076287532e86365e841e92bfc50d8c"
|
||||
}
|
||||
|
||||
rule HelloWorldSHA256 {
|
||||
condition:
|
||||
hash.sha256(0,filesize) == "7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069"
|
||||
}`,
|
||||
true, true, true, true, false, false
|
||||
],
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "YARA Match: compile warnings",
|
||||
input: "CyberChef Yara",
|
||||
expectedOutput: "Warning on line 5: string \"$s\" may slow down scanning\n" +
|
||||
"Warning on line 12: string \"$s\" may slow down scanning\n" +
|
||||
"Input matches rule \"a\".\n" +
|
||||
"Input matches rule \"b\".\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "YARA Rules",
|
||||
"args": [CONSOLE_COMPILE_WARNING_RULE, false, false, false, false, true, false],
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "YARA Match: console messages",
|
||||
input: "CyberChef Yara",
|
||||
expectedOutput: "log rule a\n" +
|
||||
"log rule b: int8(0)=0x43\n" +
|
||||
"Input matches rule \"a\".\n" +
|
||||
"Input matches rule \"b\".\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "YARA Rules",
|
||||
"args": [CONSOLE_COMPILE_WARNING_RULE, false, false, false, false, false, true],
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue