gchq/CyberChef · error · OperationError

Signature format could not be detected

Error message

Signature format could not be detected

What it means

Thrown in ECDSAVerify.run from the same Auto-detection logic as ECDSASignatureConversion: inputFormat starts as 'Auto', a JSON.parse probe (Raw JSON) and a fromBase64 URL-safe probe (JSON Web Signature) both silently fail, and the switch hits case 'Auto'. The signature was neither a JSON object nor a base64url concatenation, so its format could not be auto-detected.

Source

Thrown at src/core/operations/ECDSAVerify.mjs:119

                } else {
                    inputFormat = "P1363 HEX";
                }
            }
        }

        let inputBase64;
        if (inputFormat === "Auto") {
            try {
                inputBase64 = fromBase64(input, "A-Za-z0-9-_", false);
                inputFormat = "JSON Web Signature";
            } catch {}
        }

        // convert to ASN.1 signature
        let signatureASN1Hex;
        switch (inputFormat) {
            case "Auto":
                throw new OperationError("Signature format could not be detected");
            case "ASN.1 HEX":
                signatureASN1Hex = input;
                break;
            case "P1363 HEX":
                signatureASN1Hex = r.KJUR.crypto.ECDSA.concatSigToASN1Sig(input);
                break;
            case "JSON Web Signature":
                if (!inputBase64) inputBase64 = fromBase64(input, "A-Za-z0-9-_");
                signatureASN1Hex = r.KJUR.crypto.ECDSA.concatSigToASN1Sig(toHexFast(inputBase64));
                break;
            case "Raw JSON": {
                if (!inputJson) inputJson = JSON.parse(input);
                if (!inputJson.r) {
                    throw new OperationError('No "r" value in the signature JSON');
                }
                if (!inputJson.s) {
                    throw new OperationError('No "s" value in the signature JSON');
                }

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Set Input Format explicitly to the format you have (ASN.1 HEX / P1363 HEX / Raw JSON / JSON Web Signature).
  2. For JWS, use base64url encoding (- and _, strip padding).
  3. For Raw JSON, supply valid JSON with r and s.
  4. Trim whitespace from the signature.

Example fix

// before
verifyRun(p1363HexSig, ['Auto', ...]);   // Auto cannot detect P1363 hex
// after
verifyRun(p1363HexSig, ['P1363 HEX', ...]);
Defensive patterns

Strategy: validation

Validate before calling

function detectSigFormat(sig) {
  try { const o = JSON.parse(sig); if (o && typeof o === "object") return "Raw JSON"; } catch {}
  try { fromBase64(sig, "A-Za-z0-9-_", false); return "JSON Web Signature"; } catch {}
  if (/^[0-9a-fA-F]+$/.test(sig)) return "ASN.1 HEX";
  throw new Error("set the signature format explicitly");
}

Try / catch

try { verify(sig, ["Auto", ...]); }
catch (e) { if (String(e).includes("format could not be detected")) verify(sig, ["ASN.1 HEX", ...]); else throw e; }

Prevention

When it happens

Trigger: Input Format is 'Auto' and the signature is an ASN.1 HEX string (Auto does not recognise ASN.1 hex), malformed JSON, or standard base64 rather than base64url. Both probes swallow errors, leaving inputFormat untouched.

Common situations: Pasting ASN.1 HEX while on Auto; using +/ base64 instead of -_; truncated JSON; trailing whitespace breaking base64.

Related errors


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