org.bouncycastle.crypto.engines
Class XTEAEngine

java.lang.Object
  extended by org.bouncycastle.crypto.engines.XTEAEngine
All Implemented Interfaces:
BlockCipher

public class XTEAEngine
extends java.lang.Object
implements BlockCipher

An XTEA engine.


Field Summary
private  boolean _forEncryption
           
private  boolean _initialised
           
private  int[] _S
           
private static int block_size
           
private static int d_sum
           
private static int delta
           
private static int key_size
           
private static int rounds
           
 
Constructor Summary
XTEAEngine()
          Create an instance of the TEA encryption algorithm and set some defaults
 
Method Summary
private  int bytesToInt(byte[] in, int inOff)
           
private  int decryptBlock(byte[] in, int inOff, byte[] out, int outOff)
           
private  int encryptBlock(byte[] in, int inOff, byte[] out, int outOff)
           
 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 forEncryption, CipherParameters params)
          initialise
 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.
private  void setKey(byte[] key)
          Re-key the cipher.
private  void unpackInt(int v, byte[] out, int outOff)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rounds

private static final int rounds
See Also:
Constant Field Values

block_size

private static final int block_size
See Also:
Constant Field Values

key_size

private static final int key_size
See Also:
Constant Field Values

delta

private static final int delta
See Also:
Constant Field Values

d_sum

private static final int d_sum
See Also:
Constant Field Values

_S

private int[] _S

_initialised

private boolean _initialised

_forEncryption

private boolean _forEncryption
Constructor Detail

XTEAEngine

public XTEAEngine()
Create an instance of the TEA encryption algorithm and set some defaults

Method Detail

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.

init

public void init(boolean forEncryption,
                 CipherParameters params)
initialise

Specified by:
init in interface BlockCipher
Parameters:
forEncryption - 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.

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

setKey

private void setKey(byte[] key)
Re-key the cipher.

Parameters:
key - the key to be used

encryptBlock

private int encryptBlock(byte[] in,
                         int inOff,
                         byte[] out,
                         int outOff)

decryptBlock

private int decryptBlock(byte[] in,
                         int inOff,
                         byte[] out,
                         int outOff)

bytesToInt

private int bytesToInt(byte[] in,
                       int inOff)

unpackInt

private void unpackInt(int v,
                       byte[] out,
                       int outOff)