iaik.security.dh
Class DHParameterGenerator

java.lang.Object
  |
  +--java.security.AlgorithmParameterGeneratorSpi
        |
        +--iaik.security.dh.DHParameterGenerator
Direct Known Subclasses:
ESDHParameterGenerator

public class DHParameterGenerator
extends AlgorithmParameterGeneratorSpi

This class implements an AlgorithmParameterGenerator that generates parameters for key-agreement according to the Diffie-Hellman protocol.

The algorithm used is taken from RFC 2631. It specifies a minimum prime length of 512 bit and minimum exponent length of 160 bit; defaults in this implementation are 1024 and 300 bits respectively. Access to the verification parameters provided by the generation algorithm is not possible with the current API.

Note that parameter generation is fairly slow but this should not be a problem as this is a hardly performed activity anyway. Typically they will be generated once per user group by the CA and then the users will generate their keys using the parameters provided.

The Diffie Hellman algorithm has been the first public-key algorithm. It only can be used for key-agreement, but not for data encrypting and decrypting.

PKCS#3 describes a method for implementing the Diffie Hellman key agreement where two (or more) entities use general Diffie Hellman parameters (an odd prime p, an integer base g satisfying 0 < g < p, and optionally an integer l prescribing the length of the private value), generated from some central authority (which may an entity itself), for creating a shared secret only known by them.

Applications shall use AlgorithmParameterGenerator.getInstance("DH") for obtaining an AlgorithmParamterGenerator for generating DH parameters in opaque representation. Once the generator has been created, it shall be properly initialized by one of the several init methods. If none explicit initialization is done, per default the length of the prime modulus is set to 1024 bits and the length of the exponent (private value) is chosen to be 300 bits. After initializing the generator (or relying on default settings), the reguired parameters actually are created by calling the generateParameters method.

Version:
File Revision 18
See Also:
AlgorithmParameterGenerator, DHParameterSpec, DHParameters, DHPublicKey, DHPrivateKey, DHKeyPairGenerator, DHKeyFactory, DHKeyAgreement

Constructor Summary
DHParameterGenerator()
          The default constructor.
 
Method Summary
protected  AlgorithmParameters engineGenerateParameters()
          Actually generates the required DH AlgorithmParameters.
protected  void engineInit(AlgorithmParameterSpec param, SecureRandom random)
          Initializes this generator with DH-specific parameter generation values and some random seed.
protected  void engineInit(int primeLength, SecureRandom random)
          Initializes the parameter generator with given prime modulus length and random seed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DHParameterGenerator

public DHParameterGenerator()
The default constructor. Only internally used for creating an DHParameterGenerator object. Applications shall use one of the AlgorithmParameterGenerator.getInstance factory methods for obtaining an AlgorithmParamterGenerator for generating paramters for Diffie Hellman key agreement.
Method Detail

engineInit

protected void engineInit(int primeLength,
                          SecureRandom random)
Initializes the parameter generator with given prime modulus length and random seed. Exponent length is set to 0.

Overrides:
engineInit in class AlgorithmParameterGeneratorSpi
Parameters:
primeLength - the length of the prime modulus in bits
random - the random seed for this generator.

engineInit

protected void engineInit(AlgorithmParameterSpec param,
                          SecureRandom random)
                   throws InvalidAlgorithmParameterException
Initializes this generator with DH-specific parameter generation values and some random seed.

From the given parameter specification DHGenParameterSpec) prime modulus length and exponent length are obtained for generating the algorithm parameters.

Applications shall call init(param_spec, random) for provider independently accessing this method.

Overrides:
engineInit in class AlgorithmParameterGeneratorSpi
Parameters:
param - an instance of DHGenParameterSpec
random - the random seed to be used by this generator.
Throws:
InvalidAlgorithmParameterException - if param is not an instance of DHGenParameterSpec or if the size of the exponent is not shorter than that of the prime modulus

engineGenerateParameters

protected AlgorithmParameters engineGenerateParameters()
Actually generates the required DH AlgorithmParameters.

Applications shall call generatePrameters() for provider independently accessing this method.

Overrides:
engineGenerateParameters in class AlgorithmParameterGeneratorSpi
Returns:
the new created Diffie Hellman AlgorithmParameters

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).

IAIK-JCE 3.1 with IAIK-JCE CC Core 3.1, (c) 1997-2004 IAIK