Allow private keys without passphrase in local browser storage as requested by #429

This commit is contained in:
the-djmaze 2022-08-08 09:26:45 +02:00
parent 2458a82031
commit 7a85a75ca9

View file

@ -178,16 +178,20 @@ export const OpenPGPUserStore = new class {
}
}
if (privateKey) try {
let decryptedKey;
if (privateKey.key.isDecrypted()) {
decryptedKey = privateKey;
} else {
const passphrase = await askPassphrase(privateKey, 'BUTTON_DECRYPT');
if (null !== passphrase) {
const
publicKey = findOpenPGPKey(this.publicKeys, sender/*, sign*/),
decryptedKey = await openpgp.decryptKey({
privateKey: privateKey.key,
passphrase
});
}
}
if (decryptedKey) {
const publicKey = findOpenPGPKey(this.publicKeys, sender/*, sign*/);
return await openpgp.decrypt({
message,
verificationKeys: publicKey && publicKey.key,