java.security
Class KeyPairGenerator
java.lang.Object
|
+--java.security.KeyPairGeneratorSpi
|
+--java.security.KeyPairGenerator
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:KeyPairGenerator
protected KeyPairGenerator(java.lang.String algorithm)
Constructs a new KeyPairGenerator
Parameters:
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:
- A string with the name of the algorithm
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:
- a AlgorithmParameterGenerator repesenting the desired algorithm
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:
- a AlgorithmParameterGenerator repesenting the desired algorithm
Throws:
getProvider
public final Provider getProvider()
Gets the provider that the class is from.
Returns:
- the provider of this class
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: