de.flexiprovider.core.dsa
Class DSAKeyPairGenerator

java.lang.Object
  |
  +--java.security.KeyPairGeneratorSpi
        |
        +--de.flexiprovider.api.keys.KeyPairGenerator
              |
              +--de.flexiprovider.core.dsa.interfaces.DSAKeyPairGenerator
                    |
                    +--de.flexiprovider.core.dsa.DSAKeyPairGenerator

public class DSAKeyPairGenerator
extends DSAKeyPairGenerator

This class implements the DSAKeyPairGenerator interface. The key pair generation follows the proposal of the FIPS 186-2 standard, except for the generation of the random numbers.

The default bit length of the prime p is 1024 bits.

Author:
Thomas Wahrenbruch

Constructor Summary
DSAKeyPairGenerator()
           
 
Method Summary
 KeyPair genKeyPair()
          Generate a key pair, containing a DSAPublicKey and a DSAPrivateKey.
 void initialize(AlgorithmParameterSpec params, SecureRandom random)
          Initialize the key pair generator with the given parameters (supposed to be an instance of DSAParams) and source of randomness.
 void initialize(int keySize, SecureRandom random)
          Initialize the key pair generator with the given strength (bit length of the prime p) and source of randomness.
 
Methods inherited from class de.flexiprovider.core.dsa.interfaces.DSAKeyPairGenerator
initialize
 
Methods inherited from class de.flexiprovider.api.keys.KeyPairGenerator
generateKeyPair, initialize
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSAKeyPairGenerator

public DSAKeyPairGenerator()
Method Detail

initialize

public void initialize(AlgorithmParameterSpec params,
                       SecureRandom random)
                throws InvalidAlgorithmParameterException
Initialize the key pair generator with the given parameters (supposed to be an instance of DSAParams) and source of randomness. If the parameters are null, new parameters are generated for the default size using the DSAParameterGenerator.
Overrides:
initialize in class KeyPairGenerator
Parameters:
params - the algorithm parameters
random - the source of randomness
Throws:
InvalidAlgorithmParameterException - if the parameters are not an instance of DSAParams.

initialize

public void initialize(int keySize,
                       SecureRandom random)
Initialize the key pair generator with the given strength (bit length of the prime p) and source of randomness.

If the given strength is not a multiple of 64, the next smaller multiple of 64 is used as strength. If strength is > 1024 or < 512, 1024 is used as strength.

A new parameter set is generated for the chosen strength using the DSAParameterGenerator and the given source of randomness.

Overrides:
initialize in class KeyPairGenerator
Parameters:
keySize - the bit length of the prime p
random - the source of randomness

genKeyPair

public KeyPair genKeyPair()
Generate a key pair, containing a DSAPublicKey and a DSAPrivateKey.
Overrides:
genKeyPair in class KeyPairGenerator
Returns:
the generated key pair