crypto: remove INT_MAX restriction in randomBytes

This restriction was due to an implementation detail in CSPRNG(). Now
that CSPRNG() properly handles lengths exceeding INT_MAX, remove this
artificial restriction.

Refs: https://github.com/nodejs/node/pull/47515
PR-URL: https://github.com/nodejs/node/pull/47559
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Tobias Nießen authored and GitHub committed 2023-04-17 17:26:02 +00:00
1 parent e050cecad1
commit b342a1b565
1 file changed
-6
-6
View File
@@ -39,7 +39,6 @@ Maybe<bool> RandomBytesTraits::AdditionalConfig(
const FunctionCallbackInfo<Value>& args,
unsigned int offset,
RandomBytesConfig* params) {
Environment* env = Environment::GetCurrent(args);
CHECK(IsAnyByteSource(args[offset])); // Buffer to fill
CHECK(args[offset + 1]->IsUint32()); // Offset
CHECK(args[offset + 2]->IsUint32()); // Size
@@ -51,11 +50,6 @@ Maybe<bool> RandomBytesTraits::AdditionalConfig(
CHECK_GE(byte_offset + size, byte_offset); // Overflow check.
CHECK_LE(byte_offset + size, in.size()); // Bounds check.
if (UNLIKELY(size > INT_MAX)) {
THROW_ERR_OUT_OF_RANGE(env, "buffer is too large");
return Nothing<bool>();
}
params->buffer = in.data() + byte_offset;
params->size = size;