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
72
src/core/operations/PGPEncrypt.mjs
Normal file
72
src/core/operations/PGPEncrypt.mjs
Normal file
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* @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 } from "../lib/PGP";
|
||||
/**
|
||||
* PGP Encrypt operation
|
||||
*/
|
||||
class PGPEncrypt extends Operation {
|
||||
|
||||
/**
|
||||
* PGPEncrypt constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "PGP Encrypt";
|
||||
this.module = "PGP";
|
||||
this.description = "Input: the message you want to encrypt.\n<br><br>\nArguments: the ASCII-armoured PGP public key of the recipient.\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": "Public key of recipient",
|
||||
"type": "text",
|
||||
"value": ""
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
async run(input, args) {
|
||||
const plaintextMessage = input,
|
||||
plainPubKey = args[0];
|
||||
let key,
|
||||
encryptedMessage;
|
||||
|
||||
if (!plainPubKey) return "Enter the public key of the recipient.";
|
||||
|
||||
try {
|
||||
key = await promisify(kbpgp.KeyManager.import_from_armored_pgp)({
|
||||
armored: plainPubKey,
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Could not import public key: ${err}`;
|
||||
}
|
||||
|
||||
try {
|
||||
encryptedMessage = await promisify(kbpgp.box)({
|
||||
"msg": plaintextMessage,
|
||||
"encrypt_for": key,
|
||||
"asp": ASP
|
||||
});
|
||||
} catch (err) {
|
||||
throw `Couldn't encrypt message with provided public key: ${err}`;
|
||||
}
|
||||
|
||||
return encryptedMessage.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default PGPEncrypt;
|
Loading…
Add table
Add a link
Reference in a new issue