mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
crypto: improve RSA-PSS digest error messages
md and mgf1_md are internal variable names and should not appear in JS error messages. Also include the invalid digest name in the error message. PR-URL: https://github.com/nodejs/node/pull/44307 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
@@ -153,7 +153,7 @@ Maybe<bool> RsaKeyGenTraits::AdditionalConfig(
|
||||
Utf8Value digest(env->isolate(), args[*offset]);
|
||||
params->params.md = EVP_get_digestbyname(*digest);
|
||||
if (params->params.md == nullptr) {
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "md specifies an invalid digest");
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
}
|
||||
@@ -163,8 +163,8 @@ Maybe<bool> RsaKeyGenTraits::AdditionalConfig(
|
||||
Utf8Value digest(env->isolate(), args[*offset + 1]);
|
||||
params->params.mgf1_md = EVP_get_digestbyname(*digest);
|
||||
if (params->params.mgf1_md == nullptr) {
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env,
|
||||
"mgf1_md specifies an invalid digest");
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(
|
||||
env, "Invalid MGF1 digest: %s", *digest);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1661,7 +1661,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
|
||||
}, common.mustNotCall()), {
|
||||
name: 'TypeError',
|
||||
code: 'ERR_CRYPTO_INVALID_DIGEST',
|
||||
message: 'md specifies an invalid digest'
|
||||
message: 'Invalid digest: sha2'
|
||||
});
|
||||
|
||||
assert.throws(() => generateKeyPair('rsa-pss', {
|
||||
@@ -1670,7 +1670,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
|
||||
}, common.mustNotCall()), {
|
||||
name: 'TypeError',
|
||||
code: 'ERR_CRYPTO_INVALID_DIGEST',
|
||||
message: 'mgf1_md specifies an invalid digest'
|
||||
message: 'Invalid MGF1 digest: sha2'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user