public abstract class KeyPairGenerator extends KeyPairGeneratorSpi
KeyPairGenerator is an engine class which is capable of generating a
private key and its related public key utilizing the algorithm it was
initialized with.KeyPairGeneratorSpi| Modifier | Constructor and Description |
|---|---|
protected |
KeyPairGenerator(String algorithm)
Constructs a new instance of
KeyPairGenerator with the name of
the algorithm to use. |
| Modifier and Type | Method and Description |
|---|---|
KeyPair |
generateKeyPair()
Computes and returns a new unique
KeyPair each time this method
is called. |
KeyPair |
genKeyPair()
Computes and returns a new unique
KeyPair each time this method
is called. |
String |
getAlgorithm()
Returns the name of the algorithm of this
KeyPairGenerator. |
static KeyPairGenerator |
getInstance(String algorithm)
Returns a new instance of
KeyPairGenerator that utilizes the
specified algorithm. |
static KeyPairGenerator |
getInstance(String algorithm,
Provider provider)
Returns a new instance of
KeyPairGenerator that utilizes the
specified algorithm from the specified provider. |
static KeyPairGenerator |
getInstance(String algorithm,
String provider)
Returns a new instance of
KeyPairGenerator that utilizes the
specified algorithm from the specified provider. |
Provider |
getProvider()
Returns the provider associated with this
KeyPairGenerator. |
void |
initialize(AlgorithmParameterSpec param)
Initializes this
KeyPairGenerator with the given AlgorithmParameterSpec. |
void |
initialize(AlgorithmParameterSpec param,
SecureRandom random)
Initializes this
KeyPairGenerator with the given AlgorithmParameterSpec and the given SecureRandom. |
void |
initialize(int keysize)
Initializes this
KeyPairGenerator with the given key size. |
void |
initialize(int keysize,
SecureRandom random)
Initializes this
KeyPairGenerator with the given key size and the
given SecureRandom. |
protected KeyPairGenerator(String algorithm)
KeyPairGenerator with the name of
the algorithm to use.algorithm - the name of algorithm to usepublic String getAlgorithm()
KeyPairGenerator.KeyPairGeneratorpublic static KeyPairGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
KeyPairGenerator that utilizes the
specified algorithm.algorithm - the name of the algorithm to useKeyPairGenerator that utilizes the
specified algorithmNoSuchAlgorithmException - if the specified algorithm is not availableNullPointerException - if algorithm is nullpublic static KeyPairGenerator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
KeyPairGenerator that utilizes the
specified algorithm from the specified provider.algorithm - the name of the algorithm to useprovider - the name of the providerKeyPairGenerator that utilizes the
specified algorithm from the specified providerNoSuchAlgorithmException - if the specified algorithm is not availableNoSuchProviderException - if the specified provider is not availableNullPointerException - if algorithm is nullIllegalArgumentException - if provider == null || provider.isEmpty()public static KeyPairGenerator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
KeyPairGenerator that utilizes the
specified algorithm from the specified provider. The provider
supplied does not have to be registered.algorithm - the name of the algorithm to useprovider - the providerKeyPairGenerator that utilizes the
specified algorithm from the specified providerNoSuchAlgorithmException - if the specified algorithm is not availableNullPointerException - if algorithm is nullIllegalArgumentException - if provider == nullpublic final Provider getProvider()
KeyPairGenerator.KeyPairGeneratorpublic void initialize(int keysize)
KeyPairGenerator with the given key size. The
default parameter set and a default SecureRandom instance will be
used.keysize - the size of the key (number of bits)public void initialize(AlgorithmParameterSpec param) throws InvalidAlgorithmParameterException
KeyPairGenerator with the given AlgorithmParameterSpec. A default SecureRandom instance will be
used.param - the parameters to useInvalidAlgorithmParameterException - if the specified parameters are not supportedpublic final KeyPair genKeyPair()
KeyPair each time this method
is called.
This does exactly the same as generateKeyPair().
KeyPair each time this method is calledpublic KeyPair generateKeyPair()
KeyPair each time this method
is called.
This does exactly the same as genKeyPair().
generateKeyPair in class KeyPairGeneratorSpiKeyPair each time this method is calledpublic void initialize(int keysize,
SecureRandom random)
KeyPairGenerator with the given key size and the
given SecureRandom. The default parameter set will be used.initialize in class KeyPairGeneratorSpikeysize - the key sizerandom - the source of randomnesspublic void initialize(AlgorithmParameterSpec param, SecureRandom random) throws InvalidAlgorithmParameterException
KeyPairGenerator with the given AlgorithmParameterSpec and the given SecureRandom.initialize in class KeyPairGeneratorSpiparam - the parameters to userandom - the source of randomnessInvalidAlgorithmParameterException - if the specified parameters are not supported