Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c7abebf

Browse files
tniessenjuanarbol
authored andcommittedJan 26, 2023
src: hide kMaxDigestMultiplier outside HKDF impl
There is no reason to expose this constant outside of the HKDF implementation, especially with such a generic name. PR-URL: #46206 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 6ccf192 commit c7abebf

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎src/crypto/crypto_hkdf.cc

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ Maybe<bool> HKDFTraits::AdditionalConfig(
8787
: info.ToByteSource();
8888

8989
params->length = args[offset + 4].As<Uint32>()->Value();
90+
// HKDF-Expand computes up to 255 HMAC blocks, each having as many bits as the
91+
// output of the hash function. 255 is a hard limit because HKDF appends an
92+
// 8-bit counter to each HMAC'd message, starting at 1.
93+
constexpr size_t kMaxDigestMultiplier = 255;
9094
size_t max_length = EVP_MD_size(params->digest) * kMaxDigestMultiplier;
9195
if (params->length > max_length) {
9296
THROW_ERR_CRYPTO_INVALID_KEYLEN(env);

‎src/crypto/crypto_hkdf.h

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace node {
1313
namespace crypto {
14-
static constexpr size_t kMaxDigestMultiplier = 255;
15-
1614
struct HKDFConfig final : public MemoryRetainer {
1715
CryptoJobMode mode;
1816
size_t length;

0 commit comments

Comments
 (0)
Please sign in to comment.