kbpgp
kbpgp copied to clipboard
Importing an armored private key results in export_public_armored exporting private key
If a pgp private key is imported directly it works correctly, but it appears to be written to publickey areas as well. This results in the private key being exposed when trying to access the publicKey. Here is a simple proof of concept:
var kbpgp = require('kbpgp');
kbpgp.KeyManager.generate_ecc({'userid' : 'test'}, function(err, km1) {
km1.sign({}, function(err) {
km1.export_pgp_private({}, function(err, privateArmored) {
//Will log out private key, as expected
console.log('privateArmored', privateArmored);
kbpgp.KeyManager.import_from_armored_pgp({armored: privateArmored}, function(err, km2) {
km2.sign({}, function(err) {
km2.export_pgp_public({}, function(err, publicArmored){
//Also logs out private key, which should not happen
console.log('publicArmored', publicArmored);
});
});
});
});
});
});
(bump) Came to report this same bug. Passing {regen:true} to the export_pgp_public options fixes the problem.
(bump)
Just to confirm this as a bug as well.
Thanks for the report, this one got lost in the shuffle. We'll take a look.
Taking a look, I see the bug. Working on a fix.
Closed in #143. Sorry for the bug and thanks for the bug report. It will go live in 2.0.67.
@maxtaco that was fast! Thanks!