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) <noreply@anthropic.com>
This commit is contained in:
parent
1045fcc3c5
commit
514c97c5b2
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user