gchq/CyberChef · error · OperationError

${err}

Error message

${err}

What it means

Catch-all around the MAC engine in GOST Sign, re-raising any crypto-gost-js error as an OperationError. Common underlying causes: key not 256 bits, an invalid macLength, bad sBox for the 1989 variant, non-hex input where applicable, or IV-length problems when an IV is supplied.

Source

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

        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)));

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

}

export default GOSTSign;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Provide a 32-byte (64-hex) key.
  2. Use a macLength within the block-size bit range.
  3. Match input/key encoding to the Input type.
  4. Inspect the preserved `err` for the exact library message.

Example fix

// before
key = "aabb"; // too short for MAC
// after
key = "aabb...".padEnd(64,"0"); // 32-byte key
Defensive patterns

Strategy: try-catch

Validate before calling

if (hexKey.length !== 64) throw new Error("GOST MAC key must be 32 bytes / 64 hex chars");
if (!Number.isInteger(macLength) || macLength <= 0 || macLength > blockBits) throw new Error(`macLength must be 1..${blockBits}`);

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

Prevention

When it happens

Trigger: Key shorter/longer than 32 bytes; macLength out of range for the algorithm; non-hex characters in key/input; an sBox the 1989 MAC rejects.

Common situations: Pasting a base64 key into a Hex field; choosing a macLength larger than the block size; interop with tooling using a different sBox default.

Related errors


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