From adb3d49e2b30a26e23e8cb580b5389d8b88de5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 24 May 2023 19:45:40 +0200 Subject: [PATCH] src: remove INT_MAX asserts in SecretKeyGenTraits Now that CSPRNG() does not silently fail when the length exceeds INT_MAX anymore, there is no need for the two relevant assertions in SecretKeyGenTraits anymore. Refs: https://github.com/nodejs/node/pull/47515 PR-URL: https://github.com/nodejs/node/pull/48053 Reviewed-By: Luigi Pinca Reviewed-By: Filip Skokan --- src/crypto/crypto_keygen.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/crypto/crypto_keygen.cc b/src/crypto/crypto_keygen.cc index 64e65901ac5d67..b36f908a0b5a62 100644 --- a/src/crypto/crypto_keygen.cc +++ b/src/crypto/crypto_keygen.cc @@ -63,17 +63,13 @@ Maybe SecretKeyGenTraits::AdditionalConfig( SecretKeyGenConfig* params) { CHECK(args[*offset]->IsUint32()); uint32_t bits = args[*offset].As()->Value(); - static_assert(std::numeric_limits::max() / CHAR_BIT <= - INT_MAX); params->length = bits / CHAR_BIT; *offset += 1; return Just(true); } -KeyGenJobStatus SecretKeyGenTraits::DoKeyGen( - Environment* env, - SecretKeyGenConfig* params) { - CHECK_LE(params->length, INT_MAX); +KeyGenJobStatus SecretKeyGenTraits::DoKeyGen(Environment* env, + SecretKeyGenConfig* params) { ByteSource::Builder bytes(params->length); if (CSPRNG(bytes.data(), params->length).is_err()) return KeyGenJobStatus::FAILED;