{"record":{"id":"4ea21d90c069da1d","repo":"gchq/CyberChef","slug":"unable-to-decrypt-input-with-these-parameters","errorCode":null,"errorMessage":"Unable to decrypt input with these parameters.","messagePattern":"Unable to decrypt input with these parameters\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/AESDecrypt.mjs","lineNumber":198,"sourceCode":"        /* Allow for a \"no padding\" mode */\n        if (noPadding) {\n            decipher.mode.unpad = function (output, options) {\n                return true;\n            };\n        }\n\n        decipher.start({\n            iv: iv.length === 0 ? \"\" : iv,\n            tag: mode === \"GCM\" ? gcmTag : undefined,\n            additionalData: mode === \"GCM\" ? aad : undefined\n        });\n        decipher.update(forge.util.createBuffer(input));\n        const result = decipher.finish();\n\n        if (result) {\n            return outputType === \"Hex\" ? decipher.output.toHex() : decipher.output.getBytes();\n        } else {\n            throw new OperationError(\"Unable to decrypt input with these parameters.\");\n        }\n    }\n\n}\n\nexport default AESDecrypt;\n","sourceCodeStart":180,"sourceCodeEnd":205,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/AESDecrypt.mjs#L180-L205","documentation":"After feeding the data to node-forge, AESDecrypt checks decipher.finish(); a falsy return means forge could not complete decryption/authentication. This is a catch-all for any parameter mismatch that survives the earlier size checks — wrong key, wrong/missing IV, wrong mode or padding, GCM authentication-tag failure, or corrupted ciphertext. The operation cannot tell you which one, only that decryption failed.","triggerScenarios":"decipher.finish() returns false. Most often: GCM mode with a missing/incorrect tag (args[6]) or AAD (args[7]); wrong key or IV relative to the ciphertext; mode/padding string (args[3]) does not match the encryption (e.g. decrypting CBC data as CFB); corrupted or truncated ciphertext after the IV was stripped.","commonSituations":"Decrypting with a key/IV that differs from encryption by a single byte; selecting a mode without 'NoPadding' when the data has no padding (or vice versa); GCM tag omitted; hex/base64 decoding mismatch silently changing bytes; cross-tool interop where the other tool prepended a salt/header.","solutions":["Triple-check that key, IV, and mode string exactly match the encryption parameters.","For GCM, ensure the auth tag (args[6]) is correct (typically 16 bytes) and AAD (args[7]) matches what was used at encryption.","Confirm the input/output encoding options and that the ciphertext was not truncated by copy-paste.","For GCM, double-check the AAD and tag; for padded modes, verify the padding setting matches."],"exampleFix":"// before: GCM decrypt with missing/incorrect tag, or wrong key → 'Unable to decrypt input with these parameters.'\n// after: supply the exact 16-byte auth tag and AAD from encryption, and the correct key/IV","handlingStrategy":"try-catch","validationCode":"function preflightGcm(tagBytes, aadBytes) {\n  if (!tagBytes || tagBytes.length !== 16) throw new Error('GCM tag must be 16 bytes');\n}","typeGuard":"function looksLikeValidCiphertext(bytes, ivLen) { return bytes.length > ivLen && (bytes.length - ivLen) % 1 === 0; }","tryCatchPattern":"try {\n  return decryptAES(input, key, iv, mode, tag, aad);\n} catch (e) {\n  if (/Unable to decrypt/.test(e.message)) {\n    // key/IV/mode/tag/AAD mismatch — verify against encryption params, do not blindly retry\n    throw new Error('Decryption failed: check key, IV, mode, GCM tag, and AAD');\n  }\n  throw e;\n}","preventionTips":["Keep encryption parameters (key, IV, mode, padding, tag, AAD) in lockstep with decryption.","For GCM, always transmit and supply the 16-byte auth tag.","Verify hex/base64 decoding did not silently change byte values."],"tags":["aes","crypto","decryption","auth"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}