|
Bouncy Castle Cryptography Library 1.77.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.bouncycastle.crypto.engines.ThreefishEngine
Implementation of the Threefish tweakable large block cipher in 256, 512 and 1024 bit block sizes.
This is the 1.3 version of Threefish defined in the Skein hash function submission to the NIST SHA-3 competition in October 2010.
Threefish was designed by Niels Ferguson - Stefan Lucks - Bruce Schneier - Doug Whiting - Mihir Bellare - Tadayoshi Kohno - Jon Callas - Jesse Walker.
This implementation inlines all round functions, unrolls 8 rounds, and uses 1.2k of static tables to speed up key schedule injection. 2 x block size state is retained by each cipher instance.
Field Summary | |
static int |
BLOCKSIZE_1024
1024 bit block size - Threefish-1024 |
static int |
BLOCKSIZE_256
256 bit block size - Threefish-256 |
static int |
BLOCKSIZE_512
512 bit block size - Threefish-512 |
Constructor Summary | |
ThreefishEngine(int blocksizeBits)
Constructs a new Threefish cipher, with a specified block size. |
Method Summary | |
static long |
bytesToWord(byte[] bytes,
int off)
Deprecated. Will be removed |
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 the engine. |
void |
init(boolean forEncryption,
long[] key,
long[] tweak)
Initialise the engine, specifying the key and tweak directly. |
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. |
int |
processBlock(long[] in,
long[] out)
Process a block of data represented as 64 bit words. |
void |
reset()
Reset the cipher. |
static void |
wordToBytes(long word,
byte[] bytes,
int off)
Deprecated. Will be removed |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int BLOCKSIZE_256
public static final int BLOCKSIZE_512
public static final int BLOCKSIZE_1024
Constructor Detail |
public ThreefishEngine(int blocksizeBits)
blocksizeBits
- the block size in bits, one of BLOCKSIZE_256
, BLOCKSIZE_512
,
BLOCKSIZE_1024
.Method Detail |
public void init(boolean forEncryption, CipherParameters params) throws java.lang.IllegalArgumentException
init
in interface BlockCipher
params
- an instance of TweakableBlockCipherParameters
, or KeyParameter
(to
use a 0 tweak)public void init(boolean forEncryption, long[] key, long[] tweak)
forEncryption
- the cipher mode.key
- the words of the key, or null to use the current key.tweak
- the 2 word (128 bit) tweak, or null to use the current tweak.public java.lang.String getAlgorithmName()
BlockCipher
getAlgorithmName
in interface BlockCipher
org.bouncycastle.crypto.BlockCipher
public int getBlockSize()
BlockCipher
getBlockSize
in interface BlockCipher
org.bouncycastle.crypto.BlockCipher
public void reset()
BlockCipher
reset
in interface BlockCipher
public int processBlock(byte[] in, int inOff, byte[] out, int outOff) throws DataLengthException, java.lang.IllegalStateException
BlockCipher
processBlock
in interface BlockCipher
org.bouncycastle.crypto.BlockCipher
input
- the array containing the input data.inOff
- offset into the in array the data starts at.output
- the array the output data will be copied into.outOff
- the offset into the out array the output will start at.DataLengthException
- if there isn't enough data in input , or
space in out.java.lang.IllegalStateException
- if the cipher isn't initialised.public int processBlock(long[] in, long[] out) throws DataLengthException, java.lang.IllegalStateException
in
- a block sized buffer of words to process.out
- a block sized buffer of words to receive the output of the operation.DataLengthException
- if either the input or output is not block sized.java.lang.IllegalStateException
- if this engine is not initialised.public static long bytesToWord(byte[] bytes, int off)
public static void wordToBytes(long word, byte[] bytes, int off)
|
Bouncy Castle Cryptography Library 1.77.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |