Skip to content

Commit c868e36

Browse files
tniessenRafaelGSS
authored andcommitted
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: #44468 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 05006ed commit c868e36

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

src/crypto/crypto_hkdf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Maybe<bool> HKDFTraits::AdditionalConfig(
5858
Utf8Value hash(env->isolate(), args[offset]);
5959
params->digest = EVP_get_digestbyname(*hash);
6060
if (params->digest == nullptr) {
61-
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
61+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *hash);
6262
return Nothing<bool>();
6363
}
6464

src/crypto/crypto_hmac.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ void Hmac::HmacInit(const char* hash_type, const char* key, int key_len) {
7272

7373
const EVP_MD* md = EVP_get_digestbyname(hash_type);
7474
if (md == nullptr)
75-
return THROW_ERR_CRYPTO_INVALID_DIGEST(env());
75+
return THROW_ERR_CRYPTO_INVALID_DIGEST(
76+
env(), "Invalid digest: %s", hash_type);
7677
if (key_len == 0) {
7778
key = "";
7879
}
@@ -189,7 +190,7 @@ Maybe<bool> HmacTraits::AdditionalConfig(
189190
Utf8Value digest(env->isolate(), args[offset + 1]);
190191
params->digest = EVP_get_digestbyname(*digest);
191192
if (params->digest == nullptr) {
192-
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
193+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
193194
return Nothing<bool>();
194195
}
195196

src/crypto/crypto_rsa.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ Maybe<bool> RSACipherTraits::AdditionalConfig(
328328

329329
params->digest = EVP_get_digestbyname(*digest);
330330
if (params->digest == nullptr) {
331-
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
331+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
332332
return Nothing<bool>();
333333
}
334334

src/crypto/crypto_sig.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ Maybe<bool> SignTraits::AdditionalConfig(
647647
Utf8Value digest(env->isolate(), args[offset + 6]);
648648
params->digest = EVP_get_digestbyname(*digest);
649649
if (params->digest == nullptr) {
650-
THROW_ERR_CRYPTO_INVALID_DIGEST(env);
650+
THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *digest);
651651
return Nothing<bool>();
652652
}
653653
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy