All Packages Class Hierarchy This Package Previous Next Index
Class javax.crypto.KeyGenerator
java.lang.Object
|
+----javax.crypto.KeyGenerator
- public class KeyGenerator
- extends Object
This class provides the functionality of a (symmetric) key generator.
Key generators are constructed using the getInstance
class method of this class.
KeyGenerator objects are reusable, i.e., after a key has been
generated, the same KeyGenerator object can be re-used to generate further
keys.
- See Also:
- SecretKey, java.security.AlgorithmParameters, java.security.spec.AlgorithmParameterSpec
KeyGenerator(KeyGeneratorSpi, Provider, String)
- Creates a KeyGenerator object.
generateKey()
- Generates a secret key.
getAlgorithm()
- Returns the standard name of the key algorithm.
getInstance(String)
- Generates a KeyGenerator object for the specified key algorithm.
getInstance(String, String)
- Generates a KeyGenerator object for the specified key algorithm from the
specified provider.
getProvider()
- Returns the provider of this
KeyGenerator
object.
init(AlgorithmParameterSpec)
- Initializes the key generator with the specified parameter set, using
a system-provided source of randomness.
init(AlgorithmParameterSpec, SecureRandom)
- Initializes the key generator with the specified parameter
set and a user-provided source of randomness.
init(SecureRandom)
- Initializes the key generator.
KeyGenerator
protected KeyGenerator(KeyGeneratorSpi keyGenSpi,
Provider provider,
String algorithm)
- Creates a KeyGenerator object.
- Parameters:
- keyGenSpi - the delegate
- provider - the provider
- algorithm - the algorithm
getAlgorithm
public final String getAlgorithm()
- Returns the standard name of the key algorithm.
See Appendix A in the
Java Cryptography Extension API Specification & Reference
for information about standard algorithm names.
- Returns:
- the standard algorithm name.
getInstance
public static final KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
- Generates a KeyGenerator object for the specified key algorithm.
- Parameters:
- algorithm - the standard name of the requested key algorithm.
See Appendix A in the
Java Cryptography Extension API Specification & Reference
for information about standard algorithm names.
- Returns:
- the new KeyGenerator object
- Throws:
NoSuchAlgorithmException
- if a key generator for the
requested algorithm is not available
getInstance
public static final KeyGenerator getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException, NoSuchProviderException
- Generates a KeyGenerator object for the specified key algorithm from the
specified provider.
- Parameters:
- algorithm - the standard name of the requested key algorithm.
See Appendix A in the
Java Cryptography Extension API Specification & Reference
for information about standard algorithm names.
- provider - the name of the provider
- Returns:
- the new KeyGenerator object
- Throws:
NoSuchAlgorithmException
- if a key generator for the
requested algorithm is not available from the provider
- Throws:
NoSuchProviderException
- if the requested provider is not
available
- See Also:
- java.security.Provider
getProvider
public final Provider getProvider()
- Returns the provider of this
KeyGenerator
object.
- Returns:
- the provider of this
KeyGenerator
object
init
public final void init(SecureRandom random)
- Initializes the key generator.
- Parameters:
- random - the source of randomness for this generator
init
public final void init(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
- Initializes the key generator with the specified parameter set, using
a system-provided source of randomness.
- Parameters:
- params - the key generation parameters
- Throws:
InvalidAlgorithmParameterException
- if the given parameters
are inappropriate for this key generator
init
public final void init(AlgorithmParameterSpec params,
SecureRandom random) throws InvalidAlgorithmParameterException
- Initializes the key generator with the specified parameter
set and a user-provided source of randomness.
- Parameters:
- params - the key generation parameters
- random - the source of randomness for this key generator
- Throws:
InvalidAlgorithmParameterException
- if
params
is
inappropriate for this key generator
generateKey
public final SecretKey generateKey()
- Generates a secret key.
- Returns:
- the new key
All Packages Class Hierarchy This Package Previous Next Index