gchq/CyberChef · error · OperationError
Please enter a public key.
Error message
Please enter a public key.
What it means
Thrown in ECDSAVerify.run when keyPem.replace('-----BEGIN PUBLIC KEY-----', '').length === 0. Exactly mirroring ECDSASign's placeholder guard, the operation's default public-key text is the header line alone; this catches the user who left the field at the placeholder or pasted only the header. It fires before signature format detection, so it is a key-presence guard, not a format check.
Source
Thrown at src/core/operations/ECDSAVerify.mjs:82
{
name: "Message format",
type: "option",
value: ["Raw", "Hex", "Base64"]
}
];
}
/**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/
run(input, args) {
let inputFormat = args[0];
const [, mdAlgo, keyPem, msg, msgFormat] = args;
if (keyPem.replace("-----BEGIN PUBLIC KEY-----", "").length === 0) {
throw new OperationError("Please enter a public key.");
}
// detect input format
let inputJson;
if (inputFormat === "Auto") {
try {
inputJson = JSON.parse(input);
if (typeof(inputJson) === "object") {
inputFormat = "Raw JSON";
}
} catch {}
}
if (inputFormat === "Auto") {
const hexRegex = /^[a-f\d]{2,}$/gi;
if (hexRegex.test(input)) {
if (input.substring(0, 2) === "30" && r.ASN1HEX.isASN1HEX(input)) {
inputFormat = "ASN.1 HEX";View on GitHub (pinned to 4290ea7539)
Solutions
- Paste a full EC public key PEM (-----BEGIN PUBLIC KEY----- ...base64... -----END PUBLIC KEY-----).
- Extract the public key from a certificate with openssl if needed.
- Ensure the full PEM text (header, body, footer) is saved in any shared recipe.
Example fix
// before (placeholder only) const key = '-----BEGIN PUBLIC KEY-----'; // after const key = '-----BEGIN PUBLIC KEY-----\nMFkw...full base64...\n-----END PUBLIC KEY-----';
Defensive patterns
Strategy: validation
Validate before calling
function hasPemBody(pem, header) {
const after = pem.replace(header, "");
return after.trim().length > 0 && pem.includes(header.replace("BEGIN", "END"));
}
if (!hasPemBody(keyPem, "-----BEGIN PUBLIC KEY-----")) throw new Error("paste a full EC public key"); Type guard
const looksLikePublicKey = (p) => /-----BEGIN PUBLIC KEY-----[\s\S]+-----END PUBLIC KEY-----/.test(p);
Prevention
- Always replace the placeholder header with a complete PEM (header+body+footer).
- Validate the PEM has a body and END line before saving the recipe.
When it happens
Trigger: The 'Public Key (PEM)' field still equals '-----BEGIN PUBLIC KEY-----' with nothing after, or holds only that header line.
Common situations: Default placeholder never replaced; a key missing the base64 body and END line; a recipe saved before the key was supplied.
Related errors
- Please enter a private key.
- Provided key is not an EC key.
- Provided key is not a private key.
- Provided key is not an EC key.
- Provided key is not a public key.
AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13).
Data as JSON: /api/errors/5f9b69cb4b88dc85.
Report an issue: GitHub.