mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
crypto: add digest name to INVALID_DIGEST errors
We already do this in some places. This adds the digest name to remaining uses of ERR_CRYPTO_INVALID_DIGEST except for one occurrence in crypto_sig.cc that would require significant refactoring due to the unusual error handling there. PR-URL: https://github.com/nodejs/node/pull/44468 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
05006eddb2
commit
c868e36385
4 files changed
+6
-5
No files matched your search
@@ -58,7 +58,7 @@ Maybe<bool> HKDFTraits::AdditionalConfig(
|
||||
Utf8Value hash(env->isolate(), args[offset]);
|
||||
params->digest = EVP_get_digestbyname(*hash);
|
||||
if (params->digest == nullptr) {
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *hash);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,8 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
|
||||
|
||||
const EVP_MD* md = EVP_get_digestbyname(hash_type);
|
||||
if (md == nullptr)
|
||||
return THROW_ERR_CRYPTO_INVALID_DIGEST(env());
|
||||
return THROW_ERR_CRYPTO_INVALID_DIGEST(
|
||||
env(), "Invalid digest: %s", hash_type);
|
||||
if (key_len == 0) {
|
||||
key = "";
|
||||
}
|
||||
@@ -189,7 +190,7 @@ Maybe<bool> HmacTraits::AdditionalConfig(
|
||||
Utf8Value digest(env->isolate(), args[offset + 1]);
|
||||
params->digest = EVP_get_digestbyname(*digest);
|
||||
if (params->digest == nullptr) {
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ Maybe<bool> RSACipherTraits::AdditionalConfig(
|
||||
|
||||
params->digest = EVP_get_digestbyname(*digest);
|
||||
if (params->digest == nullptr) {
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
|
||||
|
||||
@@ -647,7 +647,7 @@ Maybe<bool> SignTraits::AdditionalConfig(
|
||||
Utf8Value digest(env->isolate(), args[offset + 6]);
|
||||
params->digest = EVP_get_digestbyname(*digest);
|
||||
if (params->digest == nullptr) {
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
|
||||
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
|
||||
return Nothing<bool>();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user