nl.warper.threefish
Class ThreefishImpl

java.lang.Object
  extended by nl.warper.threefish.ThreefishImpl

public class ThreefishImpl
extends java.lang.Object

Very early initial implementation of the Threefish encryption algorithm. For performance reasons, this class is definately not thead safe.

Since:
4 nov 2008
Version:
$Revision: $
Author:
maartenb, $Author: $

Field Summary
static int BLOCK_SIZE_BITS_1024
           
static int BLOCK_SIZE_BITS_256
           
static int BLOCK_SIZE_BITS_512
           
 
Constructor Summary
ThreefishImpl(int blockSize)
          Threefish implementation using the specified blocksize in bits.
ThreefishImpl(int blockSize, int rounds)
          Threefish implementation using the specified blocksize in bits, specifying the number of rounds directly instead of using the default number of rounds depending on the blockSize.
 
Method Summary
 void blockDecrypt(long[] c, long[] p)
          Implementation of the D(K, T, C) function.
 void blockEncrypt(long[] p, long[] c)
          Implementation of the E(K, T, P) function.
 int getBlockSize()
          Simply returns the block size in bits as set by the constructor.
 void init(long[] key, long[] tweak)
          Initialize the cipher using the key and the tweak value.
 void init(javax.crypto.SecretKey key, long[] tweak)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLOCK_SIZE_BITS_256

public static final int BLOCK_SIZE_BITS_256
See Also:
Constant Field Values

BLOCK_SIZE_BITS_512

public static final int BLOCK_SIZE_BITS_512
See Also:
Constant Field Values

BLOCK_SIZE_BITS_1024

public static final int BLOCK_SIZE_BITS_1024
See Also:
Constant Field Values
Constructor Detail

ThreefishImpl

public ThreefishImpl(int blockSize)
Threefish implementation using the specified blocksize in bits.

Parameters:
blockSize - either 256, 512 or 1024 (bits)

ThreefishImpl

public ThreefishImpl(int blockSize,
                     int rounds)
Threefish implementation using the specified blocksize in bits, specifying the number of rounds directly instead of using the default number of rounds depending on the blockSize. Mainly used for (performance) testing purposes.

Parameters:
blockSize - either 256, 512 or 1024 (bits)
rounds - the number of rounds 1..2^31
Method Detail

init

public void init(javax.crypto.SecretKey key,
                 long[] tweak)

init

public void init(long[] key,
                 long[] tweak)
Initialize the cipher using the key and the tweak value.

Parameters:
key - the Threefish key to use
tweak - the tweak values to use

blockEncrypt

public void blockEncrypt(long[] p,
                         long[] c)
Implementation of the E(K, T, P) function. The K and T values should be set previously using the init() method. This version is the 64 bit implementation of Threefish.

Parameters:
p - the initial plain text
c - the final value defined as value v{d} where d = N{r}

blockDecrypt

public void blockDecrypt(long[] c,
                         long[] p)
Implementation of the D(K, T, C) function. The K and T values should be set previously using the init() method. This version is the 64 bit implementation of Threefish.

Parameters:
c - the cipher text
p - the plain text

getBlockSize

public int getBlockSize()
Simply returns the block size in bits as set by the constructor. The block size cannot be altered after the instance has been constructed.

Returns:
the block size in bits