Try and fail to fix exported private key having old password no matter what is requested
This commit is contained in:
parent
0db3037450
commit
367daeca57
52
js/crypto.js
52
js/crypto.js
@ -43,11 +43,11 @@ function loadKeyFromLocalStorage(callback) {
|
||||
|
||||
function loadKeyFromLocalStorageWithUserFeedback() {
|
||||
loadKeyFromLocalStorage(function (msg, ok) {
|
||||
if (ok) {
|
||||
alert(msg);
|
||||
} else {
|
||||
alert("Error: " + msg);
|
||||
}
|
||||
if (ok) {
|
||||
alert(msg);
|
||||
} else {
|
||||
alert("Error: " + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -156,22 +156,41 @@ function exportPublicKey() {
|
||||
}
|
||||
|
||||
function exportPrivateKey() {
|
||||
loadKeyFromLocalStorage(function (message, ok) {
|
||||
if (ok) {
|
||||
var pass = prompt("Enter a password to protect the backup key:");
|
||||
openSaveFileDialog(function (path) {
|
||||
keymgr.export_pgp_private({
|
||||
var pass = prompt("Enter password for private key:");
|
||||
const savepriv = function (key) {
|
||||
var pass2 = prompt("Enter a password to protect the key backup:");
|
||||
openSaveFileDialog(function (path) {
|
||||
key.export_pgp_private({
|
||||
passphrase: pass2
|
||||
}, function (err, pgp_private) {
|
||||
if (err) {
|
||||
alert("Something went wrong.");
|
||||
} else {
|
||||
writeToFile(path, pgp_private);
|
||||
}
|
||||
});
|
||||
}, "private-key.asc", ".asc");
|
||||
}
|
||||
kbpgp.KeyManager.import_from_armored_pgp({
|
||||
armored: getStorage("signingkey")
|
||||
}, function (err, key) {
|
||||
if (!err) {
|
||||
if (key.is_pgp_locked()) {
|
||||
key.unlock_pgp({
|
||||
passphrase: pass
|
||||
}, function (err, pgp_private) {
|
||||
if (err) {
|
||||
alert("Something went wrong.");
|
||||
}, function (err) {
|
||||
if (!err) {
|
||||
savepriv(key);
|
||||
} else {
|
||||
writeToFile(path, pgp_private);
|
||||
alert("Could not unlock key. Password is probably incorrect.");
|
||||
}
|
||||
});
|
||||
}, "private-key.asc", ".asc");
|
||||
} else {
|
||||
console.log("Loaded private key w/o passphrase");
|
||||
savepriv(key);
|
||||
}
|
||||
} else {
|
||||
alert("Error: " + message);
|
||||
alert("Could not unlock key: " + err);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -182,6 +201,7 @@ function importPrivateKey() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
keymgr = null;
|
||||
openFileDialog(function (path) {
|
||||
var keyfile = getFileAsString(path);
|
||||
var pass = prompt("Enter password for imported key (password was set when exported):");
|
||||
|
Loading…
x
Reference in New Issue
Block a user