|
|||||||||
| Home >> All >> cryptix >> jce >> provider >> [ cipher overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
cryptix.jce.provider.cipher
Class Twofish

java.lang.Objectjavax.crypto.CipherSpi
cryptix.jce.provider.cipher.BlockCipher
cryptix.jce.provider.cipher.Twofish
- public final class Twofish
- extends BlockCipher
Twofish is an AES candidate algorithm. It is a balanced 128-bit Feistel cipher, consisting of 16 rounds. In each round, a 64-bit S-box value is computed from 64 bits of the block, and this value is xored into the other half of the block. The two half-blocks are then exchanged, and the next round begins. Before the first round, all input bits are xored with key- dependent "whitening" subkeys, and after the final round the output bits are xored with other key-dependent whitening subkeys; these subkeys are not used anywhere else in the algorithm.
Twofish was submitted by Bruce Schneier, Doug Whiting, John Kelsey, Chris Hall and David Wagner.
Reference:
- TWOFISH2.C -- Optimized C API calls for TWOFISH AES submission, Version 1.00, April 1998, by Doug Whiting.
- Version:
- $Revision: 1.4 $
| Field Summary | |
private static int |
BLOCK_SIZE
|
private boolean |
decrypt
Encrypt (false) or decrypt mode (true) |
private static int |
GF256_FDBK
Primitive polynomial for GF(256) |
private static int |
GF256_FDBK_2
Primitive polynomial for GF(256) |
private static int |
GF256_FDBK_4
Primitive polynomial for GF(256) |
private static int[][] |
MDS
MDS matrix |
private static byte[][] |
P
Fixed 8x8 permutation S-boxes |
private static int |
P_00
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_01
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_02
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_03
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_04
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_10
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_11
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_12
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_13
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_14
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_20
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_21
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_22
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_23
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_24
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_30
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_31
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_32
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_33
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
P_34
Define the fixed p0/p1 permutations used in keyed S-box lookup. |
private static int |
ROUNDS
|
private static int |
RS_GF_FDBK
|
private int[] |
sBox
Key dependent S-box |
private static int |
SK_BUMP
|
private static int |
SK_ROTL
|
private int[] |
subKeys
Subkeys |
private static int |
TOTAL_SUBKEYS
|
| Fields inherited from class cryptix.jce.provider.cipher.BlockCipher |
|
| Constructor Summary | |
Twofish()
|
|
| Method Summary | |
private static int |
_b(int x,
int N)
|
private static int |
b0(int x)
|
private static int |
b1(int x)
|
private static int |
b2(int x)
|
private static int |
b3(int x)
|
private void |
blockCrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Encrypt exactly one block of plaintext. |
protected void |
coreCrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Encrypt a given buffer. |
protected void |
coreInit(java.security.Key key,
boolean decrypt)
|
private static int |
F32(int k64Cnt,
int x,
int[] k32)
|
private static int |
Fe32(int[] sBox,
int x,
int R)
|
private static int |
LFSR1(int x)
|
private static int |
LFSR2(int x)
|
private void |
makeSubKeys(byte[] k)
Expand a user-supplied key material into a session key. |
private static int |
Mx_1(int x)
|
private static int |
Mx_X(int x)
|
private static int |
Mx_Y(int x)
|
private static int |
RS_MDS_Encode(int k0,
int k1)
Use (12, 8) Reed-Solomon code over GF(256) to produce a key S-box 32-bit entity from two key material 32-bit entities. |
private static int |
RS_rem(int x)
|
| Methods inherited from class cryptix.jce.provider.cipher.BlockCipher |
clone, coreGetBlockSize, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate |
| Methods inherited from class javax.crypto.CipherSpi |
engineDoFinal, engineUnwrap, engineUpdate, engineWrap |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
BLOCK_SIZE
private static final int BLOCK_SIZE
- See Also:
- Constant Field Values
ROUNDS
private static final int ROUNDS
- See Also:
- Constant Field Values
TOTAL_SUBKEYS
private static final int TOTAL_SUBKEYS
- See Also:
- Constant Field Values
SK_BUMP
private static final int SK_BUMP
- See Also:
- Constant Field Values
SK_ROTL
private static final int SK_ROTL
- See Also:
- Constant Field Values
P
private static final byte[][] P
- Fixed 8x8 permutation S-boxes
P_00
private static final int P_00
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_01
private static final int P_01
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_02
private static final int P_02
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_03
private static final int P_03
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_04
private static final int P_04
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_10
private static final int P_10
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_11
private static final int P_11
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_12
private static final int P_12
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_13
private static final int P_13
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_14
private static final int P_14
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_20
private static final int P_20
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_21
private static final int P_21
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_22
private static final int P_22
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_23
private static final int P_23
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_24
private static final int P_24
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_30
private static final int P_30
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_31
private static final int P_31
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_32
private static final int P_32
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_33
private static final int P_33
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
P_34
private static final int P_34
- Define the fixed p0/p1 permutations used in keyed S-box lookup.
By changing the following constant definitions, the S-boxes will
automatically get changed in the Twofish engine.
- See Also:
- Constant Field Values
GF256_FDBK
private static final int GF256_FDBK
- Primitive polynomial for GF(256)
- See Also:
- Constant Field Values
GF256_FDBK_2
private static final int GF256_FDBK_2
- Primitive polynomial for GF(256)
- See Also:
- Constant Field Values
GF256_FDBK_4
private static final int GF256_FDBK_4
- Primitive polynomial for GF(256)
- See Also:
- Constant Field Values
MDS
private static final int[][] MDS
- MDS matrix
RS_GF_FDBK
private static final int RS_GF_FDBK
- See Also:
- Constant Field Values
decrypt
private boolean decrypt
- Encrypt (false) or decrypt mode (true)
sBox
private final int[] sBox
- Key dependent S-box
subKeys
private final int[] subKeys
- Subkeys
| Constructor Detail |
Twofish
public Twofish()
| Method Detail |
LFSR1
private static final int LFSR1(int x)
LFSR2
private static final int LFSR2(int x)
Mx_1
private static final int Mx_1(int x)
Mx_X
private static final int Mx_X(int x)
Mx_Y
private static final int Mx_Y(int x)
coreInit
protected void coreInit(java.security.Key key, boolean decrypt) throws java.security.InvalidKeyException
- Specified by:
coreInitin classBlockCipher
coreCrypt
protected void coreCrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
- Description copied from class:
BlockCipher - Encrypt a given buffer. in and out can point to the same buffer if
(outOffset == inOffset) || (outOffset >= (inOffset+coreGetBlockSize))
That is: the buffers may not partially overlap...
- Specified by:
coreCryptin classBlockCipher
makeSubKeys
private final void makeSubKeys(byte[] k)
throws java.security.InvalidKeyException
- Expand a user-supplied key material into a session key.
blockCrypt
private final void blockCrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
- Encrypt exactly one block of plaintext. Blocks may overlap.
b0
private static final int b0(int x)
b1
private static final int b1(int x)
b2
private static final int b2(int x)
b3
private static final int b3(int x)
RS_MDS_Encode
private static final int RS_MDS_Encode(int k0,
int k1)
- Use (12, 8) Reed-Solomon code over GF(256) to produce a key S-box
32-bit entity from two key material 32-bit entities.
RS_rem
private static final int RS_rem(int x)
F32
private static final int F32(int k64Cnt,
int x,
int[] k32)
Fe32
private static final int Fe32(int[] sBox,
int x,
int R)
_b
private static final int _b(int x,
int N)
|
|||||||||
| Home >> All >> cryptix >> jce >> provider >> [ cipher overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC