|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.crypto.KeyGeneratorSpi de.cscc.crypto.provider.DESede2KeySecretKeyGeneratorEngine
DESede2KeySecretKeyGeneratorEngine Class provides the functionality of a DESede key generator for two keys (means 112 or 128 bit key length). This key generator generates only keys for the "DESede2Key" algorithm in the JHBCI crypto provider. This KeyGenerator Object is re-useable, i.e., after a key has been generated, the same KeyGenerator Object can be re-used to generate further keys.
Use the DESede2KeySecretKeyGeneratorEngine through the JCE in the following way: import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import java.security.SecureRandom; KeyGenerator kg = new KeyGenerator.getInstance("DESede2Key", "JHBCI"); kg.init(new SecureRandom()); SecretKey key = kg.generateKey(); //Use key further in a DESede2Key Cipher from the JHBCI provider. //Or do some other useful things with this nicely generated SecretKey.In this case you does not explicitly initialize the KeyGenerator Object (in our example code that means
kg.init(new SecureRandom());
)
we initialize the KeyGenerator Object with new SecureRandom()
.
So you can omit the line kg.init(new SecureRandom());
.
With this code we will get a SecureRandom implementation of the
higest-priority installed provider. If no one of the installed
providers supply an implementation of SecureRandom, a system provided
source of randomness will be used.
See the changed example: import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import java.security.SecureRandom; KeyGenerator kg = new KeyGenerator.getInstance("DESede2Key", "JHBCI"); SecretKey key = kg.generateKey(); //Use key further in a DESede2Key Cipher from the JHBCI provider. //Or do some other useful things with this nicely generated SecretKey.
Constructor Summary | |
DESede2KeySecretKeyGeneratorEngine()
Creates new DESede2KeySecretKeyGeneratorEngine. |
Method Summary | |
protected SecretKey |
engineGenerateKey()
Generates a secret key. |
protected void |
engineInit(AlgorithmParameterSpec params,
SecureRandom random)
Initializes the key generator with the specified parameter set and a user-provided source of randomness. |
protected void |
engineInit(int keysize,
SecureRandom random)
Initializes this key generator for a certain keysize, using the given source of randomness. |
protected void |
engineInit(SecureRandom random)
Initializes the key generator. |
String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public DESede2KeySecretKeyGeneratorEngine()
KeyGenerator.getInstance(...)
.
SecurityException
- if the provider self integrity check fails.Method Detail |
public String toString()
protected void engineInit(SecureRandom random)
random
- the source of randomness for this generator.protected void engineInit(int keysize, SecureRandom random) throws InvalidParameterException
keysize
- the keysize. This is an algorithm-specific metric,
specified in number of bits.random
- the source of randomness for this key generator.
InvalidParameterException
- if keysize is wrong or not supported.protected void engineInit(AlgorithmParameterSpec params, SecureRandom random) throws InvalidAlgorithmParameterException
params
have to be null or
InvalidAlgorithmParameterException will be thrown.
params
- the key generation parameters.random
- the source of randomness for this key generator.
InvalidAlgorithmParameterException
- if params
is
inappropriate for this key generator. We only support null
as parameter for params
.protected SecretKey engineGenerateKey()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |