gchq/CyberChef · error · OperationError

${err}

Error message

${err}

What it means

Catch-all around the crypto-gost-js engine calls in GOST Encrypt, re-raising any library error as an OperationError. Common underlying causes: key not 256 bits, IV missing/wrong length for the chosen block mode, invalid sBox for the 1989 variant, non-hex input where Input type is Hex, or engine parameter incompatibility.

Source

Thrown at src/core/operations/GOSTEncrypt.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.encrypt(Hex.decode(key), Hex.decode(input)));

            return outputType === "Hex" ? out : Utils.byteArrayToChars(fromHex(out));
        } catch (err) {
            throw new OperationError(err);
        }
    }

}

export default GOSTEncrypt;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Provide a 32-byte (64-hex-digit) key.
  2. Supply an IV matching the block size for non-ECB modes.
  3. Match Input type to the real input encoding.
  4. Inspect the preserved `err` to pinpoint the library failure.

Example fix

// before: 8-byte IV with 128-bit Kuznyechik CBC
args = [key, "0011223344556677", "Hex", "Hex", "GOST R 34.12 (Kuznyechik, 2015)", "E-A", "CBC", "NO", "PKCS5"];
// after: 16-byte IV
args = [key, "00112233445566778899aabbccddeeff", "Hex", "Hex", "GOST R 34.12 (Kuznyechik, 2015)", "E-A", "CBC", "NO", "PKCS5"];
Defensive patterns

Strategy: try-catch

Validate before calling

if (hexKey.length !== 64) throw new Error("GOST key must be 32 bytes / 64 hex chars");
if (mode !== "ECB" && hexIv.length !== (blockBits/8)*2) throw new Error(`IV must be ${blockBits/8} bytes for ${mode}`);

Type guard

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 (/key|iv|length|sbox/i.test(e.message||"")) handleUserError(e); else throw e; }

Prevention

When it happens

Trigger: Key shorter/longer than 32 bytes; CBC/CFB/OFB/CTR selected with an IV that isn't the block size; non-hex characters in input when Input type is Hex; an sBox value that the 1989 engine rejects.

Common situations: Interop with external GOST tooling that uses different defaults; pasting base64 keys into a Hex field; forgetting Kuznyechik needs a 16-byte IV vs Magma's 8 bytes.

Related errors


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/8a233c1779fd4eab. Report an issue: GitHub.