Skip to content

Commit 7cc374b

Browse files
committed
src: replace impossible THROW_... with CHECK_...
The JS layer already verifies that divisor_bits is either a non-negative 32-bit signed integer or null/undefined, in which case it passes -1 to the C++ layer. In either case, the C++ layer receives a 32-bit signed integer greater than or equal to -1.
1 parent fbd526b commit 7cc374b

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/crypto/crypto_dsa.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ Maybe<bool> DsaKeyGenTraits::AdditionalConfig(
8989

9090
params->params.modulus_bits = args[*offset].As<Uint32>()->Value();
9191
params->params.divisor_bits = args[*offset + 1].As<Int32>()->Value();
92-
if (params->params.divisor_bits < -1) {
93-
THROW_ERR_OUT_OF_RANGE(env, "invalid value for divisor_bits");
94-
return Nothing<bool>();
95-
}
92+
CHECK_GE(params->params.divisor_bits, -1);
9693

9794
*offset += 2;
9895

test/parallel/test-crypto-keygen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher);
12781278
}
12791279

12801280
// Test invalid divisor lengths. (out of range)
1281-
for (const divisorLength of [-6, -9, 2147483648]) {
1281+
for (const divisorLength of [-1, -6, -9, 2147483648]) {
12821282
assert.throws(() => generateKeyPair('dsa', {
12831283
modulusLength: 2048,
12841284
divisorLength

0 commit comments

Comments
 (0)