de.bb.security
Class DES

java.lang.Object
  |
  +--de.bb.security.BlockCipher
        |
        +--de.bb.security.DES
Direct Known Subclasses:
DES2, DES3

public class DES
extends BlockCipher


Fields inherited from class de.bb.security.BlockCipher
blockSize
 
Constructor Summary
  DES()
          Creates a new DesCipher object for en- and decrypting
protected DES(int kl)
          for derived classes as DES2 (2-key 3-DES) and DES3 (3-key 3-DES)
 
Method Summary
 void decrypt(byte[] cipherText, int cipherOff, byte[] clearText, int clearOff)
          Decrypt one block of bytes.
 void encrypt(byte[] clearText, int clearOff, byte[] cipherText, int cipherOff)
          Encrypt one block of bytes.
static void establishParity(byte[] key)
          Add an odd parity to the given key.
 byte[] generateKey()
          Create a new DES key and ensure that it is not a weak key.
static boolean isOdd(byte _v)
          isOdd
static boolean keyIsWeak(byte[] key)
          Check if the given key is a weak key.
protected  void makeKeyData(byte[] key)
           
 void setKey(byte[] key)
          Set the key for encryption and decryption.
 void setKeyUnchecked(byte[] key)
          Set the key for encryption and decryption.
 
Methods inherited from class de.bb.security.BlockCipher
blockSize, decryptCBC, decryptCBCAndPadd, decryptECB, encryptCBC, encryptCBCAndPadd, encryptECB, getBufferLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DES

public DES()
Creates a new DesCipher object for en- and decrypting

DES

protected DES(int kl)
for derived classes as DES2 (2-key 3-DES) and DES3 (3-key 3-DES)
Method Detail

setKeyUnchecked

public void setKeyUnchecked(byte[] key)
Set the key for encryption and decryption.
Parameters:
key - the given key, an array with 8 bytes

makeKeyData

protected void makeKeyData(byte[] key)

setKey

public void setKey(byte[] key)
Set the key for encryption and decryption.
Overrides:
setKey in class BlockCipher
Parameters:
key - the given key, an array with 8 bytes

encrypt

public void encrypt(byte[] clearText,
                    int clearOff,
                    byte[] cipherText,
                    int cipherOff)
Encrypt one block of bytes. You may use one byte array as input data and output data, to encrypt in place.
Overrides:
encrypt in class BlockCipher
Parameters:
clearText - input data which is encrypted
clearOff - offset into input data
cipherText - output data which is encrypted.
cipherOff - offset into output data

decrypt

public void decrypt(byte[] cipherText,
                    int cipherOff,
                    byte[] clearText,
                    int clearOff)
Decrypt one block of bytes. You may use one byte array as input data and output data, to decrypt in place.
Overrides:
decrypt in class BlockCipher
Parameters:
cipherText - output data which is encrypted.
cipherOff - offset into output data
clearText - input data which is encrypted
clearOff - offset into input data

keyIsWeak

public static final boolean keyIsWeak(byte[] key)
Check if the given key is a weak key.
Parameters:
key - this key is testes against the known weak keys.
Returns:
true if the key is a weak key.

establishParity

public static final void establishParity(byte[] key)
Add an odd parity to the given key.
Parameters:
key - this key is made odd.

isOdd

public static final boolean isOdd(byte _v)
isOdd

generateKey

public byte[] generateKey()
Create a new DES key and ensure that it is not a weak key.
Returns:
a new allocated byte array containing the key.