org.bouncycastle.crypto.engines
Class DESEngine

java.lang.Object
  extended by org.bouncycastle.crypto.engines.DESEngine
All Implemented Interfaces:
BlockCipher
Direct Known Subclasses:
DESedeEngine

public class DESEngine
extends java.lang.Object
implements BlockCipher

a class that provides a basic DES engine.


Field Summary
private static int[] bigbyte
           
protected static int BLOCK_SIZE
           
private static short[] bytebit
           
private static short[] Df_Key
          what follows is mainly taken from "Applied Cryptography", by Bruce Schneier, however it also bears great resemblance to Richard Outerbridge's D3DES...
private static byte[] pc1
           
private static byte[] pc2
           
private static int[] SP1
           
private static int[] SP2
           
private static int[] SP3
           
private static int[] SP4
           
private static int[] SP5
           
private static int[] SP6
           
private static int[] SP7
           
private static int[] SP8
           
private static byte[] totrot
           
private  int[] workingKey
           
 
Constructor Summary
DESEngine()
          standard constructor.
 
Method Summary
protected  void desFunc(int[] wKey, byte[] in, int inOff, byte[] out, int outOff)
          the DES engine.
protected  int[] generateWorkingKey(boolean encrypting, byte[] key)
          generate an integer based working key based on our secret key and what we processing we are planning to do.
 java.lang.String getAlgorithmName()
          Return the name of the algorithm the cipher implements.
 int getBlockSize()
          Return the block size for this cipher (in bytes).
 void init(boolean encrypting, CipherParameters params)
          initialise a DES cipher.
 int processBlock(byte[] in, int inOff, byte[] out, int outOff)
          Process one block of input from the array in and write it to the out array.
 void reset()
          Reset the cipher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE

protected static final int BLOCK_SIZE
See Also:
Constant Field Values

workingKey

private int[] workingKey

Df_Key

private static final short[] Df_Key
what follows is mainly taken from "Applied Cryptography", by Bruce Schneier, however it also bears great resemblance to Richard Outerbridge's D3DES...


bytebit

private static final short[] bytebit

bigbyte

private static final int[] bigbyte

pc1

private static final byte[] pc1

totrot

private static final byte[] totrot

pc2

private static final byte[] pc2

SP1

private static final int[] SP1

SP2

private static final int[] SP2

SP3

private static final int[] SP3

SP4

private static final int[] SP4

SP5

private static final int[] SP5

SP6

private static final int[] SP6

SP7

private static final int[] SP7

SP8

private static final int[] SP8
Constructor Detail

DESEngine

public DESEngine()
standard constructor.

Method Detail

init

public void init(boolean encrypting,
                 CipherParameters params)
initialise a DES cipher.

Specified by:
init in interface BlockCipher
Parameters:
encrypting - whether or not we are for encryption.
params - the parameters required to set up the cipher.
Throws:
java.lang.IllegalArgumentException - if the params argument is inappropriate.

getAlgorithmName

public java.lang.String getAlgorithmName()
Description copied from interface: BlockCipher
Return the name of the algorithm the cipher implements.

Specified by:
getAlgorithmName in interface BlockCipher
Returns:
the name of the algorithm the cipher implements.

getBlockSize

public int getBlockSize()
Description copied from interface: BlockCipher
Return the block size for this cipher (in bytes).

Specified by:
getBlockSize in interface BlockCipher
Returns:
the block size for this cipher in bytes.

processBlock

public int processBlock(byte[] in,
                        int inOff,
                        byte[] out,
                        int outOff)
Description copied from interface: BlockCipher
Process one block of input from the array in and write it to the out array.

Specified by:
processBlock in interface BlockCipher
Parameters:
in - the array containing the input data.
inOff - offset into the in array the data starts at.
out - the array the output data will be copied into.
outOff - the offset into the out array the output will start at.
Returns:
the number of bytes processed and produced.

reset

public void reset()
Description copied from interface: BlockCipher
Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).

Specified by:
reset in interface BlockCipher

generateWorkingKey

protected int[] generateWorkingKey(boolean encrypting,
                                   byte[] key)
generate an integer based working key based on our secret key and what we processing we are planning to do. Acknowledgements for this routine go to James Gillogly & Phil Karn. (whoever, and wherever they are!).


desFunc

protected void desFunc(int[] wKey,
                       byte[] in,
                       int inOff,
                       byte[] out,
                       int outOff)
the DES engine.