feat: Get AES IV from input (QoL) (#2471)

This commit is contained in:
andreas 2026-06-05 12:23:38 +02:00 committed by GitHub
parent 20b46bf1a0
commit da202d54f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 419 additions and 92 deletions

View File

@ -39,41 +39,46 @@ class AESDecrypt extends Operation {
"value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
},
{
"name": "IV Length",
"type": "number",
"value": 16
},
{
"name": "Mode",
"type": "argSelector",
"value": [
{
name: "CBC",
off: [5, 6]
off: [6, 7]
},
{
name: "CFB",
off: [5, 6]
off: [6, 7]
},
{
name: "OFB",
off: [5, 6]
off: [6, 7]
},
{
name: "CTR",
off: [5, 6]
off: [6, 7]
},
{
name: "GCM",
on: [5, 6]
on: [6, 7]
},
{
name: "ECB",
off: [5, 6]
off: [6, 7]
},
{
name: "CBC/NoPadding",
off: [5, 6]
off: [6, 7]
},
{
name: "ECB/NoPadding",
off: [5, 6]
off: [6, 7]
}
]
},
@ -98,6 +103,26 @@ class AESDecrypt extends Operation {
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
},
{
"name": "IV from input",
"type": "argSelector",
"value": [
{
name: "Off",
on: [1],
off: [2]
},
{
name: "From start",
on: [2],
off: [1]
}, {
name: "From end",
on: [2],
off: [1]
}
]
}
];
}
@ -110,14 +135,18 @@ class AESDecrypt extends Operation {
* @throws {OperationError} if cannot decrypt input or invalid key length
*/
run(input, args) {
let iv;
const key = Utils.convertToByteString(args[0].string, args[0].option),
iv = Utils.convertToByteString(args[1].string, args[1].option),
mode = args[2].split("/")[0],
noPadding = args[2].endsWith("NoPadding"),
inputType = args[3],
outputType = args[4],
gcmTag = Utils.convertToByteString(args[5].string, args[5].option),
aad = Utils.convertToByteString(args[6].string, args[6].option);
ivLength = args[2],
mode = args[3].split("/")[0],
noPadding = args[3].endsWith("NoPadding"),
inputType = args[4],
outputType = args[5],
gcmTag = Utils.convertToByteString(args[6].string, args[6].option),
aad = Utils.convertToByteString(args[7].string, args[7].option),
ivFromInput = args[8];
if ([16, 24, 32].indexOf(key.length) < 0) {
throw new OperationError(`Invalid key length: ${key.length} bytes
@ -130,11 +159,27 @@ The following algorithms will be used based on the size of the key:
input = Utils.convertToByteString(input, inputType);
if (ivFromInput !== "Off") {
if (input.length <= ivLength) {
throw new OperationError(`Input is too short to contain an IV of ${ivLength} bytes.`);
}
if (ivFromInput === "From start") {
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);
/* Allow for a "no padding" mode */
if (noPadding) {
decipher.mode.unpad = function(output, options) {
decipher.mode.unpad = function (output, options) {
return true;
};
}

View File

@ -8,6 +8,7 @@ import Operation from "../Operation.mjs";
import Utils from "../Utils.mjs";
import forge from "node-forge";
import OperationError from "../errors/OperationError.mjs";
import { toHexFast } from "../lib/Hex.mjs";
/**
* AES Encrypt operation
@ -92,6 +93,11 @@ class AESEncrypt extends Operation {
"type": "toggleString",
"value": "",
"toggleValues": ["Hex", "UTF8", "Latin1", "Base64"]
},
{
"name": "Include IV in output",
"type": "option",
"value": ["Off", "Prepend", "Append"]
}
];
}
@ -107,10 +113,11 @@ class AESEncrypt extends Operation {
const key = Utils.convertToByteString(args[0].string, args[0].option),
iv = Utils.convertToByteString(args[1].string, args[1].option),
mode = args[2].split("/")[0],
noPadding = args[2].endsWith("NoPadding"),
noPadding = args[2].endsWith("NoPadding"),
inputType = args[3],
outputType = args[4],
aad = Utils.convertToByteString(args[5].string, args[5].option);
aad = Utils.convertToByteString(args[5].string, args[5].option),
includeIV = args[6];
if ([16, 24, 32].indexOf(key.length) < 0) {
throw new OperationError(`Invalid key length: ${key.length} bytes
@ -133,26 +140,34 @@ The following algorithms will be used based on the size of the key:
additionalData: mode === "GCM" ? aad : undefined
});
if (noPadding) {
cipher.mode.pad = function(output, options) {
cipher.mode.pad = function (output, options) {
return true;
};
}
cipher.update(forge.util.createBuffer(input));
cipher.finish();
let output = cipher.output.getBytes();
if (includeIV === "Prepend") {
output = iv + output;
} else if (includeIV === "Append") {
output = output + iv;
}
if (outputType === "Hex") {
output = toHexFast(Utils.strToByteArray(output));
if (mode === "GCM") {
return cipher.output.toHex() + "\n\n" +
return output + "\n\n" +
"Tag: " + cipher.mode.tag.toHex();
}
return cipher.output.toHex();
} else {
if (mode === "GCM") {
return cipher.output.getBytes() + "\n\n" +
"Tag: " + cipher.mode.tag.getBytes();
}
return cipher.output.getBytes();
} else if (mode === "GCM") {
return output + "\n\n" +
"Tag: " + cipher.mode.tag.getBytes();
}
return output;
}
}

View File

@ -30,8 +30,8 @@ module.exports = {
testOp(browser, "A1Z26 Cipher Decode", "20 5 19 20 15 21 20 16 21 20", "testoutput");
testOp(browser, "A1Z26 Cipher Encode", "test input", "20 5 19 20 9 14 16 21 20");
testOp(browser, "ADD", "test input", "Ê»ÉÊv¿ÄÆËÊ", [{ "option": "Hex", "string": "56" }]);
testOp(browser, "AES Decrypt", "b443f7f7c16ac5396a34273f6f639caa", "test output", [{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" }, { "option": "Hex", "string": "00000000000000000000000000000000" }, "CBC", "Hex", "Raw", { "option": "Hex", "string": "" }]);
testOp(browser, "AES Encrypt", "test input", "e42eb8fbfb7a98fff061cd2c1a794d92", [{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, "CBC", "Raw", "Hex"]);
testOp(browser, "AES Decrypt", "b443f7f7c16ac5396a34273f6f639caa", "test output", [{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" }, { "option": "Hex", "string": "00000000000000000000000000000000" }, 16, "CBC", "Hex", "Raw", { "option": "Hex", "string": "" }, { "option": "Hex", "string": "" }, "Off"]);
testOp(browser, "AES Encrypt", "test input", "e42eb8fbfb7a98fff061cd2c1a794d92", [{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, "CBC", "Raw", "Hex", "Off"]);
testOp(browser, "AND", "test input", "4$04 $044", [{ "option": "Hex", "string": "34" }]);
testOp(browser, "Add line numbers", "test input", "1 test input");
testOp(browser, ["From Hex", "Add Text To Image", "SHA2"], Images.PNG_HEX, "50cdf8ea483c55564a091650c2bccb4586f919b721e5fe9d6a61660505b4346d6ebdb2ef0cf075a7728cd84cb26ea3e477b5bd86a94a49a27d79423994afb60a", [[], ["Chef", "Center", "Middle", 0, 0, 16, "Roboto"], []]);

View File

@ -79,7 +79,46 @@ TestRegister.addApiTests([
string: "some iv some iv1",
option: "utf8",
},
ivLength: 16,
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,
mode: "OFB",
inputType: "Hex",
outputType: "Raw",
gcmTag: {
option: "Hex",
string: ""
},
aad: {
option: "Hex",
string: ""
},
ivFromInput: "From end"
});
assert.equal(result.toString(), "a slightly longer sampleinput?");
}),

View File

@ -74,7 +74,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"CBC", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -90,7 +91,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
"CBC", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -106,7 +108,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
"CTR", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -122,7 +125,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CBC", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -138,7 +142,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CFB", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -154,7 +159,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"OFB", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -170,7 +176,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
"CTR", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -186,7 +193,8 @@ The following algorithms will be used based on the size of the key:
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"ECB", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -204,7 +212,8 @@ Tag: 16a3e732a605cc9ca29108f742ca0743`,
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
"GCM", "Raw", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -222,7 +231,8 @@ Tag: 3b5378917f67b0aade9891fc6c291646`,
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
"GCM", "Raw", "Hex",
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -238,7 +248,8 @@ Tag: 3b5378917f67b0aade9891fc6c291646`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -254,7 +265,8 @@ Tag: 3b5378917f67b0aade9891fc6c291646`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -270,7 +282,8 @@ Tag: 3b5378917f67b0aade9891fc6c291646`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -286,7 +299,8 @@ Tag: 3b5378917f67b0aade9891fc6c291646`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -304,7 +318,8 @@ Tag: 70fad2ca19412c20f40fd06918736e56`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -322,7 +337,8 @@ Tag: 61cc4b70809452b0b3e38f913fa0a109`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -338,7 +354,8 @@ Tag: 61cc4b70809452b0b3e38f913fa0a109`,
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -354,7 +371,8 @@ Tag: 61cc4b70809452b0b3e38f913fa0a109`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -370,7 +388,8 @@ Tag: 61cc4b70809452b0b3e38f913fa0a109`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -386,7 +405,8 @@ Tag: 61cc4b70809452b0b3e38f913fa0a109`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -402,7 +422,8 @@ Tag: 61cc4b70809452b0b3e38f913fa0a109`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -420,7 +441,8 @@ Tag: 86db597d5302595223cadbd990f1309b`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -438,7 +460,8 @@ Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -454,7 +477,8 @@ Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -470,7 +494,8 @@ Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -486,7 +511,8 @@ Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -502,7 +528,8 @@ Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -518,7 +545,8 @@ Tag: aeedf3e6ca4201577c0cf3e9ce58159d`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -536,7 +564,8 @@ Tag: 821b1e5f32dad052e502775a523d957a`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -554,7 +583,8 @@ Tag: a8f04c4d93bbef82bef61a103371aef9`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -570,7 +600,46 @@ Tag: a8f04c4d93bbef82bef61a103371aef9`,
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
},
{
name: "AES Encrypt: AES-256-GCM, Binary, AAD, prepend IV to output",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `1748e7179bd56570d51fa4ba287cc3e51287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f
Tag: a8f04c4d93bbef82bef61a103371aef9`,
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"},
"Prepend"
]
}
],
},
{
name: "AES Encrypt: AES-256-GCM, Binary, AAD, append IV to output",
input: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
expectedOutput: `1287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f1748e7179bd56570d51fa4ba287cc3e5
Tag: a8f04c4d93bbef82bef61a103371aef9`,
recipeConfig: [
{
"op": "AES Encrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
"GCM", "Hex", "Hex",
{"option": "UTF8", "string": "additional data"},
"Append"
]
}
],
@ -776,9 +845,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
16,
"CBC", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -793,9 +864,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
16,
"CBC", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -810,9 +883,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00000000000000000000000000000000"},
16,
"CTR", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -827,9 +902,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"CBC", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -844,9 +921,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"CFB", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -861,9 +940,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"OFB", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -878,9 +959,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
16,
"CTR", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -895,9 +978,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
16,
"ECB", "Hex", "Raw",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -912,9 +997,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": ""},
16,
"GCM", "Hex", "Raw",
{"option": "Hex", "string": "16a3e732a605cc9ca29108f742ca0743"},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -929,9 +1016,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "00112233445566778899aabbccddeeff"},
{"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"},
16,
"GCM", "Hex", "Raw",
{"option": "Hex", "string": "3b5378917f67b0aade9891fc6c291646"},
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -946,9 +1035,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -963,9 +1054,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -980,9 +1073,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -997,9 +1092,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1014,9 +1111,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "70fad2ca19412c20f40fd06918736e56"},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1031,9 +1130,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "61cc4b70809452b0b3e38f913fa0a109"},
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -1048,9 +1149,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1065,9 +1168,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1082,9 +1187,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1099,9 +1206,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1116,9 +1225,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1133,9 +1244,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "86db597d5302595223cadbd990f1309b"},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1150,9 +1263,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "aeedf3e6ca4201577c0cf3e9ce58159d"},
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -1167,9 +1282,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1184,9 +1301,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CBC", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1201,9 +1320,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1218,9 +1339,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"OFB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1235,9 +1358,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"CTR", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1252,9 +1377,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "821b1e5f32dad052e502775a523d957a"},
{"option": "Hex", "string": ""}
{"option": "Hex", "string": ""},
"Off"
]
}
],
@ -1269,9 +1396,11 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"},
{"option": "UTF8", "string": "additional data"}
{"option": "UTF8", "string": "additional data"},
"Off"
]
}
],
@ -1286,9 +1415,106 @@ The following algorithms will be used based on the size of the key:
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"},
16,
"ECB", "Hex", "Hex",
{"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,
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"From start"
]
}
],
},
{
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,
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"From start"
]
}
],
},
{
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,
"ECB", "Hex", "Hex",
{"option": "Hex", "string": ""},
{"option": "Hex", "string": ""},
"From end"
]
}
],
},
{
name: "AES Decrypt: AES-256-GCM with IV from input start, Binary, AAD",
input: "1748e7179bd56570d51fa4ba287cc3e51287f188ad4d7ab0d9ff69b3c29cb11f861389532d8cb9337181da2e8cfc74a84927e8c0dd7a28a32fd485afe694259a63c199b199b95edd87c7aa95329feac340f2b78b72956a85f367044d821766b1b7135815571df44900695f1518cf3ae38ecb650f",
expectedOutput: "7a0e643132750e96d805d11e9e48e281fa39a41039286423cc1c045e5442b40bf1c3f2822bded3f9c8ef11cb25da64dda9c7ab87c246bd305385150c98f31465c2a6180fe81d31ea289b916504d5a12e1de26cb10adba84a0cb0c86f94bc14bc554f3018",
recipeConfig: [
{
"op": "AES Decrypt",
"args": [
{"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"},
{"option": "Hex", "string": ""},
16,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "a8f04c4d93bbef82bef61a103371aef9"},
{"option": "UTF8", "string": "additional data"},
"From start"
]
}
],
},
{
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,
"GCM", "Hex", "Hex",
{"option": "Hex", "string": "c311c9144f8ae145ec46e2c69179a4b7"},
{"option": "UTF8", "string": "additional data"},
"From start"
]
}
],

View File

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