Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ce39bb

Browse filesBrowse 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
Copy full SHA for 3ce39bb

File tree

Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎src/crypto/crypto_hkdf.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_hkdf.cc
+4Lines changed: 4 additions & 0 deletions
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);
Collapse file

‎src/crypto/crypto_hkdf.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_hkdf.h
-2Lines changed: 0 additions & 2 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.