{"record":{"id":"02d79ecd01ec7f15","repo":"gchq/CyberChef","slug":"enter-the-private-key-of-the-signer-02d79e","errorCode":null,"errorMessage":"Enter the private key of the signer.","messagePattern":"Enter the private key of the signer\\.","errorType":"exception","errorClass":"OperationError","httpStatus":null,"severity":"warning","filePath":"src/core/operations/PGPSign.mjs","lineNumber":65,"sourceCode":"                \"type\": \"string\",\n                \"value\": \"\"\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     *\n     * @throws {OperationError} if failed private key import or failed encryption\n     */\n    async run(input, args) {\n        const message = input,\n            [privateKey, passphrase] = args;\n        let signedMessage;\n\n        if (!privateKey) throw new OperationError(\"Enter the private key of the signer.\");\n        const privKey = await importPrivateKey(privateKey, passphrase);\n\n        try {\n            signedMessage = await promisify(kbpgp.box)({\n                \"msg\": message,\n                \"sign_with\": privKey,\n                \"asp\": ASP\n            });\n        } catch (err) {\n            throw new OperationError(`Couldn't sign message: ${err}`);\n        }\n\n        return signedMessage;\n    }\n\n}\n\nexport default PGPSign;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/PGPSign.mjs#L47-L83","documentation":"PGPSign.run reads args[0] as the signer's private key. If it is falsy the operation aborts before importing any key - there is nothing to sign with. This is an input-validation guard thrown before any crypto runs.","triggerScenarios":"The 'Private key of signer' argument is empty; the args array is shorter than expected; the key text was not bound into the recipe.","commonSituations":"User forgot to paste the private key; an automated recipe with a blank key field; copy-paste that missed the clipboard.","solutions":["Provide the signer's ASCII-armoured PGP private key in the first argument.","If the key is passphrase-protected, also fill the passphrase field.","Verify the key begins with '-----BEGIN PGP PRIVATE KEY BLOCK-----'."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const [privateKey, passphrase] = args;\nif (!privateKey || !privateKey.trim()) {\n    throw new Error('Signer private key argument is required before running PGP Sign.');\n}","typeGuard":"const isArmouredPrivateKey = (s) =>\n    typeof s === 'string' && /-----BEGIN PGP PRIVATE KEY BLOCK-----/.test(s);","tryCatchPattern":null,"preventionTips":["Populate the signer private-key argument before running.","Provide a passphrase if the key is locked.","Use a key that has a signing subkey."],"tags":["pgp","validation","kbpgp","cryptography"],"backgroundTag":null,"analyzedSha":"4290ea753912378913b1f3f54e0fc5720afeda5d","analyzedAt":"2026-08-13T06:05:50.210Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}