gchq/CyberChef · error · OperationError

No "r" value in the signature JSON

Error message

No "r" value in the signature JSON

What it means

Thrown in ECDSASignatureConversion.run, Raw JSON branch, when the parsed object has no truthy inputJson.r. After JSON.parse succeeds, the code checks the two ECDSA scalars; a raw-JSON ECDSA signature must carry both r and s hex strings, and a missing r is rejected here before s is inspected.

Source

Thrown at src/core/operations/ECDSASignatureConversion.mjs:112

        // convert input to ASN.1 hex
        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');
                }
                signatureASN1Hex = r.KJUR.crypto.ECDSA.hexRSSigToASN1Sig(inputJson.r, inputJson.s);
                break;
            }
        }

        // convert ASN.1 hex to output format
        let result;
        switch (outputFormat) {
            case "ASN.1 HEX":
                result = signatureASN1Hex;
                break;
            case "P1363 HEX":
                result = r.KJUR.crypto.ECDSA.asn1SigToConcatSig(signatureASN1Hex);
                break;

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Ensure the JSON has lowercase 'r' and 's' hex strings: {"r":"...","s":"..."}.
  2. If your source uses different field names, rename them before feeding the operation.
  3. If the data is actually JWS/base64, use the JSON Web Signature format instead of Raw JSON.

Example fix

// before
run('{"s":"a3..."}', ['Raw JSON', ...]);   // missing r
// after
run('{"r":"bb...","s":"a3..."}', ['Raw JSON', ...]);
Defensive patterns

Strategy: validation

Validate before calling

const o = JSON.parse(sig);
if (!o || typeof o !== "object" || !o.r) throw new Error("signature JSON needs an 'r' field");

Type guard

const hasR = (o) => o != null && typeof o === "object" && Object.prototype.hasOwnProperty.call(o, "r");

Prevention

When it happens

Trigger: Input Format is Raw JSON (or Auto resolved to Raw JSON via JSON.parse) and the object lacks an 'r' field - e.g. {"s":"..."}, different key names like {"R":...,"S":...} (case-sensitive), or an unrelated JSON object.

Common situations: Producing JSON from a library that names fields differently (uppercase R, or 'rValue'); truncating JSON so r is dropped; pasting a JWK or other structure lacking r/s.

Related errors


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