{"record":{"id":"6e3af89c030c1b15","repo":"gchq/CyberChef","slug":"couldn-t-verify-message-err-6e3af8","errorCode":null,"errorMessage":"Couldn't verify message: ${err}","messagePattern":"Couldn't verify message: (.+?)","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"error","filePath":"src/core/operations/PGPVerify.mjs","lineNumber":105,"sourceCode":"                        }\n                        text += \"\\n\";\n                    }\n                    text += [\n                        `PGP key ID: ${km.get_pgp_short_key_id()}`,\n                        `PGP fingerprint: ${km.get_pgp_fingerprint().toString(\"hex\")}`,\n                        `Signed on ${new Date(ds.sig.when_generated() * 1000).toUTCString()}`,\n                        \"----------------------------------\\n\"\n                    ].join(\"\\n\");\n                    text += unboxedLiterals.toString();\n                    return text.trim();\n                } else {\n                    throw new OperationError(\"Could not identify a key manager.\");\n                }\n            } else {\n                throw new OperationError(\"The data does not appear to be signed.\");\n            }\n        } catch (err) {\n            throw new OperationError(`Couldn't verify message: ${err}`);\n        }\n    }\n\n}\n\nexport default PGPVerify;\n","sourceCodeStart":87,"sourceCodeEnd":112,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/PGPVerify.mjs#L87-L112","documentation":"A catch-all wrapper around the entire kbpgp verification flow. Any exception thrown inside the try block — whether from kbpgp.unbox itself or from the inner OperationError throws at lines 99 and 102 — is caught here and re-thrown with a 'Couldn't verify message:' prefix. This means inner errors (key manager not found, no signature detected) are ultimately surfaced through this wrapper.","triggerScenarios":"kbpgp.unbox rejects due to: wrong public key (signature was made with a different key), corrupt ASCII armor, malformed or unsupported PGP packet structure, or kbpgp internal assertion failures. Also catches and re-wraps the inner throws for 'Could not identify a key manager' and 'The data does not appear to be signed'.","commonSituations":"The provided public key does not correspond to the signer who created the message. The input is not a valid PGP message at all (random text). Version or format incompatibility between kbpgp and the PGP tool that produced the message.","solutions":["Read the full error text after the colon — it contains the specific kbpgp failure reason that caused the catch to fire","Verify the public key argument matches the key that signed the message","Ensure the input is valid ASCII-armored PGP (not binary OpenPGP, not random text)","If the appended message says 'does not appear to be signed', the message lacks a signature — switch to PGP Sign or PGP Encrypt & Sign"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: is the input ASCII-armored PGP?\nconst ARMOR_RE = /^-----BEGIN PGP (MESSAGE|SIGNED MESSAGE|PUBLIC KEY)-----/;\nif (!ARMOR_RE.test(input.trim())) {\n  throw new Error(\"Input is not ASCII-armored PGP data.\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await chef.pgpVerify(input, [publicKey]);\n} catch (e) {\n  const msg = e.message;\n  // The full reason is embedded after the colon\n  console.error(\"PGP verification failed:\", msg);\n  if (/wrong key|no key/i.test(msg)) {\n    // public key mismatch — prompt for correct key\n  }\n}","preventionTips":["Ensure the public key argument matches the key that signed the message","Validate the input is ASCII-armored PGP before calling the operation","Read the full error text after the colon for the specific kbpgp failure reason"],"tags":["pgp","signature","crypto","kbpgp","error-wrapping"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}