Last active
February 10, 2017 12:43
-
-
Save sorpaas/9e2f9056ced56b1f583bbdc63050b50c to your computer and use it in GitHub Desktop.
Decrypting GPG Messages Using Subkeys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var openpgp = require("openpgp"); | |
var fs = require("fs"); | |
var key = fs.readFileSync("<armored key file>", "utf8"); | |
var skey = openpgp.key.readArmored(key).keys[0]; | |
skey.decrypt("<key password>"); | |
var message = fs.readFileSync("<armored message>", "utf8"); | |
var m = openpgp.message.readArmored(message); | |
var options = { | |
message: m, | |
privateKey: skey | |
}; | |
openpgp.decrypt(options).then(function(plaintext) { | |
console.log(plaintext); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/key.js b/src/key.js | |
index 5669188..e0e66b9 100644 | |
--- a/src/key.js | |
+++ b/src/key.js | |
@@ -49,9 +49,6 @@ export function Key(packetlist) { | |
this.users = null; | |
this.subKeys = null; | |
this.packetlist2structure(packetlist); | |
- if (!this.primaryKey || !this.users) { | |
- throw new Error('Invalid key: need at least key and user ID packet'); | |
- } | |
} | |
/** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment