All Packages Class Hierarchy This Package Previous Next Index
Class java.security.KeyGenerator
java.lang.Object
|
+----java.security.KeyGenerator
- public abstract synchronized class KeyGenerator
- extends Object
ATTENTION:
This is NOT the implementation from Sun. This class
has been developed by IAIK according to the documentation
publically available. Only the documentation from Sun has been
inserted into the source files.
The KeyGenerator class is used to generate keys for a given
algorithm. Key generators are constructed using the
getInstance
factory methods (static methods that
return instances of a given class).
The KeyGenerator interface is entirely algorithm independent, and,
as for the KeyPairGenerator instances, KeyGenerator instances may be
cast to algorithm-specific interfaces defined elsewhere in
the Java Cryptography Architecture.
A typical set of calls would be:
import java.security.KeyGenerator;
SecureRandom random = new SecureRandom();
KeyGenerator keygen = KeyGenerator.getInstance("DES");
keygen.initialize(random);
Key key = keygen.generateKey();
-
KeyGenerator(String)
- Creates a KeyGenerator object for the specified algorithm.
-
generateKey()
- Generates a key.
-
getAlgorithm()
- Returns the standard name of the algorithm for this key generator.
-
getInstance(String)
- Generates a KeyGenerator object that implements the algorithm
requested, as available in the environment.
-
getInstance(String, String)
- Generates a KeyGenerator object implementing the specified
algorithm, as supplied from the specified provider, if such an
algorithm is available from the provider.
-
initialize(SecureRandom)
- Initialize the key generator.
KeyGenerator
protected KeyGenerator(String algorithm)
- Creates a KeyGenerator object for the specified algorithm.
- Parameters:
- algorithm - - the standard string name of the algorithm.
See Appendix A
in the Java Cryptography Architecture API Specification &
Reference for information about standard algorithm names.
getAlgorithm
public String getAlgorithm()
- Returns the standard name of the algorithm for this key generator.
See Appendix A
in the Java Cryptography Architecture API Specification &
Reference for information about standard algorithm names.
- Returns:
- the standard string name of the algorithm.
getInstance
public static KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
- Generates a KeyGenerator object that implements the algorithm
requested, as available in the environment.
- Parameters:
- algorithm - - the standard string name of the algorithm.
See Appendix A
in the Java Cryptography Architecture API Specification &
Reference for information about standard algorithm names.
- Returns:
- the new KeyGenerator object.
- Throws: NoSuchAlgorithmException
- if the algorithm is
not available in the environment.
getInstance
public static KeyGenerator getInstance(String algorithm,
String provider) throws NoSuchAlgorithmException, NoSuchProviderException
- Generates a KeyGenerator object implementing the specified
algorithm, as supplied from the specified provider, if such an
algorithm is available from the provider.
- Parameters:
- algorithm - - the standard string name of the algorithm.
See Appendix A
in the Java Cryptography Architecture API Specification &
Reference for information about standard algorithm names.
- provider - - the string name of the provider.
- Returns:
- the new KeyGenerator object.
- Throws: NoSuchAlgorithmException
- if the algorithm is
not available from the provider.
- Throws: NoSuchProviderException
- if the provider is not
available in the environment.
initialize
public abstract void initialize(SecureRandom random)
- Initialize the key generator.
- Parameters:
- random - - the source of randomness for this generator.
generateKey
public abstract SecretKey generateKey()
- Generates a key. This method generates a new key every time it is called.
- Returns:
- the new key.
All Packages Class Hierarchy This Package Previous Next Index