Fix error message for legacy encrypted private keys
This commit is contained in:
parent
c6ed05d2c3
commit
2131fb0978
|
@ -324,7 +324,7 @@ async function produceEncryptionKey(s2k, passphrase, algorithm) {
|
||||||
* @async
|
* @async
|
||||||
*/
|
*/
|
||||||
SecretKey.prototype.decrypt = async function (passphrase) {
|
SecretKey.prototype.decrypt = async function (passphrase) {
|
||||||
if (this.s2k.type === 'gnu-dummy') {
|
if (this.s2k && this.s2k.type === 'gnu-dummy') {
|
||||||
this.isEncrypted = false;
|
this.isEncrypted = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +336,10 @@ SecretKey.prototype.decrypt = async function (passphrase) {
|
||||||
let key;
|
let key;
|
||||||
if (this.s2k_usage === 254 || this.s2k_usage === 253) {
|
if (this.s2k_usage === 254 || this.s2k_usage === 253) {
|
||||||
key = await produceEncryptionKey(this.s2k, passphrase, this.symmetric);
|
key = await produceEncryptionKey(this.s2k, passphrase, this.symmetric);
|
||||||
|
} else if (this.s2k_usage === 255) {
|
||||||
|
throw new Error('Encrypted private key is authenticated using an insecure two-byte hash');
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Unsupported legacy encrypted key');
|
throw new Error('Private key is encrypted using an insecure S2K function: unsalted MD5');
|
||||||
}
|
}
|
||||||
|
|
||||||
let cleartext;
|
let cleartext;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user