public class AESKeyGenerator
extends javax.crypto.KeyGeneratorSpi
An application uses
KeyGenerator key_gen = KeyGenerator.getInstance("Rijndael");
for creating a KeyGenerator object for the Rijndael algorithm. For actually
generating the requested secret key from the KeyGenerator object
just created, an application calls the generateKey method after
having initialized the generator with some random seed or relied on the
default system-provided source of randomness:
SecretKey new_key = key_gen.generateKey();
The name for the generated key is AES, minimum key length 128 bit, maximum 256 in increments of 64 bit, default 128.
This class SHOULD NOT be used directly; it should only be used through the JCA/JCE.
| Constructor and Description |
|---|
AESKeyGenerator()
The constructor; creates a new instance of the AES key generation
algorithm.
|
| Modifier and Type | Method and Description |
|---|---|
protected javax.crypto.SecretKey |
engineGenerateKey()
Generates a secret key.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes the key generator with the specified parameter set and a
user-provided source of randomness.
|
protected void |
engineInit(int strength,
java.security.SecureRandom random)
Initializes this key generator for a certain keysize, using the given
source of randomness.
|
protected void |
engineInit(java.security.SecureRandom random)
Initializes the key generator.
|
public AESKeyGenerator()
Applications should not use this constructor, instead the key generation
algorithm should be requested from the appropriate JCA/JCE cryptographic
service provider as follows:
KeyGenerator.getInstance("AES", "IAIK").
protected void engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException
engineInit in class javax.crypto.KeyGeneratorSpiparams - [FIPS 140-2 data input] the key generation parametersrandom - [FIPS 140-2 control input] the source of randomness for this
key generatorjava.security.InvalidAlgorithmParameterException - [FIPS 140-2 status output] if params is
inappropriate for this key generatorFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected void engineInit(int strength,
java.security.SecureRandom random)
Lengths outside the range of minimum to maximum length default to the default length.
engineInit in class javax.crypto.KeyGeneratorSpikeysize - [FIPS 140-2 data input] the keysize. This is an
algorithm-specific metric, specified in number of bits.random - [FIPS 140-2 control input] the source of randomness for this
key generatorFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected void engineInit(java.security.SecureRandom random)
The strength defaults to the default length.
engineInit in class javax.crypto.KeyGeneratorSpirandom - [FIPS 140-2 control input] the source of randomness for this
generatorFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operationsprotected javax.crypto.SecretKey engineGenerateKey()
engineGenerateKey in class javax.crypto.KeyGeneratorSpiFips140ErrorStateException - [FIPS 140-2 status output] thrown if the Toolkit is not
allowed to perform cryptographic operations