Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

cryptix.jce.provider.key
Class DESKeyGenerator  view DESKeyGenerator download DESKeyGenerator.java

java.lang.Object
  extended byjavax.crypto.KeyGeneratorSpi
      extended bycryptix.jce.provider.key.RawKeyGenerator
          extended bycryptix.jce.provider.key.DESKeyGenerator

public class DESKeyGenerator
extends RawKeyGenerator

A key generator for DES.

Version:
$Revision: 1.7 $

Constructor Summary
DESKeyGenerator()
           
 
Method Summary
protected  javax.crypto.SecretKey engineGenerateKey()
          Generate a key, returning it as a javax.crypto.SecretKey.
protected  void engineInit(java.security.spec.AlgorithmParameterSpec params, java.security.SecureRandom random)
          Initialize this key generator with parameters and a source of randomness.
protected  void engineInit(int keysize, java.security.SecureRandom random)
          Initialize this key generator with a key size (in bits) and a source of randomness.
protected  void engineInit(java.security.SecureRandom random)
          Initialize this key generator with a source of randomness; the implementation should use reasonable default parameters (such as generated key size).
protected  byte[] fixUp(byte[] key)
          Fix the parity
protected  boolean isValidSize(int size)
          Is the given keysize valid for this algorithm?
protected  boolean isWeak(byte[] key)
          Test for weak keys
private  boolean isWeak(byte[] key, int offset)
          Returns true iff the bytes at key[offset..offset+7] represent a weak or semi-weak single DES key.
protected  int strengthToBits(int strength)
          Translates strength (complexity, 56 for DES) to bit length (64 for DES).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DESKeyGenerator

public DESKeyGenerator()
Method Detail

isWeak

protected boolean isWeak(byte[] key)
Test for weak keys

Specified by:
isWeak in class RawKeyGenerator

isWeak

private boolean isWeak(byte[] key,
                       int offset)
Returns true iff the bytes at key[offset..offset+7] represent a weak or semi-weak single DES key. It can be called either before or after setting parity bits.

(This checks for the 16 weak and semi-weak keys as given by Schneier, Applied Cryptography 2nd ed., tables 12.11 and 12.12. It does not check for the possibly-weak keys in table 12.13.)


isValidSize

protected boolean isValidSize(int size)
Description copied from class: RawKeyGenerator
Is the given keysize valid for this algorithm?

Specified by:
isValidSize in class RawKeyGenerator

strengthToBits

protected int strengthToBits(int strength)
Description copied from class: RawKeyGenerator
Translates strength (complexity, 56 for DES) to bit length (64 for DES).

Overrides:
strengthToBits in class RawKeyGenerator

fixUp

protected byte[] fixUp(byte[] key)
Fix the parity

Overrides:
fixUp in class RawKeyGenerator

engineInit

protected void engineInit(java.security.SecureRandom random)
Description copied from class: javax.crypto.KeyGeneratorSpi
Initialize this key generator with a source of randomness; the implementation should use reasonable default parameters (such as generated key size).


engineInit

protected void engineInit(java.security.spec.AlgorithmParameterSpec params,
                          java.security.SecureRandom random)
                   throws java.security.InvalidAlgorithmParameterException
Description copied from class: javax.crypto.KeyGeneratorSpi
Initialize this key generator with parameters and a source of randomness.


engineInit

protected void engineInit(int keysize,
                          java.security.SecureRandom random)
Description copied from class: javax.crypto.KeyGeneratorSpi
Initialize this key generator with a key size (in bits) and a source of randomness.


engineGenerateKey

protected javax.crypto.SecretKey engineGenerateKey()
Description copied from class: javax.crypto.KeyGeneratorSpi
Generate a key, returning it as a javax.crypto.SecretKey.