public class PrimeGenerator
extends java.lang.Object
This class will either:
(1) Generate the primes according to Java's BigInteger prime generation methods, which satisfy ANSI X9.80
or
(2) Bolster Java BigInteger's prime generation to meet the requirements of NIST SP 800-56B ("Recommendation for Pair-Wise Key Establishment Schemes Using Integer Factorization Cryptography") and FIPS 186-4 ("Digital Signature Standard (DSS)") for key generation using probable primes.
Relevant page: SP 800-56B: p30 http://csrc.nist.gov/publications/nistpubs/800-56B/sp800-56B.pdf#page=30 Heading: 5.4 Prime Number Generators
Relevant pages FIPS 186-4: p50-p53, p55, p71: Sections B.3.1, B.3.3
http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf#page=61
http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf#page=80
Headings of most interest: Table C.2 "Minimum number of rounds of M-R testing when generating primes for use in RSA Digital Signatures" and "The primes p and q shall be selected with the following constraints"
Constructor and Description |
---|
PrimeGenerator() |
Modifier and Type | Method and Description |
---|---|
static java.math.BigInteger[] |
getPrimePair(int bitLength,
int certainty,
java.util.Random rnd)
This method returns a two-long array containing a viable RSA p and q meeting FIPS 186-4 and SP 800-56B
|
static java.math.BigInteger |
getSecondPrime(int bitLength,
int certainty,
java.util.Random rnd,
java.math.BigInteger p)
Method to generate a second prime, q, in relation to a (p,q) RSA key pair
|
static java.math.BigInteger |
getSinglePrime(int bitLength,
int certainty,
java.util.Random rnd)
Method to generate a single prime
|
public static java.math.BigInteger getSinglePrime(int bitLength, int certainty, java.util.Random rnd)
Will optionally ensure that the prime meets the requirements in NIST SP 800-56B and FIPS 186-4
NOTE: bitLength corresponds to the FIPS 186-4 nlen parameter
public static java.math.BigInteger getSecondPrime(int bitLength, int certainty, java.util.Random rnd, java.math.BigInteger p)
Will optionally ensure that the prime meets the requirements in NIST SP 800-56B and FIPS 186-4
NOTE: bitLength corresponds to the FIPS 186-4 nlen parameter
public static java.math.BigInteger[] getPrimePair(int bitLength, int certainty, java.util.Random rnd)