{"record":{"id":"aba26d181e68b002","repo":"gchq/CyberChef","slug":"enter-the-private-key-of-the-signer","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/PGPEncryptAndSign.mjs","lineNumber":73,"sourceCode":"                \"type\": \"text\",\n                \"value\": \"\"\n            }\n        ];\n    }\n\n    /**\n     * @param {string} input\n     * @param {Object[]} args\n     * @returns {string}\n     *\n     * @throws {OperationError} if failure to sign message\n     */\n    async run(input, args) {\n        const message = input,\n            [privateKey, passphrase, publicKey] = args;\n        let signedMessage;\n\n        if (!privateKey) throw new OperationError(\"Enter the private key of the signer.\");\n        if (!publicKey) throw new OperationError(\"Enter the public key of the recipient.\");\n        const privKey = await importPrivateKey(privateKey, passphrase);\n        const pubKey = await importPublicKey(publicKey);\n\n        try {\n            signedMessage = await promisify(kbpgp.box)({\n                \"msg\": message,\n                \"encrypt_for\": pubKey,\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","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/gchq/CyberChef/blob/4290ea753912378913b1f3f54e0fc5720afeda5d/src/core/operations/PGPEncryptAndSign.mjs#L55-L91","documentation":"PGPEncryptAndSign.run reads args[0] as the signer's private key. If it is falsy the operation aborts before importing any key - signing cannot proceed. This is an input-validation guard.","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 supplied only the recipient public key and forgot the signer private key; programmatic call with a missing argument; blank UI field.","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, publicKey] = args;\nif (!privateKey || !privateKey.trim()) {\n    throw new Error('Signer private key argument is required before running PGP Encrypt and 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 first.","Provide a passphrase if the key is locked.","Also supply the recipient public key."],"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"}