mirror of
https://github.com/gchq/CyberChef.git
synced 2024-11-02 14:11:02 +01:00
Added passphrase support to importing private key
This commit is contained in:
parent
f07263ca2a
commit
6a67fe09de
File diff suppressed because it is too large
Load Diff
@ -162,15 +162,25 @@ const PGP = {
|
||||
|
||||
async runDecrypt(input, args) {
|
||||
let encryptedMessage = input,
|
||||
plainPrivateKey = args[0],
|
||||
privateKey = args[0],
|
||||
passphrase = args[1],
|
||||
keyring = new kbpgp.keyring.KeyRing();
|
||||
|
||||
let key, plaintextMessage;
|
||||
|
||||
try {
|
||||
key = await promisify(kbpgp.KeyManager.import_from_armored_pgp)({
|
||||
armored: plainPrivateKey,
|
||||
armored: privateKey,
|
||||
});
|
||||
if (key.is_pgp_locked() && passphrase) {
|
||||
if (passphrase) {
|
||||
await promisify(key.unlock_pgp, key)({
|
||||
passphrase
|
||||
});
|
||||
} else if (!passphrase) {
|
||||
throw "Did not provide passphrase with locked private key.";
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
throw `Could not import private key: ${err}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user