Commit Graph

8 Commits

Author SHA1 Message Date
Tobias Nießen
e8697cfe38
crypto: improve prime size argument validation
The current validation in JavaScript is insufficient and also produces
an incorrect error message, restricting the size parameter to 32-bit
values, whereas the C++ backend restricts the size parameter to the
positive range of an int.

This change tightens the validation in JavaScript and adapts the error
message accordingly, making the validation in C++ superfluous.

Refs: https://github.com/nodejs/node/pull/42207

PR-URL: https://github.com/nodejs/node/pull/42234
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-03-08 17:33:38 +00:00
Tobias Nießen
f34f9f1f9d
test: cover 32-bit sizes in generatePrime
PR-URL: https://github.com/nodejs/node/pull/42207
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
2022-03-06 12:32:56 +00:00
Mohammed Keyvanzadeh
8c4b8b201a
lib: replace validator and error
Refs: https://github.com/nodejs/node/pull/41660

PR-URL: https://github.com/nodejs/node/pull/41678
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-02-05 08:36:48 -08:00
Tobias Nießen
6e804a9f1a test: only run prime test with supported OpenSSL
PR-URL: https://github.com/nodejs/node/pull/37212
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-08 16:48:49 -08:00
Tobias Nießen
11d20106ea crypto: avoid infinite loops in prime generation
PR-URL: https://github.com/nodejs/node/pull/37212
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-08 16:47:58 -08:00
Tobias Nießen
406984ec7c 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>
2021-02-06 08:56:13 -08:00
Tobias Nießen
814f97186f doc,test: fix prime generation description
The previous description incorrectly explained the behavior of
options.add and options.rem for primes that are not safe.

PR-URL: https://github.com/nodejs/node/pull/37085
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-02-01 16:14:36 +01:00
James M Snell
bb13469acb
crypto: add generatePrime/checkPrime
APIs for generating and checking pseudo-random primes

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/36997
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-01-26 07:37:18 -08:00