gchq/CyberChef · error · OperationError

Unknown algorithm version: ${version}

Error message

Unknown algorithm version: ${version}

What it means

Thrown by the GOST Sign (MAC) 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 sets versionNum/blockLength before the MAC engine is built; an unknown value is rejected up front.

Source

Thrown at src/core/operations/GOSTSign.mjs:114

        const iv = toHexFast(Utils.convertToByteArray(ivObj.string, ivObj.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: "MAC",
            sBox: sBoxVal,
            macLength: macLength
        };

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

            const cipher = GostEngine.getGostCipher(algorithm);
            const out = Hex.encode(cipher.sign(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 `GOSTSign.args` option list when scripting.

Example fix

// before
args[versionIndex] = "Magma";
// after
args[versionIndex] = "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/legacy version label; replaying a recipe from an older CyberChef release; using the cipher's short name.

Common situations: Recipe migration; docs copy-paste; locale differences.

Related errors


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