Top Description Fields Constructors Methods
org.bouncycastle.crypto.generators

public Class DSAParametersGenerator

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.security.SecureRandom, org.bouncycastle.crypto.Digest, org.bouncycastle.crypto.digests.SHA1Digest, org.bouncycastle.crypto.params.DSAParameterGenerationParameters, .DSAParameters, .DSAValidationParameters, org.bouncycastle.crypto.util.DigestFactory, org.bouncycastle.util.Arrays, .BigIntegers, org.bouncycastle.util.encoders.Hex

Generate suitable parameters for DSA, in line with FIPS 186-2, or FIPS 186-3.

Field Summary

Modifier and TypeField and Description
private int
private Digest
private int
private int
L

private int
N

private static final BigInteger
private SecureRandom
private static final BigInteger
private int
private boolean
private static final BigInteger

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private static BigInteger
private static BigInteger
private static BigInteger
public DSAParameters

Returns:

a generated DSA parameters object.
generateParameters
()

which generates the p and g values from the given parameters, returning the DSAParameters object.

private DSAParameters
private DSAParameters
generateParameters_FIPS186_3()

generate suitable parameters for DSA, in line with FIPS 186-3 A.1 Generation of the FFC Primes p and q.

private static int
getDefaultN(int L)

private static int
private static void
hash(Digest d, byte[] input, byte[] output, int outputPos)

private static void
inc(byte[] buf)

public void
init(int
size of the key (range 2^512 -> 2^1024 - 64 bit increments)
size
,
int
measure of robustness of prime (for FIPS 186-2 compliance this should be at least 80).
certainty
,
SecureRandom
random byte source.
random
)

initialise the key generator.

public void
init(DSAParameterGenerationParameters
DSA 2 key generation parameters.
params
)

Initialise the key generator for DSA 2.

private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

certaintyback to summary
private int certainty
digestback to summary
private Digest digest
iterationsback to summary
private int iterations
Lback to summary
private int L
Nback to summary
private int N
ONEback to summary
private static final BigInteger ONE
randomback to summary
private SecureRandom random
TWOback to summary
private static final BigInteger TWO
usageIndexback to summary
private int usageIndex
use186_3back to summary
private boolean use186_3
ZEROback to summary
private static final BigInteger ZERO

Constructor Detail

DSAParametersGeneratorback to summary
public DSAParametersGenerator()
DSAParametersGeneratorback to summary
public DSAParametersGenerator(Digest digest)

Method Detail

calculateGenerator_FIPS186_2back to summary
private static BigInteger calculateGenerator_FIPS186_2(BigInteger p, BigInteger q, SecureRandom r)
calculateGenerator_FIPS186_3_Unverifiableback to summary
private static BigInteger calculateGenerator_FIPS186_3_Unverifiable(BigInteger p, BigInteger q, SecureRandom r)
calculateGenerator_FIPS186_3_Verifiableback to summary
private static BigInteger calculateGenerator_FIPS186_3_Verifiable(Digest d, BigInteger p, BigInteger q, byte[] seed, int index)
generateParametersback to summary
public DSAParameters generateParameters()

which generates the p and g values from the given parameters, returning the DSAParameters object.

Note

can take a while...

Returns:DSAParameters

a generated DSA parameters object.

generateParameters_FIPS186_2back to summary
private DSAParameters generateParameters_FIPS186_2()
generateParameters_FIPS186_3back to summary
private DSAParameters generateParameters_FIPS186_3()

generate suitable parameters for DSA, in line with FIPS 186-3 A.1 Generation of the FFC Primes p and q.

getDefaultNback to summary
private static int getDefaultN(int L)
getMinimumIterationsback to summary
private static int getMinimumIterations(int L)
hashback to summary
private static void hash(Digest d, byte[] input, byte[] output, int outputPos)
incback to summary
private static void inc(byte[] buf)
initback to summary
public void init(int size, int certainty, SecureRandom random)

initialise the key generator.

Parameters
size:int

size of the key (range 2^512 -> 2^1024 - 64 bit increments)

certainty:int

measure of robustness of prime (for FIPS 186-2 compliance this should be at least 80).

random:SecureRandom

random byte source.

initback to summary
public void init(DSAParameterGenerationParameters params)

Initialise the key generator for DSA 2.

Use this init method if you need to generate parameters for DSA 2 keys.

Parameters
params:DSAParameterGenerationParameters

DSA 2 key generation parameters.

isProbablePrimeback to summary
private boolean isProbablePrime(BigInteger x)