From 7cc374b1b6a633af2c68bd7eb16f15848a38bdf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Mon, 20 Mar 2023 02:19:49 +0000 Subject: [PATCH] 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. --- src/crypto/crypto_dsa.cc | 5 +---- test/parallel/test-crypto-keygen.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/crypto/crypto_dsa.cc b/src/crypto/crypto_dsa.cc index 6839283fbf4ca7..dce1f93f4c20d5 100644 --- a/src/crypto/crypto_dsa.cc +++ b/src/crypto/crypto_dsa.cc @@ -89,10 +89,7 @@ Maybe DsaKeyGenTraits::AdditionalConfig( params->params.modulus_bits = args[*offset].As()->Value(); params->params.divisor_bits = args[*offset + 1].As()->Value(); - if (params->params.divisor_bits < -1) { - THROW_ERR_OUT_OF_RANGE(env, "invalid value for divisor_bits"); - return Nothing(); - } + CHECK_GE(params->params.divisor_bits, -1); *offset += 2; diff --git a/test/parallel/test-crypto-keygen.js b/test/parallel/test-crypto-keygen.js index 1a77266b057041..df8c5d93a90342 100644 --- a/test/parallel/test-crypto-keygen.js +++ b/test/parallel/test-crypto-keygen.js @@ -1278,7 +1278,7 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); } // Test invalid divisor lengths. (out of range) - for (const divisorLength of [-6, -9, 2147483648]) { + for (const divisorLength of [-1, -6, -9, 2147483648]) { assert.throws(() => generateKeyPair('dsa', { modulusLength: 2048, divisorLength