public class DSAKeyPairGenerator
extends java.security.KeyPairGenerator
implements java.security.interfaces.DSAKeyPairGenerator
Valid length for the modulus is any multiple of 64 in the range
of 512 to 1024, 2048 or 3072. If the modulus length is greater
than 3072 a SHA2withDSAKeyPairGenerator
is used.
This class contains precalculated public DSA parameters for modulus lengths of 512, 768, 1024 bits, and 2048 and 3072 bits (by SHA2withDSAKeyPairGenerator).
To create a DSA key pair, a KeyPairGenerator has to be instantiated,
properly initialized and directed to actually generate the keys by calling
the generateKeyPair()
method. If the generator is not initialized
by explicitly calling an initialize
method, the modulus length
is set to 2048 bits.
Generating DSA keys using a modulus length of, e.g. 1024 bits (explicitly initialized), may be done by:
KeyPairGenerator key_gen = KeyPairGenerator.getIntance("DSA", "IAIK"); key_gen.initialize(1024); KeyPair key_pair = key_gen.generateKeyPair();
KeyPairGenerator
,
KeyPair
,
DSA
,
RawDSA
,
DSAPublicKey
,
DSAPrivateKey
,
DSAKeyFactory
,
DSAParams
Constructor and Description |
---|
DSAKeyPairGenerator()
Default constructor for creating a DSAKeyPairGenerator object.
|
DSAKeyPairGenerator(java.lang.String name)
Creates a DSAKeyPairGenerator with the given name.
|
Modifier and Type | Method and Description |
---|---|
java.security.KeyPair |
generateKeyPair()
Actually generates the requested KeyPair.
|
void |
initialize(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes this DSAKeyPairGenerator with given DSAParameterSpec and random seed.
|
void |
initialize(java.security.interfaces.DSAParams params,
java.security.SecureRandom random)
Initializes this DSAKeyPairGenerator with given DSA parameters and random seed.
|
void |
initialize(int strength)
Initializes this DSAKeyPairGenerator for given prime modulus length.
|
void |
initialize(int modlen,
boolean genParams,
java.security.SecureRandom random)
Initializes this DSAKeyPairGenerator for given modulus length with the given random seed.
|
void |
initialize(int strength,
java.security.SecureRandom random)
Initializes this DSAKeyPairGenerator for given modulus length with the given random seed.
|
public DSAKeyPairGenerator()
public DSAKeyPairGenerator(java.lang.String name)
name
- the name of the KeyPairGeneratorpublic void initialize(int strength)
initialize
in class java.security.KeyPairGenerator
strength
- the length of the modulus (any multiple of 64 in the range
of 512 to 1024, or 2048 or 3072)public void initialize(int strength, java.security.SecureRandom random)
initialize
in class java.security.KeyPairGenerator
strength
- the length of the modulus (any multiple of 64 in the range
of 512 to 1024, or 2048 or 3072)random
- the random seed as SecureRandompublic void initialize(int modlen, boolean genParams, java.security.SecureRandom random) throws java.security.InvalidParameterException
genParams
is set to false
), or by generating new DSA parameter
values (when genParams
is set to true
). Precomputed parameters are
available for modulus length of either 512, 768, 1024 bits, or 2048 or 3072 bits).initialize
in interface java.security.interfaces.DSAKeyPairGenerator
modlen
- the length of the modulus in bits (512, 768, or 1024, 2048 or 3072)genParams
- true
for generating new parameters, false
for using
precomputed values for p, q and grandom
- the random seed as SecureRandomjava.security.InvalidParameterException
- if the given modulus length is not a multiple of 64 between
512 and 1024, or 2048 or 3072public void initialize(java.security.interfaces.DSAParams params, java.security.SecureRandom random) throws java.security.InvalidParameterException
initialize
in interface java.security.interfaces.DSAKeyPairGenerator
params
- the DSAParams representing prime p
, sub-prime q
,
and base g
random
- the random seed as SecureRandomjava.security.InvalidParameterException
- if the given parameters to not match to DSAParamspublic void initialize(java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random) throws java.security.InvalidAlgorithmParameterException
initialize
in class java.security.KeyPairGenerator
params
- the DSAParamaterSpec representing p, q and g for initializing this generatorrandom
- the random seed as SecureRandomjava.security.InvalidAlgorithmParameterException
- if the given parameter specification is not a DSAParameterSpecpublic java.security.KeyPair generateKeyPair()
generateKeyPair
in class java.security.KeyPairGenerator