Skip to content

Commit 3ce39bb

Browse files
tniessenjuanarbol
authored andcommitted
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 <info@bnoordhuis.nl> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent edcd4fc commit 3ce39bb

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)