gchq/CyberChef · error · OperationError

No "s" value in the signature JSON

Error message

No "s" value in the signature JSON

What it means

Thrown in ECDSASignatureConversion.run, Raw JSON branch, after the r check passed but inputJson.s is falsy. Companion to the r guard: a raw-JSON ECDSA signature needs both scalars, and a missing s is caught right after r is confirmed.

Source

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

            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;
            case "JSON Web Signature":
                result = r.KJUR.crypto.ECDSA.asn1SigToConcatSig(signatureASN1Hex);
                result = toBase64(fromHex(result), "A-Za-z0-9-_");  // base64url

View on GitHub (pinned to 4290ea7539)

Solutions

  1. Ensure the JSON contains a lowercase 's' hex string alongside 'r': {"r":"...","s":"..."}.
  2. Rename mismatched field names from your source data before input.
  3. Re-extract both scalars from the original signature if only one was captured.

Example fix

// before
run('{"r":"bb..."}', ['Raw JSON', ...]);  // missing s
// 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.s) throw new Error("signature JSON needs an 's' field");

Type guard

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

Prevention

When it happens

Trigger: Input Format resolved to Raw JSON and the JSON has a valid r but no s - e.g. {"r":"..."} or {"r":"...","sig":"..."} where the second scalar is under a different key.

Common situations: Truncated JSON missing the trailing s; a field named differently by the producing tool ('S' uppercase, 'sValue'); only the r half of a split signature was serialised.

Related errors


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