From 68d71970dc267878d9c67ce9e7e64446cd22dc7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 17 May 2023 23:59:24 +0000 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 --- 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;