gchq/CyberChef · error · OperationError
${err}
Error message
${err} What it means
A catch-all around the crypto-gost-js engine calls in GOST Decrypt that re-throws any library exception as an OperationError. The underlying `err` is most often a key-length, IV-length, sBox, or hex-decode failure raised inside `GostEngine.getGostCipher` or `cipher.decrypt`. GOST keys must be 256 bits (32 bytes / 64 hex chars); block modes other than ECB require an IV equal to the block size (8 bytes for Magma, 16 for Kuznyechik).
Source
Thrown at src/core/operations/GOSTDecrypt.mjs:145
version: versionNum,
length: blockLength,
mode: "ES",
sBox: sBoxVal,
block: blockMode,
keyMeshing: keyMeshing,
padding: padding
};
try {
const Hex = CryptoGost.coding.Hex;
if (iv) algorithm.iv = Hex.decode(iv);
const cipher = GostEngine.getGostCipher(algorithm);
const out = Hex.encode(cipher.decrypt(Hex.decode(key), Hex.decode(input)));
return outputType === "Hex" ? out : Utils.byteArrayToChars(fromHex(out));
} catch (err) {
throw new OperationError(err);
}
}
}
export default GOSTDecrypt;
View on GitHub (pinned to 4290ea7539)
Solutions
- Ensure the key is exactly 32 bytes; if Input type is Hex, that is 64 hex digits.
- Provide an IV of the correct block size for any non-ECB mode (8 bytes for Magma, 16 for Kuznyechik).
- Verify the Input type matches the actual input encoding; switch to Raw if the input is text.
- Set padding to match how the data was encrypted (e.g. PKCS5).
- Inspect the wrapped `err.message` (it is preserved) to identify the exact library failure.
Example fix
// before: key too short, no IV for CBC args = ["aabb", "", "Hex", "Raw", "GOST R 34.12 (Magma, 2015)", "E-A", "CBC", "NO", "NO"]; // after: 32-byte key, 8-byte IV for 64-bit Magma CBC args = ["aabb...dd".padEnd(64,"0"), "0011223344556677", "Hex", "Raw", "GOST R 34.12 (Magma, 2015)", "E-A", "CBC", "NO", "PKCS5"];
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate key/iv lengths before baking
const KEY_BYTES = 32;
if (hexKey.length !== KEY_BYTES * 2) throw new Error(`Key must be ${KEY_BYTES} bytes (${KEY_BYTES*2} hex chars)`);
if (mode !== "ECB" && hexIv.length !== (blockBits/8) * 2) throw new Error(`IV must be ${blockBits/8} bytes for ${mode}`); Type guard
/** Hex string of even length with only 0-9a-fA-F */
function isHex(s) { return typeof s === "string" && /^[0-9a-fA-F]*$/.test(s) && s.length % 2 === 0; } Try / catch
try { chef.bake(input, recipe); }
catch (e) {
if (e.message && /key|iv|length|sbox/i.test(e.message)) handleUserError(e);
else throw e;
} Prevention
- Always supply a 32-byte (64-hex) GOST key.
- Match IV length to the algorithm's block size for non-ECB modes.
- Confirm Input type matches the real input encoding before baking.
- Keep the original error text — the wrapped err carries the library's precise message.
When it happens
Trigger: Supplying a key that is not exactly 32 bytes; choosing CBC/CFB/OFB/CTR but leaving the IV empty or the wrong length; passing non-hex characters when Input type is "Hex"; selecting an invalid sBox for the 1989 variant; decrypting data whose ciphertext length is not a whole number of blocks with NO padding.
Common situations: Pasting a key copied from a PEM/base64 source without converting to the configured key format; forgetting that the IV must match the block size of the chosen algorithm (Magma 64-bit vs Kuznyechik 128-bit); interop with another tool that used a different padding or mode.
Related errors
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/e64a2a3e057b0bf9.
Report an issue: GitHub.