{"record":{"id":"84319dd384112957","repo":"gchq/CyberChef","slug":"unknown-algorithm-version-version-84319d","errorCode":null,"errorMessage":"Unknown algorithm version: ${version}","messagePattern":"Unknown algorithm version: (.+?)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/GOSTKeyWrap.mjs","lineNumber":111,"sourceCode":"        const ukm = toHexFast(Utils.convertToByteArray(ukmObj.string, ukmObj.option));\n        input = inputType === \"Hex\" ? input : toHexFast(Utils.strToArrayBuffer(input));\n\n        let blockLength, versionNum;\n        switch (version) {\n            case \"GOST 28147 (1989)\":\n                versionNum = 1989;\n                blockLength = 64;\n                break;\n            case \"GOST R 34.12 (Magma, 2015)\":\n                versionNum = 2015;\n                blockLength = 64;\n                break;\n            case \"GOST R 34.12 (Kuznyechik, 2015)\":\n                versionNum = 2015;\n                blockLength = 128;\n                break;\n            default:\n                throw new OperationError(`Unknown algorithm version: ${version}`);\n        }\n\n        const sBoxVal = versionNum === 1989 ? sBox : null;\n\n        const algorithm = {\n            version: versionNum,\n            length: blockLength,\n            mode: \"KW\",\n            sBox: sBoxVal,\n            keyWrapping: keyWrapping\n        };\n\n        try {\n            const Hex = CryptoGost.coding.Hex;\n            algorithm.ukm = Hex.decode(ukm);\n\n            const cipher = GostEngine.getGostCipher(algorithm);\n            const out = Hex.encode(cipher.wrapKey(Hex.decode(key), Hex.decode(input)));","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/GOSTKeyWrap.mjs#L93-L129","documentation":"Thrown by the GOST Key Wrap operation's version switch when the `Algorithm` arg is not one of the three supported labels (\"GOST 28147 (1989)\", \"GOST R 34.12 (Magma, 2015)\", \"GOST R 34.12 (Kuznyechik, 2015)\"). The label selects versionNum/blockLength before the KW engine is built; an unmatched value is rejected before wrapping.","triggerScenarios":"Programmatic recipe with a misspelled/legacy version string; replaying an older recipe whose label text differs; using the cipher's short name instead of the full label.","commonSituations":"Recipe migration across CyberChef versions; docs copy-paste; locale differences.","solutions":["Use one of the three declared option labels verbatim.","Derive allowed values from `GOSTKeyWrap.args[4].value[].name` when scripting."],"exampleFix":"// before\nargs[4] = \"28147\";\n// after\nargs[4] = \"GOST 28147 (1989)\";","handlingStrategy":"validation","validationCode":"const VALID = [\"GOST 28147 (1989)\", \"GOST R 34.12 (Magma, 2015)\", \"GOST R 34.12 (Kuznyechik, 2015)\"];\nif (!VALID.includes(version)) throw new Error(`Bad version; valid: ${VALID.join(\", \")}`);","typeGuard":"function isGostVersion(v){return[\"GOST 28147 (1989)\",\"GOST R 34.12 (Magma, 2015)\",\"GOST R 34.12 (Kuznyechik, 2015)\"].includes(v);}","tryCatchPattern":null,"preventionTips":["Reuse labels from GOSTKeyWrap.args option list when scripting.","Regenerate older recipe steps after upgrades."],"tags":["crypto","gost","key-wrap","argument-validation"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}