mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
crypto: fix and simplify prime option validation
PR-URL: https://github.com/nodejs/node/pull/37164 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
dc38dd2c6f
commit
9dac99a11a
2 files changed
+56
-67
No files matched your search
@@ -71,6 +71,28 @@ const pCheckPrime = promisify(checkPrime);
|
||||
});
|
||||
});
|
||||
|
||||
{
|
||||
// Negative BigInts should not be converted to 0 silently.
|
||||
|
||||
assert.throws(() => generatePrime(20, { add: -1n }, common.mustNotCall()), {
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
message: 'The value of "options.add" is out of range. It must be >= 0. ' +
|
||||
'Received -1n'
|
||||
});
|
||||
|
||||
assert.throws(() => generatePrime(20, { rem: -1n }, common.mustNotCall()), {
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
message: 'The value of "options.rem" is out of range. It must be >= 0. ' +
|
||||
'Received -1n'
|
||||
});
|
||||
|
||||
assert.throws(() => checkPrime(-1n, common.mustNotCall()), {
|
||||
code: 'ERR_OUT_OF_RANGE',
|
||||
message: 'The value of "candidate" is out of range. It must be >= 0. ' +
|
||||
'Received -1n'
|
||||
});
|
||||
}
|
||||
|
||||
generatePrime(80, common.mustSucceed((prime) => {
|
||||
assert(checkPrimeSync(prime));
|
||||
checkPrime(prime, common.mustSucceed((result) => {
|
||||
|
||||
Reference in new issue
Block a user