mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
Ported x86 Disassembler & PGP ops
This commit is contained in:
parent
b8d39f49b2
commit
2b0c327001
7 changed files with 694 additions and 0 deletions
80
src/core/operations/PGPEncryptAndSign.mjs
Normal file
80
src/core/operations/PGPEncryptAndSign.mjs
Normal file
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
* @author tlwr [toby@toby.codes]
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
import * as kbpgp from "kbpgp";
|
||||
import { promisify } from "es6-promisify";
|
||||
import { ASP, importPrivateKey, importPublicKey } from "../lib/PGP";
|
||||
|
||||
/**
|
||||
* PGP Encrypt and Sign operation
|
||||
*/
|
||||
class PGPEncryptAndSign extends Operation {
|
||||
|
||||
/**
|
||||
* PGPEncryptAndSign constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "PGP Encrypt and Sign";
|
||||
this.module = "PGP";
|
||||
this.description = "Input: the cleartext you want to sign.\n<br><br>\nArguments: the ASCII-armoured private key of the signer (plus the private key password if necessary)\nand the ASCII-armoured PGP public key of the recipient.\n<br><br>\nThis operation uses PGP to produce an encrypted digital signature.\n<br><br>\nPretty Good Privacy is an encryption standard (OpenPGP) used for encrypting, decrypting, and signing messages.\n<br><br>\nThis function uses the Keybase implementation of PGP.";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [
|
||||
{
|
||||
"name": "Private key of signer",
|
||||
"type": "text",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "Private key passphrase",
|
||||
"type": "string",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "Public key of recipient",
|
||||
"type": "text",
|
||||
"value": ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async run(input, args) {
|
||||
const message = input,
|
||||
privateKey = args[0],
|
||||
passphrase = args[1],
|
||||
publicKey = args[2];
|
||||
let signedMessage;
|
||||
|
||||
if (!privateKey) return "Enter the private key of the signer.";
|
||||
if (!publicKey) return "Enter the public key of the recipient.";
|
||||
const privKey = await importPrivateKey(privateKey, passphrase);
|
||||
const pubKey = await importPublicKey(publicKey);
|
||||
|
||||
try {
|
||||
signedMessage = await promisify(kbpgp.box)({
|
||||
"msg": message,
|
||||
"encrypt_for": pubKey,
|
||||
"sign_with": privKey,
|
||||
"asp": ASP
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Couldn't sign message: ${err}`;
|
||||
}
|
||||
|
||||
return signedMessage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default PGPEncryptAndSign;
|
Loading…
Add table
Add a link
Reference in a new issue