|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.crypto.KeyGenerator
Engine class for creating secret keys in algorithm independent manner.
Attention: This is not a SUN implementation!
This class has been developed by IAIK according to the documentation publicly available.
For SUNīs documentation of this class see
http://java.sun.com/security/JCE1.2/spec/apidoc/index.html
This class represents a key generator for creating secret keys for symmetric
algorithms. For creating a KeyGenerator object, an application shall use one
of the getInstance
methods, supplied with the particular symmetric
algorithm in mind and (optionally) a particular provider.
For instance:
KeyGenerator key_gen = KeyGenerator.getInstance("DES");
For actually generating the requested secret key from the KeyGenerator object just
created (and initialized with one of the init
methods), use the
generateKey
method:
For instance:
SecretKey des_key = key_gen.generateKey();
Initializing the key generator maybe done either algorithm-independently with some random seed, or algorithm-specific with some particular algorithm parameter specification. If no explicit initialization is done at all, it is left to the actual provider implementation to take default settings.
getInstance(java.lang.String)
,
generateKey()
,
SecretKey
,
SecretKey
Constructor Summary | |
protected |
KeyGenerator(KeyGeneratorSpi keyGenSpi,
Provider provider,
String algorithm)
Default Constructor for creating a KeyGenerator object. |
Method Summary | |
SecretKey |
generateKey()
Actually generates a secret key from this KeyGenerator object. |
String |
getAlgorithm()
Returns the standard name of the key algorithm. |
static KeyGenerator |
getInstance(String algorithm)
Returns the default provider KeyGenerator implementation for the specified algorithm. |
static KeyGenerator |
getInstance(String algorithm,
String provider)
Returns a KeyGenerator object for the specified algorithm, implemented by the given provider. |
Provider |
getProvider()
Returns the provider used for creating this KeyGenerator object. |
void |
init(AlgorithmParameterSpec params)
Initializes this key generator with the given algorithm parameters. |
void |
init(AlgorithmParameterSpec params,
SecureRandom random)
Initializes this key generator with given algorithm parameters and random seed. |
void |
init(int strength)
Initializes this key generator for the given strength. |
void |
init(int strength,
SecureRandom random)
Initializes this key generator for the given strength with the given random seed |
void |
init(SecureRandom random)
Initializes this key generator with the given random seed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected KeyGenerator(KeyGeneratorSpi keyGenSpi, Provider provider, String algorithm)
getInstance
factory methods for obtaining a KeyGenerator object.keyGenSpi
- the SPI KeyGenerator implementation of the actual providerprovider
- the provideralgorithm
- the algorithmMethod Detail |
public final String getAlgorithm()
public static final KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
algorithm
- the standard name of the algorithm for which the KeyGenerator is usedNoSuchAlgorithmException
- if this algorithm is not implementedpublic static final KeyGenerator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm
- the standard name of algorithm for which the KeyGenerator is usedprovider
- the name of the provider as string.NoSuchAlgorithmException
- if this algorithm is not implemented by the given providerNoSuchProviderException
- if the given provider cannot be fetchedpublic final Provider getProvider()
public final void init(SecureRandom random)
random
- the random seedpublic final void init(int strength)
strength
- the strength of the key to be createdpublic final void init(int strength, SecureRandom random)
strength
- the strength of the key to be createdrandom
- the random seedpublic final void init(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
params
- the algorithm parametersInvalidAlgorithmParameterException
- if the given algorithm parameters do not match to this KeyGeneratorpublic final void init(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException
params
- the algorithm parametersrandom
- the random seedInvalidAlgorithmParameterException
- if the given algorithm parameters do not match to this KeyGeneratorpublic final SecretKey generateKey()
|
This Javadoc may contain text parts from Internet Standard specifications (RFC 2459, 3280, 3039, 2560, 1521, 821, 822, 2253, 1319, 1321, ,2630, 2631, 2268, 3058, 2984, 2104, 2144, 2040, 2311, 2279, see copyright note) and RSA Data Security Public-Key Cryptography Standards (PKCS#1,3,5,7,8,9,10,12, see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |