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

  1. Paste a full EC public key PEM (-----BEGIN PUBLIC KEY----- ...base64... -----END PUBLIC KEY-----).
  2. Extract the public key from a certificate with openssl if needed.
  3. 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

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


AI-assisted analysis of gchq/CyberChef@4290ea7539 (2026-08-13). Data as JSON: /api/errors/5f9b69cb4b88dc85. Report an issue: GitHub.