Top Description Fields Constructors Methods
com.sun.crypto.provider

public final Class DHKeyPairGenerator

extends KeyPairGeneratorSpi
Class Inheritance
Imports
java.math.BigInteger, java.security.*, java.security.spec.AlgorithmParameterSpec, .InvalidParameterSpecException, javax.crypto.spec.DHParameterSpec, .DHGenParameterSpec, sun.security.provider.ParameterCache

This class represents the key pair generator for Diffie-Hellman key pairs.

This key pair generator may be initialized in two different ways:

Author
Jan Luehe
See Also
java.security.KeyPairGenerator

Field Summary

Modifier and TypeField and Description
private DHParameterSpec
private int
private SecureRandom

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
checkKeySize(int keysize, int expSize)

public KeyPair

Returns:

the new key pair
generateKeyPair
()

Implements abstract java.security.KeyPairGeneratorSpi.generateKeyPair.

Generates a key pair.
public void
initialize(int
the keysize (size of prime modulus) in bits
keysize
,
SecureRandom
the source of randomness
random
)

Implements abstract java.security.KeyPairGeneratorSpi.initialize.

Initializes this key pair generator for a certain keysize and source of randomness.
public void
initialize(AlgorithmParameterSpec
the parameter set used to generate the key pair
algParams
,
SecureRandom
the source of randomness
random
)

Overrides java.security.KeyPairGeneratorSpi.initialize.

Initializes this key pair generator for the specified parameter set and source of randomness.

Field Detail

paramsback to summary
private DHParameterSpec params
pSizeback to summary
private int pSize
randomback to summary
private SecureRandom random

Constructor Detail

DHKeyPairGeneratorback to summary
public DHKeyPairGenerator()

Method Detail

checkKeySizeback to summary
pack-priv static void checkKeySize(int keysize, int expSize) throws InvalidParameterException
generateKeyPairback to summary
public KeyPair generateKeyPair()

Implements abstract java.security.KeyPairGeneratorSpi.generateKeyPair.

Generates a key pair.

Returns:KeyPair

the new key pair

initializeback to summary
public void initialize(int keysize, SecureRandom random)

Implements abstract java.security.KeyPairGeneratorSpi.initialize.

Initializes this key pair generator for a certain keysize and source of randomness. The keysize is specified as the size in bits of the prime modulus.

Parameters
keysize:int

the keysize (size of prime modulus) in bits

random:SecureRandom

the source of randomness

initializeback to summary
public void initialize(AlgorithmParameterSpec algParams, SecureRandom random) throws InvalidAlgorithmParameterException

Overrides java.security.KeyPairGeneratorSpi.initialize.

Initializes this key pair generator for the specified parameter set and source of randomness.

The given parameter set contains the prime modulus, the base generator, and optionally the requested size in bits of the random exponent (private value).

Parameters
algParams:AlgorithmParameterSpec

the parameter set used to generate the key pair

random:SecureRandom

the source of randomness

Exceptions
InvalidAlgorithmParameterException:
if the given parameters are inappropriate for this key pair generator