public abstract class VarLengthKeyGenerator
extends javax.crypto.KeyGeneratorSpi
An application uses e.g.
KeyGenerator key_gen = KeyGenerator.getInstance("Blowfish");
to create a KeyGenerator object for the given 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();
KeyGenerator,
KeyGeneratorSpi,
SecretKey,
SecretKey| Modifier | Constructor and Description |
|---|---|
protected |
VarLengthKeyGenerator(java.lang.String algorithmName,
int minLength,
int maxLength,
int defaultLength)
Creates a new KeyGanerator with given minimum, maximum, and default key
length.
|
| Modifier and Type | Method and Description |
|---|---|
protected javax.crypto.SecretKey |
engineGenerateKey()
Generates a new key.
|
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
Initializes this key generator with the given random seed.
|
protected void |
engineInit(int strength,
java.security.SecureRandom random)
Initializes this key generator for the given strength with the given random
seed.
|
protected void |
engineInit(java.security.SecureRandom random)
Initializes this key generator with the given random seed.
|
protected VarLengthKeyGenerator(java.lang.String algorithmName,
int minLength,
int maxLength,
int defaultLength)
algorithmName - the name of the algorithmminLength - the minimum key lengthmaxLength - the maximum key lengthdefaultLength - the default key lengthprotected void engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException
engineInit in class javax.crypto.KeyGeneratorSpiparams - not requiredrandom - the random seedjava.security.InvalidAlgorithmParameterException - if parameters are suppliedprotected void engineInit(int strength,
java.security.SecureRandom random)
engineInit in class javax.crypto.KeyGeneratorSpistrength - the strength of the key to be created; if -1, the default length
is usedrandom - the random seedjava.security.InvalidParameterException - if the supplied key strength is shorter than the minimum
required length or longer than the maximum required lengthprotected void engineInit(java.security.SecureRandom random)
engineInit in class javax.crypto.KeyGeneratorSpirandom - the random seed for this generatorprotected javax.crypto.SecretKey engineGenerateKey()
engineGenerateKey in class javax.crypto.KeyGeneratorSpi