mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2025-06-09 07:36:42 +00:00
Allow calling clearPrivateParams on decrypted keys
Calling it on unencrypted keys was already allowed, so this safety check didn't do much.
This commit is contained in:
parent
6ae6012786
commit
889e0c4930
@ -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 () {
|
SecretKey.prototype.clearPrivateParams = function () {
|
||||||
if (this.s2k && this.s2k.type === 'gnu-dummy') {
|
if (this.s2k && this.s2k.type === 'gnu-dummy') {
|
||||||
@ -387,9 +387,6 @@ SecretKey.prototype.clearPrivateParams = function () {
|
|||||||
return;
|
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);
|
const algo = enums.write(enums.publicKey, this.algorithm);
|
||||||
this.params = this.params.slice(0, crypto.getPubKeyParamTypes(algo).length);
|
this.params = this.params.slice(0, crypto.getPubKeyParamTypes(algo).length);
|
||||||
this.isEncrypted = true;
|
this.isEncrypted = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user