Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2022-09-03 02:48:27 +0300
committerGitHub <noreply@github.com>2022-09-03 02:48:27 +0300
commit4b17d8838ab979defd99e12c2d1c7f261a6219ee (patch)
treeb24639b2224af8aa6c498d0b5ac8c463a22e3753 /src
parent729ce827fb2ee148dd83b6394cdde03cb979e241 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/crypto/crypto_hkdf.cc2
-rw-r--r--src/crypto/crypto_hmac.cc5
-rw-r--r--src/crypto/crypto_rsa.cc2
-rw-r--r--src/crypto/crypto_sig.cc2
4 files changed, 6 insertions, 5 deletions
diff --git a/src/crypto/crypto_hkdf.cc b/src/crypto/crypto_hkdf.cc
index 081a930e69f..43bf8a93505 100644
--- a/src/crypto/crypto_hkdf.cc
+++ b/src/crypto/crypto_hkdf.cc
@@ -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>();
}
diff --git a/src/crypto/crypto_hmac.cc b/src/crypto/crypto_hmac.cc
index 2e1c97ce480..ed78e21f118 100644
--- a/src/crypto/crypto_hmac.cc
+++ b/src/crypto/crypto_hmac.cc
@@ -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>();
}
diff --git a/src/crypto/crypto_rsa.cc b/src/crypto/crypto_rsa.cc
index e55c9555305..ec339e5635d 100644
--- a/src/crypto/crypto_rsa.cc
+++ b/src/crypto/crypto_rsa.cc
@@ -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>();
}
diff --git a/src/crypto/crypto_sig.cc b/src/crypto/crypto_sig.cc
index 72f98788d17..92188911b35 100644
--- a/src/crypto/crypto_sig.cc
+++ b/src/crypto/crypto_sig.cc
@@ -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>();
}
}