gchq/CyberChef · error · OperationError
Invalid size
Error message
Invalid size
What it means
Thrown by the Shake operation when the 'Capacity' argument is neither 128 nor 256 (after parseInt). The message says 'Invalid size' but it actually guards the capacity parameter (the SHAKE variant selection). SHAKE only has two defined instances: shake128 and shake256.
Source
Thrown at src/core/operations/Shake.mjs:63
* @returns {string}
*/
run(input, args) {
const capacity = parseInt(args[0], 10),
size = args[1];
let algo;
if (size < 0)
throw new OperationError("Size must be greater than 0");
switch (capacity) {
case 128:
algo = JSSHA3.shake128;
break;
case 256:
algo = JSSHA3.shake256;
break;
default:
throw new OperationError("Invalid size");
}
return algo(input, size);
}
}
export default Shake;
View on GitHub (pinned to 4290ea7539)
Solutions
- Set Capacity to either 128 or 256 (the only two supported SHAKE instances).
- If using SHA-3 with other bit sizes, use the 'SHA3' operation instead of Shake.
- Validate the capacity against [128, 256] before invoking.
Example fix
// before run(input, ["384", 512]) // after run(input, ["256", 512])
Defensive patterns
Strategy: validation
Validate before calling
const capacity = parseInt(args[0], 10);
if (capacity !== 128 && capacity !== 256) {
throw new Error(`Unsupported Shake capacity ${capacity}; use 128 or 256.`);
}
// safe to invoke Shake Type guard
function isValidShakeCapacity(capacity) {
return [128, 256].includes(parseInt(capacity, 10));
} Try / catch
try {
chef.shake(input, { capacity: "128", size: 256 });
} catch (e) {
// 'Invalid size' here actually means invalid capacity.
} Prevention
- Only use the predefined Capacity options (128, 256).
- For other SHA-3 bit sizes use the SHA3 operation, not Shake.
- Validate capacity against [128,256] when building recipes programmatically.
When it happens
Trigger: The Capacity option is parsed to a value other than 128 or 256. The arg type is 'option' with values ["256","128"], so this is only reachable if the option value is tampered with or the operation is invoked programmatically with an unsupported capacity.
Common situations: Programmatic recipe construction passing a capacity like 384 or 512 (those are SHA-3 variants, not valid SHAKE capacities); corrupted recipe JSON; a custom UI that allows free-text entry of capacity.
Related errors
- Size must be greater than 0
- Invalid size
- Invalid size
- Invalid block cipher mode: ${mode}
- Invalid ciphertext length: ${originalLength} bytes. Must be
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/e9e34ab3a783c45e.
Report an issue: GitHub.