gchq/CyberChef · error · OperationError

Unknown algorithm version: ${version}

Error message

Unknown algorithm version: ${version}

What it means

Thrown by the GOST Key Unwrap operation's version switch when the `Algorithm` arg is not one of "GOST 28147 (1989)", "GOST R 34.12 (Magma, 2015)", "GOST R 34.12 (Kuznyechik, 2015)". The label selects versionNum and blockLength before the key-wrap engine is constructed; an unknown label is rejected up front.

Source

Thrown at src/core/operations/GOSTKeyUnwrap.mjs:111

        const ukm = toHexFast(Utils.convertToByteArray(ukmObj.string, ukmObj.option));
        input = inputType === "Hex" ? input : toHexFast(Utils.strToArrayBuffer(input));

        let blockLength, versionNum;
        switch (version) {
            case "GOST 28147 (1989)":
                versionNum = 1989;
                blockLength = 64;
                break;
            case "GOST R 34.12 (Magma, 2015)":
                versionNum = 2015;
                blockLength = 64;
                break;
            case "GOST R 34.12 (Kuznyechik, 2015)":
                versionNum = 2015;
                blockLength = 128;
                break;
            default:
                throw new OperationError(`Unknown algorithm version: ${version}`);
        }

        const sBoxVal = versionNum === 1989 ? sBox : null;

        const algorithm = {
            version: versionNum,
            length: blockLength,
            mode: "KW",
            sBox: sBoxVal,
            keyWrapping: keyWrapping
        };

        try {
            const Hex = CryptoGost.coding.Hex;
            algorithm.ukm = Hex.decode(ukm);

            const cipher = GostEngine.getGostCipher(algorithm);
            const out = Hex.encode(cipher.unwrapKey(Hex.decode(key), Hex.decode(input)));

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Use one of the three declared option labels verbatim.
  2. Derive allowed values from `GOSTKeyUnwrap.args[4].value[].name` when scripting.

Example fix

// before
args[4] = "Magma 2015";
// after
args[4] = "GOST R 34.12 (Magma, 2015)";
Defensive patterns

Strategy: validation

Validate before calling

const VALID = ["GOST 28147 (1989)", "GOST R 34.12 (Magma, 2015)", "GOST R 34.12 (Kuznyechik, 2015)"];
if (!VALID.includes(version)) throw new Error(`Bad version; valid: ${VALID.join(", ")}`);

Type guard

function isGostVersion(v){return["GOST 28147 (1989)","GOST R 34.12 (Magma, 2015)","GOST R 34.12 (Kuznyechik, 2015)"].includes(v);}

Prevention

When it happens

Trigger: Programmatic recipe with a misspelled or legacy version string; replaying a recipe saved under a CyberChef version with different label text; passing the cipher's common name instead of the full label.

Common situations: Recipe migration; copy-pasting label text from third-party docs; locale differences.

Related errors


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