crypto: fix and simplify prime option validation
This commit fixes the handling of negative BigInt
s in the generatePrime
and generatePrimeSync
functions and adds tests for these cases.
Additionally, it extracts the logic to set up the RandomPrimeJob
to a new function to eliminate duplicate code.