feat: Get AES IV from input

This commit is contained in:
Andreas Røed Tvete 2026-05-29 15:46:24 +02:00
parent bdcd5fa8b1
commit 718f5ae14d
4 changed files with 332 additions and 48 deletions

View File

@ -39,41 +39,51 @@ class AESDecrypt extends Operation {
"value": "", "value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"] "toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
}, },
{
"name": "IV Length",
"type": "number",
"value": 16
},
{
"name": "IV Location",
"type": "option",
"value": ["Start of input", "End of input"],
},
{ {
"name": "Mode", "name": "Mode",
"type": "argSelector", "type": "argSelector",
"value": [ "value": [
{ {
name: "CBC", name: "CBC",
off: [5, 6] off: [7, 8]
}, },
{ {
name: "CFB", name: "CFB",
off: [5, 6] off: [7, 8]
}, },
{ {
name: "OFB", name: "OFB",
off: [5, 6] off: [7, 8]
}, },
{ {
name: "CTR", name: "CTR",
off: [5, 6] off: [7, 8]
}, },
{ {
name: "GCM", name: "GCM",
on: [5, 6] on: [7, 8]
}, },
{ {
name: "ECB", name: "ECB",
off: [5, 6] off: [7, 8]
}, },
{ {
name: "CBC/NoPadding", name: "CBC/NoPadding",
off: [5, 6] off: [7, 8]
}, },
{ {
name: "ECB/NoPadding", name: "ECB/NoPadding",
off: [5, 6] off: [7, 8]
} }
] ]
}, },
@ -98,6 +108,22 @@ class AESDecrypt extends Operation {
"type": "toggleString", "type": "toggleString",
"value": "", "value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"] "toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
},
{
"name": "IV from input",
"type": "argSelector",
"value": [
{
name: "Off",
on: [1],
off: [2, 3]
},
{
name: "On",
on: [2, 3],
off: [1]
}
]
} }
]; ];
} }
@ -110,14 +136,19 @@ class AESDecrypt extends Operation {
* @throws {OperationError} if cannot decrypt input or invalid key length * @throws {OperationError} if cannot decrypt input or invalid key length
*/ */
run(input, args) { run(input, args) {
let iv;
const key = Utils.convertToByteString(args[0].string, args[0].option), const key = Utils.convertToByteString(args[0].string, args[0].option),
iv = Utils.convertToByteString(args[1].string, args[1].option), ivLength = args[2],
mode = args[2].split("/")[0], ivFromStart = args[3] === "Start of input",
noPadding = args[2].endsWith("NoPadding"), mode = args[4].split("/")[0],
inputType = args[3], noPadding = args[4].endsWith("NoPadding"),
outputType = args[4], inputType = args[5],
gcmTag = Utils.convertToByteString(args[5].string, args[5].option), outputType = args[6],
aad = Utils.convertToByteString(args[6].string, args[6].option); gcmTag = Utils.convertToByteString(args[7].string, args[7].option),
aad = Utils.convertToByteString(args[8].string, args[8].option),
ivFromInput = args[9] === "On";
if ([16, 24, 32].indexOf(key.length) < 0) { if ([16, 24, 32].indexOf(key.length) < 0) {
throw new OperationError(`Invalid key length: ${key.length} bytes throw new OperationError(`Invalid key length: ${key.length} bytes
@ -130,6 +161,22 @@ The following algorithms will be used based on the size of the key:
input = Utils.convertToByteString(input, inputType); input = Utils.convertToByteString(input, inputType);
if (ivFromInput) {
if (input.length <= ivLength) {
throw new OperationError(`Input is too short to contain an IV of ${ivLength} bytes.`);
}
if (ivFromStart) {
iv = input.substr(0, ivLength);
input = input.substr(ivLength);
} else {
iv = input.substr(input.length - ivLength);
input = input.substr(0, input.length - ivLength);
}
} else {
iv = Utils.convertToByteString(args[1].string, args[1].option);
}
const decipher = forge.cipher.createDecipher("AES-" + mode, key); const decipher = forge.cipher.createDecipher("AES-" + mode, key);
/* Allow for a "no padding" mode */ /* Allow for a "no padding" mode */
@ -147,7 +194,7 @@ The following algorithms will be used based on the size of the key:
decipher.update(forge.util.createBuffer(input)); decipher.update(forge.util.createBuffer(input));
const result = decipher.finish(); const result = decipher.finish();
if (result) { if (result && decipher.output.length() > 0) {
return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes(); return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes();
} else { } else {
throw new OperationError("Unable to decrypt input with these parameters."); throw new OperationError("Unable to decrypt input with these parameters.");

View File

@ -79,7 +79,48 @@ TestRegister.addApiTests([
string: "some iv some iv1", string: "some iv some iv1",
option: "utf8", option: "utf8",
}, },
ivLength: 16,
ivLocation: "Start of input",
mode: "OFB", mode: "OFB",
inputType: "Hex",
outputType: "Raw",
gcmTag: {
option: "Hex",
string: ""
},
aad: {
option: "Hex",
string: ""
},
ivFromInput: "Off"
});
assert.equal(result.toString(), "a slightly longer sampleinput?");
}),
it("AES decrypt: IV from input", () => {
const result = AESDecrypt("4a123af235a507bbc9d5871721d61b98504d569a9a5a7847e2d78315fec7736f6d6520697620736f6d6520697631", {
key: {
string: "some longer key1",
option: "utf8",
},
iv: {
string: "",
option: "Hex",
},
ivLength: 16,
ivLocation: "End of input",
mode: "OFB",
inputType: "Hex",
outputType: "Raw",
gcmTag: {
option: "Hex",
string: ""
},
aad: {
option: "Hex",
string: ""
},
ivFromInput: "On"
}); });
assert.equal(result.toString(), "a slightly longer sampleinput?"); assert.equal(result.toString(), "a slightly longer sampleinput?");
}), }),

View File

@ -776,9 +776,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
16,
"Start of input",
"CBC", "Hex", "Raw", "CBC", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -793,9 +796,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": "00000000000000000000000000000000"},
16,
"Start of input",
"CBC", "Hex", "Raw", "CBC", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -810,9 +816,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"}, {"option": "Hex", "string": "00000000000000000000000000000000"},
16,
"Start of input",
"CTR", "Hex", "Raw", "CTR", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -827,9 +836,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"Start of input",
"CBC", "Hex", "Raw", "CBC", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -844,9 +856,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"Start of input",
"CFB", "Hex", "Raw", "CFB", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -861,9 +876,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"Start of input",
"OFB", "Hex", "Raw", "OFB", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -878,9 +896,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"Start of input",
"CTR", "Hex", "Raw", "CTR", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -895,9 +916,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
16,
"Start of input",
"ECB", "Hex", "Raw", "ECB", "Hex", "Raw",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -912,9 +936,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
16,
"Start of input",
"GCM", "Hex", "Raw", "GCM", "Hex", "Raw",
{"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"}, {"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -929,9 +956,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"}, {"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
16,
"Start of input",
"GCM", "Hex", "Raw", "GCM", "Hex", "Raw",
{"option": "Hex", "string": "3b5378917f67b0aade9891fc6c291646"}, {"option": "Hex", "string": "3b5378917f67b0aade9891fc6c291646"},
{"option": "UTF8", "string": "additional data"} {"option": "UTF8", "string": "additional data"},
"Off"
] ]
} }
], ],
@ -946,9 +976,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CBC", "Hex", "Hex", "CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -963,9 +996,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CFB", "Hex", "Hex", "CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -980,9 +1016,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"OFB", "Hex", "Hex", "OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -997,9 +1036,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CTR", "Hex", "Hex", "CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1014,9 +1056,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"GCM", "Hex", "Hex", "GCM", "Hex", "Hex",
{"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"}, {"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1031,9 +1076,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"GCM", "Hex", "Hex", "GCM", "Hex", "Hex",
{"option": "Hex", "string": "61cc4b70809452b0b3e38f913fa0a109"}, {"option": "Hex", "string": "61cc4b70809452b0b3e38f913fa0a109"},
{"option": "UTF8", "string": "additional data"} {"option": "UTF8", "string": "additional data"},
"Off"
] ]
} }
], ],
@ -1048,9 +1096,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"ECB", "Hex", "Hex", "ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1065,9 +1116,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CBC", "Hex", "Hex", "CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1082,9 +1136,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CFB", "Hex", "Hex", "CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1099,9 +1156,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"OFB", "Hex", "Hex", "OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1116,9 +1176,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CTR", "Hex", "Hex", "CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1133,9 +1196,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"GCM", "Hex", "Hex", "GCM", "Hex", "Hex",
{"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"}, {"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1150,9 +1216,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"GCM", "Hex", "Hex", "GCM", "Hex", "Hex",
{"option": "Hex", "string": "aeedf3e6ca4201577c0cf3e9ce58159d"}, {"option": "Hex", "string": "aeedf3e6ca4201577c0cf3e9ce58159d"},
{"option": "UTF8", "string": "additional data"} {"option": "UTF8", "string": "additional data"},
"Off"
] ]
} }
], ],
@ -1167,9 +1236,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"ECB", "Hex", "Hex", "ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1184,9 +1256,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CBC", "Hex", "Hex", "CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1201,9 +1276,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CFB", "Hex", "Hex", "CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1218,9 +1296,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"OFB", "Hex", "Hex", "OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1235,9 +1316,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"CTR", "Hex", "Hex", "CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1252,9 +1336,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"GCM", "Hex", "Hex", "GCM", "Hex", "Hex",
{"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"}, {"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
] ]
} }
], ],
@ -1269,9 +1356,12 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"GCM", "Hex", "Hex", "GCM", "Hex", "Hex",
{"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"}, {"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"},
{"option": "UTF8", "string": "additional data"} {"option": "UTF8", "string": "additional data"},
"Off"
] ]
} }
], ],
@ -1286,9 +1376,112 @@ The following algorithms will be used based on the size of the key:
"args": [ "args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"Start of input",
"ECB", "Hex", "Hex", "ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}, {"option": "Hex", "string": ""},
{"option": "Hex", "string": ""} {"option": "Hex", "string": ""},
"Off"
]
}
],
},
{
name: "AES Decrypt: IV from input, with too short input",
input: "1748e7179bd56570d51fa4ba287cc3e5",
expectedOutput: "Input is too short to contain an IV of 16 bytes.",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": ""},
16,
"End of input",
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"On"
]
}
],
},
{
name: "AES Decrypt: AES-256-ECB with IV from input start, Binary",
input: "1748e7179bd56570d51fa4ba287cc3e57e8521ba3f356ef692a51841807e141464aadc07bbc0ef2b628b8745bae356d245682a220688afca7be987b60cb120681ed42680ee93a67065619a3beaac11111a6cd88a6afa9e367722cb57df343f8548f2d691b295184da4ed5f3b763aaa8558502cb348ab58e81986337096e90caa",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": ""},
16,
"Start of input",
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"On"
]
}
],
},
{
name: "AES Decrypt: AES-256-ECB with IV from input end, Binary",
input: "7e8521ba3f356ef692a51841807e141464aadc07bbc0ef2b628b8745bae356d245682a220688afca7be987b60cb120681ed42680ee93a67065619a3beaac11111a6cd88a6afa9e367722cb57df343f8548f2d691b295184da4ed5f3b763aaa8558502cb348ab58e81986337096e90caa1748e7179bd56570d51fa4ba287cc3e5",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": ""},
16,
"End of input",
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"On"
]
}
],
},
{
name: "AES Decrypt: AES-256-GCM with IV from input, Binary, AAD",
input: "1748e7179bd56570d51fa4ba287cc3e51287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": ""},
16,
"Start of input",
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"},
{"option": "UTF8", "string": "additional data"},
"On"
]
}
],
},
{
name: "AES Decrypt: AES-256-GCM with 12-byte IV from input start, Binary, AAD",
input: "1748e7179bd56570d51fa4ba623c81f4605da9ac3df29c67c43abe4aad5230dca82a98ab31f042fe871b81a0a1e8b8af41044d46f627828e7d11eca2d04ac27f4e7c7c9a20da87854df9868a2ddbd67d85f7db92f9ff1272cfb7955a2d279dbe715965011fddf6e730e79e7b22f89817",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": ""},
12,
"Start of input",
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "c311c9144f8ae145ec46e2c69179a4b7"},
{"option": "UTF8", "string": "additional data"},
"On"
] ]
} }
], ],

View File

@ -59,6 +59,8 @@ TestRegister.addTests([
"option": "Hex", "option": "Hex",
"string": "$R0" "string": "$R0"
}, },
16,
"Start of input",
"CTR", "Hex", "Raw", "CTR", "Hex", "Raw",
{ {
"option": "Hex", "option": "Hex",
@ -67,7 +69,8 @@ TestRegister.addTests([
{ {
"option": "Hex", "option": "Hex",
"string": "" "string": ""
} },
"Off"
] ]
} }
] ]