au.net.aba.crypto.provider
Class DESKeyGenerator
java.lang.Object
|
+--javax.crypto.KeyGeneratorSpi
|
+--au.net.aba.crypto.provider.DESKeyGenerator
- Direct Known Subclasses:
- DESedeKeyGenerator
- public class DESKeyGenerator
- extends KeyGeneratorSpi
This class is used for generating random DES keys. This class
should not be instantiated directly, instead use the
javax.crypto.KeyGenerator interface.
There is no AlgorithmParameterSpec class defined for DES so this
generator can only be initialised using the keysize,random
initialisation.
The returned key will be a non-weak key with odd parity.
Field Summary |
static java.lang.String |
ident
|
Method Summary |
protected SecretKey |
engineGenerateKey()
Generates a secret key, setting odd parity and confirming that the
key is not a weak key. |
protected void |
engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
This method is not implemented as there is no AlgorithmParameterSpec
defined for DES. |
protected void |
engineInit(int strength,
java.security.SecureRandom random)
Since DES keys are of a fixed size, this method does
nothing except set the random source. |
protected void |
engineInit(java.security.SecureRandom random)
Initialises the key generator with the given random number source. |
protected void |
setOddParity(byte[] bytes)
DES Keys use the LSB as the odd parity bit. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ident
public static final java.lang.String ident
DESKeyGenerator
public DESKeyGenerator()
engineInit
protected void engineInit(java.security.spec.AlgorithmParameterSpec params,
java.security.SecureRandom random)
throws java.security.InvalidAlgorithmParameterException
- This method is not implemented as there is no AlgorithmParameterSpec
defined for DES. (Use one of the other initialisation methods!)
- Parameters:
params
- the algorithm parameter specs for this
generator.random
- a source of random numbers for this generator.- Throws:
- java.security.InvalidAlgorithmParameterException - An invalid
parameter specification is provided.
- Overrides:
- engineInit in class KeyGeneratorSpi
engineInit
protected void engineInit(java.security.SecureRandom random)
- Initialises the key generator with the given random number source.
- Parameters:
random
- a source of random numbers for this generator.- Overrides:
- engineInit in class KeyGeneratorSpi
engineInit
protected void engineInit(int strength,
java.security.SecureRandom random)
- Since DES keys are of a fixed size, this method does
nothing except set the random source.
- Parameters:
strength
- the strength of the key. This parameter is
ignored.random
- the source of randomness for this key generator- Overrides:
- engineInit in class KeyGeneratorSpi
engineGenerateKey
protected SecretKey engineGenerateKey()
- Generates a secret key, setting odd parity and confirming that the
key is not a weak key.
- Returns:
- a secret key representing a DES key.
- Overrides:
- engineGenerateKey in class KeyGeneratorSpi
setOddParity
protected void setOddParity(byte[] bytes)
- DES Keys use the LSB as the odd parity bit. This can
be used to check for corrupt keys.
- Parameters:
bytes
- the byte array to set the parity on.