Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.security

Class KeyPairGenerator

java.lang.Object
|
+--java.security.KeyPairGeneratorSpi
   |
   +--java.security.KeyPairGenerator


public abstract class KeyPairGenerator

extends KeyPairGeneratorSpi

KeyPairGenerator is the class used to generate key pairs for a security algorithm. The KeyPairGenerator is created with the getInstance() methods. The class is used to generate public and private keys for an algorithm and associate it with algorithm parameters.

Author:

Constructor Summary

KeyPairGenerator(java.lang.String algorithm)

Constructs a new KeyPairGenerator

Method Summary

java.security.KeyPairgenKeyPair()

Generates a KeyPair according the rules for the algorithm.
java.security.KeyPairgenerateKeyPair()

Generates a KeyPair according the rules for the algorithm.
java.lang.StringgetAlgorithm()

Returns the name of the algorithm used
static java.security.KeyPairGeneratorgetInstance(java.lang.String algorithm)

Gets an instance of the KeyPairGenerator class which generates key pairs for the specified algorithm.
static java.security.KeyPairGeneratorgetInstance(java.lang.String algorithm, java.lang.String provider)

Gets an instance of the KeyPairGenerator class which generates key pairs for the specified algorithm.
java.security.ProvidergetProvider()

Gets the provider that the class is from.
voidinitialize(int keysize)

Initializes the KeyPairGenerator for the specified key size.
voidinitialize(int keysize, java.security.SecureRandom random)

Initializes the KeyPairGenerator for the specified key size and specified SecureRandom.
voidinitialize(java.security.spec.AlgorithmParameterSpec params)

Initializes the KeyPairGenerator with the specified AlgorithmParameterSpec class.
voidinitialize(java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)

Initializes the KeyPairGenerator with the specified AlgorithmParameterSpec class and specified SecureRandom.

Constructor Details

KeyPairGenerator

protected KeyPairGenerator(java.lang.String algorithm)

Constructs a new KeyPairGenerator

Parameters:


Method Details

genKeyPair

public final KeyPair genKeyPair()

Generates a KeyPair according the rules for the algorithm. Unless intialized, algorithm defaults will be used. It creates a unique key pair each time. Same as generateKeyPair();

Returns:


generateKeyPair

public KeyPair generateKeyPair()

Generates a KeyPair according the rules for the algorithm. Unless intialized, algorithm defaults will be used. It creates a unique key pair each time. Same as genKeyPair();

Returns:


getAlgorithm

public String getAlgorithm()

Returns the name of the algorithm used

Returns:


getInstance

public static KeyPairGenerator getInstance(java.lang.String algorithm)

Gets an instance of the KeyPairGenerator class which generates key pairs for the specified algorithm. If the algorithm is not found then, it throws NoSuchAlgorithmException.

Parameters:

Returns:

Throws:


getInstance

public static KeyPairGenerator getInstance(java.lang.String algorithm, java.lang.String provider)

Gets an instance of the KeyPairGenerator class which generates key pairs for the specified algorithm. If the algorithm is not found then, it throws NoSuchAlgorithmException.

Parameters:

Returns:

Throws:


getProvider

public final Provider getProvider()

Gets the provider that the class is from.

Returns:


initialize

public void initialize(int keysize)

Initializes the KeyPairGenerator for the specified key size. (Since no source of randomness is specified, a default one is provided.)

Parameters:


initialize

public void initialize(int keysize, java.security.SecureRandom random)

Initializes the KeyPairGenerator for the specified key size and specified SecureRandom.

Since:Parameters:


initialize

public void initialize(java.security.spec.AlgorithmParameterSpec params)

Initializes the KeyPairGenerator with the specified AlgorithmParameterSpec class. (Since no source of randomness is specified, a default one is provided.)

Since:Parameters:


initialize

public void initialize(java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)

Initializes the KeyPairGenerator with the specified AlgorithmParameterSpec class and specified SecureRandom.

Since:Parameters: