From 889e0c4930432203464e76342c0ba3e8c69d914c Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 24 Jan 2020 16:34:49 +0100 Subject: [PATCH] Allow calling clearPrivateParams on decrypted keys Calling it on unencrypted keys was already allowed, so this safety check didn't do much. --- src/packet/secret_key.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/packet/secret_key.js b/src/packet/secret_key.js index 20dc27ef..263f185b 100644 --- a/src/packet/secret_key.js +++ b/src/packet/secret_key.js @@ -379,7 +379,7 @@ SecretKey.prototype.generate = async function (bits, curve) { }; /** - * Clear private params, return to initial state + * Clear private key parameters */ SecretKey.prototype.clearPrivateParams = function () { if (this.s2k && this.s2k.type === 'gnu-dummy') { @@ -387,9 +387,6 @@ SecretKey.prototype.clearPrivateParams = function () { return; } - if (!this.keyMaterial) { - throw new Error('If secret key is not encrypted, clearing private params is irreversible.'); - } const algo = enums.write(enums.publicKey, this.algorithm); this.params = this.params.slice(0, crypto.getPubKeyParamTypes(algo).length); this.isEncrypted = true;