|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.security.KeyPairGeneratorSpi | +--java.security.KeyPairGenerator | +--iaik.security.dsa.DSAKeyPairGenerator
Key pair generator for DSA keys as specified in FIPS PUB 186.
Valid length for the modulus is any multiple of 64 in the range of 512 to 1024.
This class contains precalculated public DSA parameters for modulus lengths of 512, 768, and 1024 bits. For other key lengths the parameters have to be calculated first, which is extremely slow (usually several minutes, depending on your luck and machine speed). However, when DSA parameters are available, key generation is very fast, therefore I recommend to stay with 512, 768, or 1024 bits.
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 1024 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"); key_gen.initialize(1024, sec_random); KeyPair key_pair = key_gen.generateKeyPair();
The example above initializes the key pair generator algorithm-independent by only specifying the length of the modulus. For performing an algorithm-specific initialization, an explicit cast to DSAKeyPairGenerator would be necessary:
DSAKeyPairGenerator dsa_key_gen = (DSAKeyPairGenerator)key_gen; dsa_key_gen.initialize(dsa_params, sec_random);
Guidelines on how to create some key using a KeyPairGenerator can be found in http://java.sun.com/products/JDK/1.1/docs/guide/security/CryptoSpec.html.
KeyPairGenerator
,
KeyPair
,
DSA
,
RawDSA
,
DSAPublicKey
,
DSAPrivateKey
,
DSAKeyFactory
,
DSAParams
Constructor Summary | |
DSAKeyPairGenerator()
Default constructor for creating a DSAKeyPairGenerator object. |
Method Summary | |
KeyPair |
generateKeyPair()
Actually generates the requested KeyPair. |
void |
initialize(AlgorithmParameterSpec params,
SecureRandom random)
Initializes this DSAKeyPairGenerator with given DSAParameterSpec and random seed. |
void |
initialize(DSAParams params,
SecureRandom random)
Initializes this DSAKeyPairGenerator with given DSA parameters and random seed. |
void |
initialize(int strength)
Initializes this DSAKeyPairGenerator for given modulus length. |
void |
initialize(int modlen,
boolean genParams,
SecureRandom random)
Initializes this DSAKeyPairGenerator for given modulus length with the given random seed. |
void |
initialize(int strength,
SecureRandom random)
Initializes this DSAKeyPairGenerator for given modulus length with the given random seed. |
Methods inherited from class java.security.KeyPairGenerator |
genKeyPair, getAlgorithm, getInstance, getInstance, getProvider, initialize |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DSAKeyPairGenerator()
Method Detail |
public void initialize(int strength)
initialize
in class KeyPairGenerator
public void initialize(int strength, SecureRandom random)
initialize
in class KeyPairGenerator
strength
- the length of the modulus (any multiple of 64 in the range
of 512 to 1024)random
- the random seed as SecureRandompublic void initialize(DSAParams params, SecureRandom random) throws InvalidParameterException
initialize
in interface DSAKeyPairGenerator
params
- the DSAParams representing prime p
, sub-prime q
,
and base g
random
- the random seed as SecureRandomInvalidParameterException
- if the given parameters to not match to DSAParamspublic void initialize(int modlen, boolean genParams, SecureRandom random) throws 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, or 1024 bits.initialize
in interface DSAKeyPairGenerator
modlen
- the length of the modulus in bits (512, 768, or 1024)genParams
- true
for generating new parameters, false
for using
precomputed values for p, q and grandom
- the random seed as SecureRandomInvalidParameterException
- if the given modulus length is not a multiple of 64 between
512 and 1024 when genParms
= true
;
or the given modulus length is not 512, 768, or 1024 when
when genParms
= false
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException
initialize
in class KeyPairGenerator
params
- the DSAParamaterSpec representing p, q and g for initializing this generatorrandom
- the random seed as SecureRandomInvalidAlgorithmParameterException
- if the given parameter specification is not a DSAParameterSpecpublic KeyPair generateKeyPair()
generateKeyPair
in class KeyPairGenerator
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |