public abstract class SHA2withDSAParameterGenerator
extends java.security.AlgorithmParameterGeneratorSpi
This class represents a DSA parameter generator to be used with SHA-2 hash algorithms for generating DSA parameters p, q and g (prime modulus, prime divisor and generator, respectively) according to FIPS PUB 186-3, Digital Signature Standard (DSS), June 2009.
This generator may be
initialized
with
the desired prime modulus and prime divisor length (L and N, respectively).
Notice that FIPS 186-3 (June 2009) allows the following (L,N) pairs to may be
used:
If this generator is used without explicit initialization by default 2048 is used as the bit length of the prime modulus L. The default length of the prime divisor N is set to the output length of the hash algorithm (224 for SHA-224, and 256 for SHA-256).
For explictly specifying prime modulus and prime divisor length when
initializing
this
DSA parameter generator use a SHA2withDSAGenParameterSpec
object, e.g.:
int L = 3072; int N = 256; SHA2withDSAGenParameterSpec genParamSpec = new SHA2withDSAGenParameterSpec(L, N); AlgorithmParameterGenerator generator = AlgorithmParameterGenerator.getInstance("SHA256withDSA", "IAIK"); SecureRandom random = ...; generator.init(genParamSpec, random); AlgortithmParameters params = generator.generateParameters();
SHA2withDSAGenParameterSpec
,
SHA224withDSAParameterGenerator
,
SHA256withDSAParameterGenerator
Modifier and Type | Method and Description |
---|---|
protected java.security.AlgorithmParameters |
engineGenerateParameters()
Generates the DSA AlgorithmParameters.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec genParamSpec,
java.security.SecureRandom random)
Initializes this generator with given parameters and random seed.
|
protected void |
engineInit(int L,
java.security.SecureRandom random)
Initializes the parameter generator with given prime modulus length L and
random seed.
|
static void |
validateParameters(java.math.BigInteger p,
java.math.BigInteger q,
byte[] domainParamSeed,
int counter,
java.security.MessageDigest hashEngine,
int outlen)
Validates the given DSA parameters.
|
protected void engineInit(int L, java.security.SecureRandom random)
FIPS 186-3 (June 2009) allows the following prime modulus, prime divisor (L,N) pairs to may be used:
engineInit
in class java.security.AlgorithmParameterGeneratorSpi
L
- the length L of the prime modulus in bitsrandom
- the random seed for this generator.java.lang.IllegalArgumentException
- if the prime modulus length is not 1024, 2048 or 3072protected void engineInit(java.security.spec.AlgorithmParameterSpec genParamSpec, java.security.SecureRandom random) throws java.security.InvalidAlgorithmParameterException
Applications shall call init(genParamSpec, random)
for
provider independent initialization, e.g.:
int L = 3072; int N = 256; SHA2withDSAGenParameterSpec genParamSpec = new SHA2withDSAGenParameterSpec(L, N); AlgorithmParameterGenerator generator = AlgorithmParameterGenerator.getInstance("SHA256withDSA", "IAIK"); SecureRandom random = ...; generator.init(genParamSpec, random); AlgortithmParameters params = generator.generateParameters();
engineInit
in class java.security.AlgorithmParameterGeneratorSpi
genParamSpec
- the generation parameter specification; must be a
SHA2withDSAGenParameterSpec
random
- the random seed to be used by this generator.java.security.InvalidAlgorithmParameterException
- if the given parameter specification is not a
SHA2withDSAGenParameterSpec
, or the prime divisor length (N)
of the given parameter specification is greater than the
output length of the hash algorithm used by this generator
(i.e. N = 256 can be only used with SHA-256 but not with
SHA-224)protected java.security.AlgorithmParameters engineGenerateParameters()
Applications shall call generatePrameters()
for provider
independently accessing this method.
engineGenerateParameters
in class java.security.AlgorithmParameterGeneratorSpi
public static void validateParameters(java.math.BigInteger p, java.math.BigInteger q, byte[] domainParamSeed, int counter, java.security.MessageDigest hashEngine, int outlen) throws java.security.InvalidAlgorithmParameterException
p
- the prime modulus p.q
- the prime divisor q.domainParamSeed
- the domain parameter seed that has been used for parameter
generationcounter
- the final counter value form the parameter generation procedurehashEngine
- the MessageDigest engine to be usedoutlen
- the length (in bits) of the hash function output,java.security.InvalidAlgorithmParameterException
- if the parameter validation fails