|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.math.Primes
Utility methods for generating primes and testing for primality.
Nested Class Summary | |
static class |
Primes.MROutput
Used to return the output from the Enhanced Miller-Rabin Probabilistic Primality Test |
static class |
Primes.STOutput
Used to return the output from the Shawe-Taylor Random_Prime Routine |
Field Summary | |
static int |
SMALL_FACTOR_LIMIT
|
Constructor Summary | |
Primes()
|
Method Summary | |
static Primes.MROutput |
enhancedMRProbablePrimeTest(java.math.BigInteger candidate,
java.security.SecureRandom random,
int iterations)
FIPS 186-4 C.3.2 Enhanced Miller-Rabin Probabilistic Primality Test Run several iterations of the Miller-Rabin algorithm with randomly-chosen bases. |
static Primes.STOutput |
generateSTRandomPrime(Digest hash,
int length,
byte[] inputSeed)
FIPS 186-4 C.6 Shawe-Taylor Random_Prime Routine Construct a provable prime number using a hash function. |
static boolean |
hasAnySmallFactors(java.math.BigInteger candidate)
A fast check for small divisors, up to some implementation-specific limit. |
static boolean |
isMRProbablePrime(java.math.BigInteger candidate,
java.security.SecureRandom random,
int iterations)
FIPS 186-4 C.3.1 Miller-Rabin Probabilistic Primality Test Run several iterations of the Miller-Rabin algorithm with randomly-chosen bases. |
static boolean |
isMRProbablePrimeToBase(java.math.BigInteger candidate,
java.math.BigInteger base)
FIPS 186-4 C.3.1 Miller-Rabin Probabilistic Primality Test (to a fixed base). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SMALL_FACTOR_LIMIT
Constructor Detail |
public Primes()
Method Detail |
public static Primes.STOutput generateSTRandomPrime(Digest hash, int length, byte[] inputSeed)
hash
- the Digest
instance to use (as "Hash()"). Cannot be null.length
- the length (in bits) of the prime to be generated. Must be at least 2.inputSeed
- the seed to be used for the generation of the requested prime. Cannot be null or
empty.
Primes.STOutput
instance containing the requested prime.public static Primes.MROutput enhancedMRProbablePrimeTest(java.math.BigInteger candidate, java.security.SecureRandom random, int iterations)
isMRProbablePrime(BigInteger, SecureRandom, int)
that provides more
information about a composite candidate, which may be useful when generating or validating
RSA moduli.
candidate
- the BigInteger
instance to test for primality.random
- the source of randomness to use to choose bases.iterations
- the number of randomly-chosen bases to perform the test for.
Primes.MROutput
instance that can be further queried for details.public static boolean hasAnySmallFactors(java.math.BigInteger candidate)
candidate
- the BigInteger
instance to test for division by small factors.
public static boolean isMRProbablePrime(java.math.BigInteger candidate, java.security.SecureRandom random, int iterations)
candidate
- the BigInteger
instance to test for primality.random
- the source of randomness to use to choose bases.iterations
- the number of randomly-chosen bases to perform the test for.
public static boolean isMRProbablePrimeToBase(java.math.BigInteger candidate, java.math.BigInteger base)
candidate
- the BigInteger
instance to test for primality.base
- the base value to use for this iteration.
|
Bouncy Castle Cryptography Library 1.81 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |