gchq/CyberChef · warning · OperationError
Bit length limited to 4096 bits for performance reasons
Error message
Bit length limited to 4096 bits for performance reasons
What it means
Thrown by GeneratePrime when the requested bit length exceeds 4096. The cap exists for performance reasons — Miller-Rabin probable-prime testing on very large numbers is expensive in the browser/Node environment.
Source
Thrown at src/core/operations/GeneratePrime.mjs:127
value: ["Decimal", "Hexadecimal"]
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
const [bits, cryptoGrade, outputFormat] = args;
if (bits < 2) {
throw new OperationError("Bit length must be at least 2");
}
if (bits > 4096) {
throw new OperationError("Bit length limited to 4096 bits for performance reasons");
}
const rounds = cryptoGrade ? 40 : 7;
let attempts = 0;
const maxAttempts = 10000;
let n = randBigInt(bits);
while (!isProbablePrime(n, rounds)) {
n = randBigInt(bits);
attempts++;
if (attempts > maxAttempts) {
throw new OperationError(`Failed to generate prime after ${maxAttempts} attempts. Try a different bit length.`);
}
}
// Return only the prime for pipeabilityView on GitHub (pinned to 4290ea7539)
Solutions
- Set bits to 4096 or less.
- For larger primes, use a dedicated native crypto tool or OpenSSL outside CyberChef.
Example fix
// before args = [8192, true, "Hexadecimal"]; // after args = [4096, true, "Hexadecimal"];
Defensive patterns
Strategy: validation
Validate before calling
if (bits > 4096) {
// cap or reject; explain the 4096-bit performance limit
} Type guard
function isWithinPrimeBitCap(n) {
return Number.isInteger(n) && n >= 2 && n <= 4096;
} Prevention
- Inform users that 4096 is the hard cap for in-browser prime generation.
- Direct users needing larger primes to native tooling (OpenSSL).
When it happens
Trigger: Passing bits > 4096 (e.g. 8192) expecting RSA-key-sized primes.
Common situations: User accustomed to 8192-bit RSA trying to generate equally large primes here.
Related errors
- Bit length must be at least 2
- Length must be less than ${maxLoremWords}
- Length must be less than ${maxLoremCharacters}
- Bit length limited to 4096 bits for performance reasons
- Invalid block cipher mode: ${mode}
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/84c8cb6c8f06d3fd.
Report an issue: GitHub.