|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectxjava.security.KeyGenerator
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();
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.3 $
Constructor Summary | |
---|---|
protected |
KeyGenerator(java.lang.String algorithm)
Creates a KeyGenerator object for the specified algorithm. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Returns a clone of this key generator. |
protected java.lang.Object |
engineGetParameter(java.lang.String param)
SPI: Gets the value of the specified algorithm parameter. |
protected void |
engineSetParameter(java.lang.String param,
java.lang.Object value)
SPI: Sets the specified algorithm parameter to the specified value. |
abstract SecretKey |
generateKey()
Generates a key. |
java.lang.String |
getAlgorithm()
Returns the standard name of the algorithm for this key generator. |
static java.lang.String[] |
getAlgorithms()
Gets the standard names of all KeyGenerators implemented by any installed provider. |
static java.lang.String[] |
getAlgorithms(java.security.Provider provider)
Gets the standard names of all KeyGenerators implemented by a provider. |
static KeyGenerator |
getInstance(java.lang.String algorithm)
Generates a KeyGenerator object that implements the algorithm requested, as available in the environment. |
static KeyGenerator |
getInstance(java.lang.String algorithm,
java.lang.String provider)
Generates a KeyGenerator object implementing the specified algorithm, as supplied from the specified provider, if such an algorithm is available from the provider. |
java.lang.Object |
getParameter(java.lang.String param)
Gets the value of the specified algorithm parameter. |
abstract void |
initialize(java.security.SecureRandom random)
Initializes the key generator. |
void |
setParameter(java.lang.String param,
java.lang.Object value)
Sets the specified algorithm parameter to the specified value. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected KeyGenerator(java.lang.String algorithm)
algorithm
- the standard string name of the algorithm.
java.lang.NullPointerException
- if algorithm == nullMethod Detail |
public static KeyGenerator getInstance(java.lang.String algorithm) throws java.security.NoSuchAlgorithmException
See International JCE Standard Algorithm Names for a list of KeyGenerator algorithm names.
algorithm
- the standard name or an alias for the algorithm.
java.security.NoSuchAlgorithmException
- if the algorithm is not
available in the environment.public static KeyGenerator getInstance(java.lang.String algorithm, java.lang.String provider) throws java.security.NoSuchAlgorithmException, java.security.NoSuchProviderException
See International JCE Standard Algorithm Names for a list of KeyGenerator algorithm names.
algorithm
- the standard name or an alias for the algorithm.provider
- the string name of the provider.
java.security.NoSuchAlgorithmException
- if the algorithm is not
available from the provider.
java.security.NoSuchProviderException
- if the provider is not
available in the environment.public java.lang.String getAlgorithm()
See International JCE Standard Algorithm Names for a list of KeyGenerator algorithm names.
public abstract void initialize(java.security.SecureRandom random)
random
- a source of randomness for this generator.public abstract SecretKey generateKey()
public void setParameter(java.lang.String param, java.lang.Object value) throws NoSuchParameterException, java.security.InvalidParameterException, InvalidParameterTypeException
This method supplies a general-purpose mechanism through which it is possible to set the various parameters of this object. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.
This method is not supported in JavaSoft's version of JCE.
setParameter
in interface Parameterized
param
- the string identifier of the parameter.value
- the parameter value.
java.lang.NullPointerException
- if param == null
NoSuchParameterException
- if there is no parameter with name
param for this key generator implementation.
java.security.InvalidParameterException
- if the parameter exists but cannot
be set.
InvalidParameterTypeException
- if value is the wrong type
for this parameter.public java.lang.Object getParameter(java.lang.String param) throws NoSuchParameterException, java.security.InvalidParameterException
This method supplies a general-purpose mechanism through which it is possible to get the various parameters of this object. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.
This method is not supported in JavaSoft's version of JCE.
getParameter
in interface Parameterized
param
- the string name of the parameter.
java.lang.NullPointerException
- if param == null
NoSuchParameterException
- if there is no parameter with name
param for this key generator implementation.
java.security.InvalidParameterException
- if the parameter exists but cannot
be read.protected void engineSetParameter(java.lang.String param, java.lang.Object value) throws NoSuchParameterException, java.security.InvalidParameterException, InvalidParameterTypeException
This method supplies a general-purpose mechanism through which it is possible to set the various parameters of this object. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.
The default implementation always throws a NoSuchParameterException.
This method is not supported in JavaSoft's version of JCE.
param
- the string name of the parameter.value
- the parameter value.
NoSuchParameterException
- if there is no parameter with name
param for this key generator implementation.
java.security.InvalidParameterException
- if the parameter exists but cannot
be set.
InvalidParameterTypeException
- if value is the wrong type
for this parameter.protected java.lang.Object engineGetParameter(java.lang.String param) throws NoSuchParameterException, java.security.InvalidParameterException
This method supplies a general-purpose mechanism through which it is possible to get the various parameters of this object. A uniform algorithm-specific naming scheme for each parameter is desirable but left unspecified at this time.
The default implementation always throws a NoSuchParameterException.
This method is not supported in JavaSoft's version of JCE.
param
- the string name of the parameter.
NoSuchParameterException
- if there is no parameter with name
param for this key generator implementation.
java.security.InvalidParameterException
- if the parameter exists but cannot
be read.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
Note: In JavaSoft's version of JCE, KeyGenerator.clone()
is
protected. This is not very useful, since then an application (as opposed
to the key generator implementation itself) is not able to call it.
java.lang.CloneNotSupportedException
- if the key generator is not cloneable.public java.lang.String toString()
public static java.lang.String[] getAlgorithms(java.security.Provider provider)
This method
is not supported in JavaSoft's version of JCE.
For compatibility you may wish to use
IJCE.getAlgorithms(provider, "KeyGenerator")
instead.
public static java.lang.String[] getAlgorithms()
This method
is not supported in JavaSoft's version of JCE.
For compatibility you may wish to use
IJCE.getAlgorithms("KeyGenerator")
instead.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |