Throw when trying to encrypt a key that's already encrypted (#950)

This commit is contained in:
Daniel Huigens
2019-08-19 13:27:52 +02:00
committed by GitHub
parent d27060e508
commit a7cc71e35e
3 changed files with 16 additions and 0 deletions

View File

@@ -273,6 +273,10 @@ SecretKey.prototype.encrypt = async function (passphrase) {
return false;
}
if (!this.isDecrypted()) {
throw new Error('Key packet is already encrypted');
}
if (this.isDecrypted() && !passphrase) {
this.s2k_usage = 0;
return false;