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 <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Tobias Nießen authored and GitHub committed 2023-05-24 17:45:40 +00:00
1 parent 6599cfeb04
commit c3b84f1f33
1 file changed
+2 -6
+2 -6
View File
@@ -63,17 +63,13 @@ Maybe<bool> SecretKeyGenTraits::AdditionalConfig(
SecretKeyGenConfig* params) {
CHECK(args[*offset]->IsUint32());
uint32_t bits = args[*offset].As<Uint32>()->Value();
static_assert(std::numeric_limits<decltype(bits)>::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<unsigned char>(), params->length).is_err())
return KeyGenJobStatus::FAILED;