|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.crypto.KeyGenerator
public class KeyGenerator
A generic producer of keys for symmetric cryptography. The keys returned may be simple wrappers around byte arrays, or, if the target cipher requires them, more complex objects.
Cipher
,
Mac
Constructor Summary | |
---|---|
protected |
KeyGenerator(KeyGeneratorSpi kgSpi,
Provider provider,
String algorithm)
Create a new key generator. |
Method Summary | |
---|---|
SecretKey |
generateKey()
Generate a key. |
String |
getAlgorithm()
Return the name of this key generator. |
static KeyGenerator |
getInstance(String algorithm)
Create a new key generator, returning the first available implementation. |
static KeyGenerator |
getInstance(String algorithm,
Provider provider)
Create a new key generator from the supplied provider. |
static KeyGenerator |
getInstance(String algorithm,
String provider)
Create a new key generator from the named provider. |
Provider |
getProvider()
Return the provider of the underlying implementation. |
void |
init(AlgorithmParameterSpec params)
Initialize this key generator with a set of parameters; the highest-priority SecureRandom implementation
will be used. |
void |
init(AlgorithmParameterSpec params,
SecureRandom random)
Initialize this key generator with a set of parameters and a source of randomness. |
void |
init(int keySize)
Initialize this key generator with a key size (in bits); the highest-priority SecureRandom implementation
will be used. |
void |
init(int keySize,
SecureRandom random)
Initialize this key generator with a key size (in bits) and a source of randomness. |
void |
init(SecureRandom random)
Initialize this key generator with a source of randomness. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected KeyGenerator(KeyGeneratorSpi kgSpi, Provider provider, String algorithm)
kgSpi
- The underlying generator.provider
- The provider of this implementation.algorithm
- The algorithm's name.Method Detail |
---|
public static final KeyGenerator getInstance(String algorithm) throws NoSuchAlgorithmException
algorithm
- The generator algorithm name.
NoSuchAlgorithmException
- If the specified algorithm does not exist.
IllegalArgumentException
- if algorithm
is
null
or is an empty string.public static final KeyGenerator getInstance(String algorithm, String provider) throws NoSuchAlgorithmException, NoSuchProviderException
algorithm
- The generator algorithm name.provider
- The name of the provider to use.
NoSuchAlgorithmException
- If the specified algorithm is not
implemented by the named provider.
NoSuchProviderException
- If the named provider does not exist.
IllegalArgumentException
- if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.public static final KeyGenerator getInstance(String algorithm, Provider provider) throws NoSuchAlgorithmException
algorithm
- The generator algorithm name.provider
- The provider to use.
NoSuchAlgorithmException
- If the specified algorithm is not
implemented by the provider.
IllegalArgumentException
- if either algorithm
or
provider
is null
, or if
algorithm
is an empty string.public final SecretKey generateKey()
public final String getAlgorithm()
public final Provider getProvider()
public final void init(AlgorithmParameterSpec params) throws InvalidAlgorithmParameterException
SecureRandom
implementation
will be used.
params
- The algorithm parameters.
InvalidAlgorithmParameterException
- If the
supplied parameters are inapproprate.public final void init(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException
params
- The algorithm parameters.random
- The source of randomness.
InvalidAlgorithmParameterException
- If the
supplied parameters are inapproprate.public final void init(int keySize)
SecureRandom
implementation
will be used.
keySize
- The target key size, in bits.
InvalidParameterException
- If the
key size is unsupported.public final void init(int keySize, SecureRandom random)
keySize
- The target key size, in bits.random
- The source of randomness.
InvalidAlgorithmParameterException
- If the
key size is unsupported.public final void init(SecureRandom random)
random
- The source of randomness.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |