{"record":{"id":"c45c596fa88e552b","repo":"gchq/CyberChef","slug":"no-r-value-in-the-signature-json","errorCode":null,"errorMessage":"No \"r\" value in the signature JSON","messagePattern":"No \"r\" value in the signature JSON","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/ECDSASignatureConversion.mjs","lineNumber":112,"sourceCode":"        // convert input to ASN.1 hex\n        let signatureASN1Hex;\n        switch (inputFormat) {\n            case \"Auto\":\n                throw new OperationError(\"Signature format could not be detected\");\n            case \"ASN.1 HEX\":\n                signatureASN1Hex = input;\n                break;\n            case \"P1363 HEX\":\n                signatureASN1Hex = r.KJUR.crypto.ECDSA.concatSigToASN1Sig(input);\n                break;\n            case \"JSON Web Signature\":\n                if (!inputBase64) inputBase64 = fromBase64(input, \"A-Za-z0-9-_\");\n                signatureASN1Hex = r.KJUR.crypto.ECDSA.concatSigToASN1Sig(toHexFast(inputBase64));\n                break;\n            case \"Raw JSON\": {\n                if (!inputJson) inputJson = JSON.parse(input);\n                if (!inputJson.r) {\n                    throw new OperationError('No \"r\" value in the signature JSON');\n                }\n                if (!inputJson.s) {\n                    throw new OperationError('No \"s\" value in the signature JSON');\n                }\n                signatureASN1Hex = r.KJUR.crypto.ECDSA.hexRSSigToASN1Sig(inputJson.r, inputJson.s);\n                break;\n            }\n        }\n\n        // convert ASN.1 hex to output format\n        let result;\n        switch (outputFormat) {\n            case \"ASN.1 HEX\":\n                result = signatureASN1Hex;\n                break;\n            case \"P1363 HEX\":\n                result = r.KJUR.crypto.ECDSA.asn1SigToConcatSig(signatureASN1Hex);\n                break;","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ECDSASignatureConversion.mjs#L94-L130","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the JSON has lowercase 'r' and 's' hex strings: {\"r\":\"...\",\"s\":\"...\"}.","If your source uses different field names, rename them before feeding the operation.","If the data is actually JWS/base64, use the JSON Web Signature format instead of Raw JSON."],"exampleFix":"// before\nrun('{\"s\":\"a3...\"}', ['Raw JSON', ...]);   // missing r\n// after\nrun('{\"r\":\"bb...\",\"s\":\"a3...\"}', ['Raw JSON', ...]);","handlingStrategy":"validation","validationCode":"const o = JSON.parse(sig);\nif (!o || typeof o !== \"object\" || !o.r) throw new Error(\"signature JSON needs an 'r' field\");","typeGuard":"const hasR = (o) => o != null && typeof o === \"object\" && Object.prototype.hasOwnProperty.call(o, \"r\");","tryCatchPattern":null,"preventionTips":["Standardise raw-JSON ECDSA signatures as lowercase {\"r\",\"s\"} hex fields.","Rename upstream field names (R/S, rValue/sValue) before feeding the operation."],"tags":["crypto","ecdsa","signature","json","operation-error"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}