From 718f5ae14db353cc95260efb31ce42a8a535f51d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20R=C3=B8ed=20Tvete?= Date: Fri, 29 May 2026 15:46:24 +0200 Subject: [PATCH] feat: Get AES IV from input --- src/core/operations/AESDecrypt.mjs | 79 +++++++-- tests/node/tests/operations.mjs | 41 +++++ tests/operations/tests/Crypt.mjs | 255 ++++++++++++++++++++++++---- tests/operations/tests/Register.mjs | 5 +- 4 files changed, 332 insertions(+), 48 deletions(-) diff --git a/src/core/operations/AESDecrypt.mjs b/src/core/operations/AESDecrypt.mjs index 5e6cec2643..12756b262f 100644 --- a/src/core/operations/AESDecrypt.mjs +++ b/src/core/operations/AESDecrypt.mjs @@ -39,41 +39,51 @@ class AESDecrypt extends Operation { "value": "", "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", "type": "argSelector", "value": [ { name: "CBC", - off: [5, 6] + off: [7, 8] }, { name: "CFB", - off: [5, 6] + off: [7, 8] }, { name: "OFB", - off: [5, 6] + off: [7, 8] }, { name: "CTR", - off: [5, 6] + off: [7, 8] }, { name: "GCM", - on: [5, 6] + on: [7, 8] }, { name: "ECB", - off: [5, 6] + off: [7, 8] }, { name: "CBC/NoPadding", - off: [5, 6] + off: [7, 8] }, { name: "ECB/NoPadding", - off: [5, 6] + off: [7, 8] } ] }, @@ -98,6 +108,22 @@ 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, 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 */ 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], + ivFromStart = args[3] === "Start of input", + mode = args[4].split("/")[0], + noPadding = args[4].endsWith("NoPadding"), + inputType = args[5], + outputType = args[6], + 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) { 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); + 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); /* 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)); const result = decipher.finish(); - if (result) { + if (result && decipher.output.length() > 0) { return outputType === "Hex" ? decipher.output.toHex() : decipher.output.getBytes(); } else { throw new OperationError("Unable to decrypt input with these parameters."); diff --git a/tests/node/tests/operations.mjs b/tests/node/tests/operations.mjs index 3b2bbda6c2..8555e25654 100644 --- a/tests/node/tests/operations.mjs +++ b/tests/node/tests/operations.mjs @@ -79,7 +79,48 @@ TestRegister.addApiTests([ string: "some iv some iv1", option: "utf8", }, + ivLength: 16, + ivLocation: "Start of input", 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?"); }), diff --git a/tests/operations/tests/Crypt.mjs b/tests/operations/tests/Crypt.mjs index 504f64b92e..7a3dedea55 100644 --- a/tests/operations/tests/Crypt.mjs +++ b/tests/operations/tests/Crypt.mjs @@ -776,9 +776,12 @@ The following algorithms will be used based on the size of the key: "args": [ {"option": "Hex", "string": ""}, {"option": "Hex", "string": ""}, + 16, + "Start of input", "CBC", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, + 16, + "Start of input", "CBC", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, + 16, + "Start of input", "CTR", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, + 16, + "Start of input", "CBC", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, + 16, + "Start of input", "CFB", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, + 16, + "Start of input", "OFB", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, + 16, + "Start of input", "CTR", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": ""}, + 16, + "Start of input", "ECB", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": ""}, + 16, + "Start of input", "GCM", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "ffeeddccbbaa99887766554433221100"}, + 16, + "Start of input", "GCM", "Hex", "Raw", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CBC", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CFB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "OFB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CTR", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "GCM", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "GCM", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "51e201d463698ef5f717f71f5b4712af"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "ECB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CBC", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CFB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "OFB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CTR", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "GCM", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "GCM", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "6801ed503c9d96ee5f9d78b07ab1b295dba3c2adf81c7816"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "ECB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CBC", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CFB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "OFB", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "CTR", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "GCM", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "GCM", "Hex", "Hex", {"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": [ {"option": "Hex", "string": "2d767f6e9333d1c77581946e160b2b7368c2cdd5e2b80f04ca09d64e02afbfe1"}, {"option": "Hex", "string": "1748e7179bd56570d51fa4ba287cc3e5"}, + 16, + "Start of input", "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, + "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" ] } ], diff --git a/tests/operations/tests/Register.mjs b/tests/operations/tests/Register.mjs index 3ef7ef94ad..4fc0d30791 100644 --- a/tests/operations/tests/Register.mjs +++ b/tests/operations/tests/Register.mjs @@ -59,6 +59,8 @@ TestRegister.addTests([ "option": "Hex", "string": "$R0" }, + 16, + "Start of input", "CTR", "Hex", "Raw", { "option": "Hex", @@ -67,7 +69,8 @@ TestRegister.addTests([ { "option": "Hex", "string": "" - } + }, + "Off" ] } ]