{"record":{"id":"2060a2e6fe372e73","repo":"gchq/CyberChef","slug":"no-r-value-in-the-signature-json-2060a2","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/ECDSAVerify.mjs","lineNumber":133,"sourceCode":"        // convert to ASN.1 signature\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        // verify signature\n        const internalAlgorithmName = mdAlgo.replace(\"-\", \"\") + \"withECDSA\";\n        const sig = new r.KJUR.crypto.Signature({ alg: internalAlgorithmName });\n        const key = r.KEYUTIL.getKey(keyPem);\n        if (key.type !== \"EC\") {\n            throw new OperationError(\"Provided key is not an EC key.\");\n        }\n        if (!key.isPublic) {\n            throw new OperationError(\"Provided key is not a public key.\");","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/ECDSAVerify.mjs#L115-L151","documentation":"Thrown in ECDSAVerify.run, Raw JSON branch, when the parsed signature JSON has no truthy r field. Identical to the corresponding guard in ECDSASignatureConversion: after format resolution to Raw JSON and JSON.parse, the r scalar is checked first; a missing r aborts before s is inspected.","triggerScenarios":"Input Format is Raw JSON (or Auto resolved there) and the object lacks 'r' - e.g. {\"s\":\"...\"}, wrong-cased keys, or unrelated JSON.","commonSituations":"Field-name mismatch from the producing library; truncated JSON; pasting a non-ECDSA JSON structure.","solutions":["Provide JSON with lowercase 'r' and 's' hex strings.","Rename mismatched fields from your source data.","If the data is base64/concatenation, use the JSON Web Signature or P1363 format instead."],"exampleFix":"// before\nverifyRun('{\"s\":\"a3...\"}', ['Raw JSON', ...]);  // missing r\n// after\nverifyRun('{\"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":["Use lowercase r/s field names in raw-JSON signatures.","Validate the JSON shape before verifying."],"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"}