Top Description Fields Constructors Methods
org.bouncycastle.crypto.engines

public Class DESEngine

extends DESBase
implements BlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.BlockCipher
Imports
org.bouncycastle.crypto.BlockCipher, .CipherParameters, .CryptoServicesRegistrar, .DataLengthException, .OutputLengthException, org.bouncycastle.crypto.constraints.DefaultServiceProperties, org.bouncycastle.crypto.params.KeyParameter, org.bouncycastle.util.Pack

a class that provides a basic DES engine.

Field Summary

Modifier and TypeField and Description
private static final int[]
protected static final int
private static final short[]
bytebit

Hides org.bouncycastle.crypto.engines.DESBase.bytebit.

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

Constructor Summary

AccessConstructor and Description
public
DESEngine()

standard constructor.

Method Summary

Modifier and TypeMethod and Description
protected void
desFunc(int[] wKey, byte[] in, int inOff, byte[] out, int outOff)

Overrides org.bouncycastle.crypto.engines.DESBase.desFunc.

the DES engine.
protected int[]
generateWorkingKey(boolean encrypting, byte[] key)

Overrides org.bouncycastle.crypto.engines.DESBase.generateWorkingKey.

generate an integer based working key based on our secret key and what we processing we are planning to do.
public String
getAlgorithmName()

Implements org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.
public int
getBlockSize()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).
public void
init(boolean
whether or not we are for encryption.
encrypting
,
CipherParameters
the parameters required to set up the cipher.
params
)

Implements org.bouncycastle.crypto.BlockCipher.init.

initialise a DES cipher.
public int
processBlock(byte[]
the array containing the input data.
in
,
int
offset into the in array the data starts at.
inOff
,
byte[]
the array the output data will be copied into.
out
,
int
the offset into the out array the output will start at.
outOff
)

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.
public void
reset()

Implements org.bouncycastle.crypto.BlockCipher.reset.

Reset the cipher.

Field Detail

bigbyteback to summary
private static final int[] bigbyte

Hides org.bouncycastle.crypto.engines.DESBase.bigbyte.

BLOCK_SIZEback to summary
protected static final int BLOCK_SIZE

Hides org.bouncycastle.crypto.engines.DESBase.BLOCK_SIZE.

bytebitback to summary
private static final short[] bytebit

Hides org.bouncycastle.crypto.engines.DESBase.bytebit.

what follows is mainly taken from "Applied Cryptography", by Bruce Schneier, however it also bears great resemblance to Richard Outerbridge's D3DES...

forEncryptionback to summary
private boolean forEncryption
pc1back to summary
private static final byte[] pc1

Hides org.bouncycastle.crypto.engines.DESBase.pc1.

pc2back to summary
private static final byte[] pc2

Hides org.bouncycastle.crypto.engines.DESBase.pc2.

SP1back to summary
private static final int[] SP1

Hides org.bouncycastle.crypto.engines.DESBase.SP1.

SP2back to summary
private static final int[] SP2

Hides org.bouncycastle.crypto.engines.DESBase.SP2.

SP3back to summary
private static final int[] SP3

Hides org.bouncycastle.crypto.engines.DESBase.SP3.

SP4back to summary
private static final int[] SP4

Hides org.bouncycastle.crypto.engines.DESBase.SP4.

SP5back to summary
private static final int[] SP5

Hides org.bouncycastle.crypto.engines.DESBase.SP5.

SP6back to summary
private static final int[] SP6

Hides org.bouncycastle.crypto.engines.DESBase.SP6.

SP7back to summary
private static final int[] SP7

Hides org.bouncycastle.crypto.engines.DESBase.SP7.

SP8back to summary
private static final int[] SP8

Hides org.bouncycastle.crypto.engines.DESBase.SP8.

totrotback to summary
private static final byte[] totrot

Hides org.bouncycastle.crypto.engines.DESBase.totrot.

workingKeyback to summary
private int[] workingKey

Constructor Detail

DESEngineback to summary
public DESEngine()

standard constructor.

Method Detail

desFuncback to summary
protected void desFunc(int[] wKey, byte[] in, int inOff, byte[] out, int outOff)

Overrides org.bouncycastle.crypto.engines.DESBase.desFunc.

the DES engine.

generateWorkingKeyback to summary
protected int[] generateWorkingKey(boolean encrypting, byte[] key)

Overrides org.bouncycastle.crypto.engines.DESBase.generateWorkingKey.

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!).

getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.

Returns:String

the name of the algorithm the cipher implements.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

Doc from org.bouncycastle.crypto.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).

Returns:int

the block size for this cipher in bytes.

initback to summary
public void init(boolean encrypting, CipherParameters params)

Implements org.bouncycastle.crypto.BlockCipher.init.

initialise a DES cipher.

Parameters
encrypting:boolean

whether or not we are for encryption.

params:CipherParameters

the parameters required to set up the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
processBlockback to summary
public int processBlock(byte[] in, int inOff, byte[] out, int outOff)

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Doc from org.bouncycastle.crypto.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.

Parameters
in:byte[]

the array containing the input data.

inOff:int

offset into the in array the data starts at.

out:byte[]

the array the output data will be copied into.

outOff:int

the offset into the out array the output will start at.

Returns:int

the number of bytes processed and produced.

resetback to summary
public void reset()

Implements org.bouncycastle.crypto.BlockCipher.reset.

Doc from org.bouncycastle.crypto.BlockCipher.reset.

Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).