Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.security.KeyPairGeneratorSpi
java.security.KeyPairGenerator
public abstract class KeyPairGenerator
extends KeyPairGeneratorSpi
KeyPairGenerator
is a class used to generate key-pairs for a
security algorithm.
The KeyPairGenerator
is created with the
getInstance()
Factory methods. It is used to generate a pair of
public and private keys for a specific algorithm and associate this key-pair
with the algorithm parameters it was initialized with.
KeyPair
, AlgorithmParameterSpec
Constructor Summary | |
|
Method Summary | |
KeyPair |
|
KeyPair |
|
String |
|
static KeyPairGenerator |
|
static KeyPairGenerator |
|
static KeyPairGenerator |
|
Provider |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.security.KeyPairGeneratorSpi | |
clone , generateKeyPair , initialize , initialize |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected KeyPairGenerator(String algorithm)
Constructs a new instance ofKeyPairGenerator
.
- Parameters:
algorithm
- the algorithm to use.
public final KeyPair genKeyPair()
Generates a new "DSA"KeyPair
from the "GNU" security provider.This method generates a unique key-pair each time it is called.
- Returns:
- a new unique
KeyPair
.
- Since:
- 1.2
- See Also:
generateKeyPair()
public KeyPair generateKeyPair()
Generates a new "DSA"KeyPair
from the "GNU" security provider.This method generates a unique key pair each time it is called.
- Overrides:
- generateKeyPair in interface KeyPairGeneratorSpi
- Returns:
- a new unique
KeyPair
.
- See Also:
genKeyPair()
public String getAlgorithm()
Returns the name of the algorithm used.
- Returns:
- the name of the algorithm used.
public static KeyPairGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
Returns a new instance ofKeyPairGenerator
which generates key-pairs for the specified algorithm.
- Parameters:
algorithm
- the name of the algorithm to use.
- Returns:
- a new instance repesenting the desired algorithm.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not implemented by any provider.IllegalArgumentException
- ifalgorithm
isnull
or is an empty string.
public static KeyPairGenerator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
Returns a new instance ofKeyPairGenerator
which generates key-pairs for the specified algorithm from a named provider.
- Parameters:
algorithm
- the name of the algorithm to use.provider
- the name of aProvider
to use.
- Returns:
- a new instance repesenting the desired algorithm.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not implemented by the named provider.NoSuchProviderException
- if the named provider was not found.IllegalArgumentException
- if eitheralgorithm
orprovider
isnull
or empty.
public static KeyPairGenerator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
Returns a new instance ofKeyPairGenerator
which generates key-pairs for the specified algorithm from a designatedProvider
.
- Parameters:
algorithm
- the name of the algorithm to use.provider
- theProvider
to use.
- Returns:
- a new insatnce repesenting the desired algorithm.
- Throws:
NoSuchAlgorithmException
- if the algorithm is not implemented by theProvider
.IllegalArgumentException
- if eitheralgorithm
orprovider
isnull
, or ifalgorithm
is an empty string.
- Since:
- 1.4
- See Also:
Provider
public final Provider getProvider()
Returns theProvider
of this instance.
- Returns:
- the
Provider
of this instance.
public void initialize(int keysize)
Initializes this instance for the specified key size. Since no source of randomness is specified, a default one will be used.
- Parameters:
keysize
- the size of keys to use.
public void initialize(int keysize, SecureRandom random)
Initializes this instance for the specified key size andSecureRandom
.
- Overrides:
- initialize in interface KeyPairGeneratorSpi
- Parameters:
keysize
- the size of keys to use.random
- theSecureRandom
to use.
- Since:
- 1.2
public void initialize(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
Initializes this instance with the specifiedAlgorithmParameterSpec
. Since no source of randomness is specified, a default one will be used.
- Parameters:
params
- theAlgorithmParameterSpec
to use.
- Throws:
InvalidAlgorithmParameterException
- if the designated specifications are invalid.
- Since:
- 1.2
public void initialize(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException
Initializes this instance with the specifiedAlgorithmParameterSpec
andSecureRandom
.
- Overrides:
- initialize in interface KeyPairGeneratorSpi
- Parameters:
params
- theAlgorithmParameterSpec
to use.random
- theSecureRandom
to use.
- Throws:
InvalidAlgorithmParameterException
- if the designated specifications are invalid.
- Since:
- 1.2