iaik.security.cipher
Class TripleDESKeyGenerator
java.lang.Object
|
+--javax.crypto.KeyGeneratorSpi
|
+--iaik.security.cipher.TripleDESKeyGenerator
- public class TripleDESKeyGenerator
- extends KeyGeneratorSpi
This class provides the functionality of a TripleDES key generator.
A key generator is used for creating secret keys for symmetric algorithms.
An application uses
KeyGenerator key_gen = KeyGenerator.getInstance("TripleDES");
for creating a KeyGenerator object for the TripleDES algorithm. For actually
generating the requested secret TripleDES 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 triple_des_key = key_gen.generateKey();
A TripleDES key is composed of three DES keys. For extracting the inherent DES
keys, an application may use the getEncoded method to get a byte
array representation of the TripleDES key and subsequently split it accordingly:
des key1 = first 8 bytes of key
des key2 = second 8 bytes of key
des key3 = first 8 bytes of key in case of 2 key triple DES, third 8 bytes otherwise
- See Also:
KeyGenerator,
KeyGeneratorSpi,
SecretKey,
SecretKey,
DESKeyGenerator,
TripleDES
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
random
protected SecureRandom random
key_len
protected int key_len
TripleDESKeyGenerator
public TripleDESKeyGenerator()
engineInit
public void engineInit(AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidAlgorithmParameterException
- Because this TripleDES key generator needs no parameter this initialization method
only throws a InvalidAlgorithmParameterException.
- Overrides:
- engineInit in class KeyGeneratorSpi
- Throws:
- InvalidAlgorithmParameterException - since this TripleDES key generator needs no parameters
engineInit
public void engineInit(SecureRandom random)
- Initializes this TripleDES key generator with the given random seed.
- Overrides:
- engineInit in class KeyGeneratorSpi
- Parameters:
random - the random seed for this TripleDES key generator
engineInit
public void engineInit(int strength,
SecureRandom random)
- Initializes this DES key generator for the given strength with the given random seed.
- Overrides:
- engineInit in class KeyGeneratorSpi
- Parameters:
strength - the strength of the key to be created; 112 for TripleDES with
2 keys and 168 for TripleDES with 3 keys (default)random - the random seed
engineGenerateKey
public SecretKey engineGenerateKey()
- Generates a TripleDES key from three DES keys.
- Overrides:
- engineGenerateKey in class KeyGeneratorSpi
- Returns:
- the new created parity adjusted TripleDES key
- See Also:
SecretKey