From 514c97c5b27260bd8519f9830e0792188dc032d4 Mon Sep 17 00:00:00 2001 From: J8k3 Date: Mon, 15 Jun 2026 08:30:39 -0400 Subject: [PATCH] fix(payment): align AES calls with upstream v11 operation signatures The v11 sync changed the AESEncrypt/AESDecrypt operation argument layouts (purely additive): - AESDecrypt inserted 'ivLength' at args[2] and appended 'ivFromInput' at args[8]. - AESEncrypt appended 'Include IV in output' at args[6]. PaymentDataCipher still passed the old positional layout, so AESDecrypt read args[7].string off undefined, erroring the 4 Payment Decrypt/ Re-Encrypt tests. Realign both call sites; pass ivFromInput/includeIV 'Off' to preserve the prior behaviour (IV supplied explicitly, never sliced from or prepended to the data). Co-Authored-By: Claude Opus 4.8 (1M context) --- src/core/lib/PaymentDataCipher.mjs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/lib/PaymentDataCipher.mjs b/src/core/lib/PaymentDataCipher.mjs index ff36fbc4..2124ff57 100644 --- a/src/core/lib/PaymentDataCipher.mjs +++ b/src/core/lib/PaymentDataCipher.mjs @@ -91,13 +91,15 @@ function encryptPaymentData(inputHex, profile, keyHex, ivHex, ksn, dukptVariant) if (profile.startsWith("AES ")) { const aes = new AESEncrypt(); const mode = profile.substring(4); + // AESEncrypt args: [key, iv, mode, inputType, outputType, AAD, includeIV] ciphertextHex = aes.run(plaintextHex, [ { string: effectiveKeyHex, option: "Hex" }, { string: normalizedIv, option: "Hex" }, mode, "Hex", "Hex", - { string: "", option: "Hex" } + { string: "", option: "Hex" }, + "Off" ]).toUpperCase(); } else { const tdes = new TripleDESEncrypt(); @@ -140,14 +142,18 @@ function decryptPaymentData(inputHex, profile, keyHex, ivHex, ksn, dukptVariant) if (profile.startsWith("AES ")) { const aes = new AESDecrypt(); const mode = profile.substring(4); + // AESDecrypt args: [key, iv, ivLength, mode, inputType, outputType, GCM tag, AAD, ivFromInput]. + // ivLength is unused here because the IV is supplied explicitly (ivFromInput "Off"). plaintextHex = aes.run(ciphertextHex, [ { string: effectiveKeyHex, option: "Hex" }, { string: normalizedIv, option: "Hex" }, + 16, mode, "Hex", "Hex", { string: "", option: "Hex" }, - { string: "", option: "Hex" } + { string: "", option: "Hex" }, + "Off" ]).toUpperCase(); } else { const tdes = new TripleDESDecrypt();