Don't ask user for private key backup password, because it won't be used

This commit is contained in:
Skylar Ittner 2021-07-20 15:32:29 -06:00
parent 8efb4dd8fe
commit f114febad3
2 changed files with 18 additions and 36 deletions

View File

@ -202,45 +202,27 @@ function exportPublicKey() {
}); });
} }
/**
* This should be modified to prompt the user for a backup password,
* but that doesn't work. https://github.com/keybase/kbpgp/issues/211
* @returns {undefined}
*/
function exportPrivateKey() { function exportPrivateKey() {
showPasswordPrompt("Enter password for private key:", function (pass) { loadKeyFromLocalStorage(function (message, ok) {
const savepriv = function (key) { if (!ok) {
showPasswordPrompt("Enter a password to protect the key backup:", function (pass2) { showAlert("Error: " + message);
openSaveFileDialog(function (path) { return;
key.export_pgp_private({
passphrase: pass2
}, function (err, pgp_private) {
if (err) {
showAlert("Something went wrong.");
} else {
writeToFile(path, pgp_private);
}
});
}, "private-key.asc", ".asc");
});
} }
kbpgp.KeyManager.import_from_armored_pgp({ openSaveFileDialog(function (path) {
armored: getStorage("signingkey") keymgr.export_pgp_private({}, function (err, pgp_private) {
}, function (err, key) { if (err) {
if (!err) { showAlert("Something went wrong.");
if (key.is_pgp_locked()) {
key.unlock_pgp({
passphrase: pass
}, function (err) {
if (!err) {
savepriv(key);
} else {
showAlert("Could not unlock key. Password is probably incorrect.");
}
});
} else { } else {
console.log("Loaded private key w/o passphrase"); writeToFile(path, pgp_private);
savepriv(key); showAlert("Private key backup saved.");
} }
} else { });
showAlert("Could not unlock key: " + err); }, "private-key.asc", ".asc");
}
});
}); });
} }

View File

@ -255,7 +255,7 @@ $("#passwordModal").on("shown.bs.modal", function () {
$("#passwordModalInput").focus(); $("#passwordModalInput").focus();
}); });
$(".modal").on("keydown", function (e) { $(".modal.show").on("keydown", function (e) {
if (e.keyCode == 13) { if (e.keyCode == 13) {
$(this).find(".btn-default").first().click(); $(this).find(".btn-default").first().click();
} }