{"record":{"id":"ce8f9884f532ed9b","repo":"gchq/CyberChef","slug":"undefined-encryption-algorithm","errorCode":null,"errorMessage":"Undefined encryption algorithm","messagePattern":"Undefined encryption algorithm","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/CMAC.mjs","lineNumber":77,"sourceCode":"                    }\n                    return {\n                        \"algorithm\": \"AES-ECB\",\n                        \"key\": key,\n                        \"blockSize\": 16,\n                        \"Rb\": new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x87]),\n                    };\n                case \"Triple DES\":\n                    if (key.length !== 16 && key.length !== 24) {\n                        throw new OperationError(\"The key for Triple DES must be 16 or 24 bytes (currently \" + key.length + \" bytes)\");\n                    }\n                    return {\n                        \"algorithm\": \"3DES-ECB\",\n                        \"key\": key.length === 16 ? key + key.substring(0, 8) : key,\n                        \"blockSize\": 8,\n                        \"Rb\": new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0x1b]),\n                    };\n                default:\n                    throw new OperationError(\"Undefined encryption algorithm\");\n            }\n        })();\n\n        const xor = function(a, b, out) {\n            if (!out) out = new Uint8Array(a.length);\n            for (let i = 0; i < a.length; i++) {\n                out[i] = a[i] ^ b[i];\n            }\n            return out;\n        };\n\n        const leftShift1 = function(a) {\n            const out = new Uint8Array(a.length);\n            let carry = 0;\n            for (let i = a.length - 1; i >= 0; i--) {\n                out[i] = (a[i] << 1) | carry;\n                carry = a[i] >> 7;\n            }","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/CMAC.mjs#L59-L95","documentation":"The CMAC operation's algorithm switch only handles 'AES' and 'Triple DES'. Any other value for args[1] (algo) falls through to the default case and throws, since no block-cipher configuration is defined for it.","triggerScenarios":"Calling CMAC.run with args[1] set to a value other than 'AES' or 'Triple DES' (e.g. a typo, 'DES', 'AES-128', or a localized string).","commonSituations":"Dropdown/value mismatch after an upgrade; user-typed algorithm name; recipe serialized with a stale or unsupported algorithm identifier.","solutions":["Set algo to exactly 'AES' or 'Triple DES'.","If you need another algorithm, pick a different MAC operation (e.g. HMAC).","Validate the algorithm against the allowed set in the UI before running."],"exampleFix":"// before\nalgo = 'AES-128'\n// after\nalgo = 'AES'","handlingStrategy":"validation","validationCode":"if (!['AES', 'Triple DES'].includes(algo)) throw new Error('CMAC algo must be AES or Triple DES');","typeGuard":"function isSupportedCmacAlgo(a) { return a === 'AES' || a === 'Triple DES'; }","tryCatchPattern":null,"preventionTips":["Restrict the algorithm dropdown to AES and Triple DES.","For other primitives use the appropriate MAC operation.","Validate against the allowed set before running."],"tags":["crypto","cmac","validation","algorithm"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}