|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.ObjectTwofish
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:
Copyright © 1998
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: #3 $
| Field Summary | |
(package private) static int |
BLOCK_SIZE
|
private static int |
GF256_FDBK
Primitive polynomial for GF(256) |
private static int |
GF256_FDBK_2
|
private static int |
GF256_FDBK_4
|
private static char[] |
HEX_DIGITS
data for hexadecimal visualisation. |
private static int |
INPUT_WHITEN
|
private static int |
MAX_ROUNDS
|
private static int[][] |
MDS
MDS matrix |
private static int |
OUTPUT_WHITEN
|
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
|
private static int |
P_02
|
private static int |
P_03
|
private static int |
P_04
|
private static int |
P_10
|
private static int |
P_11
|
private static int |
P_12
|
private static int |
P_13
|
private static int |
P_14
|
private static int |
P_20
|
private static int |
P_21
|
private static int |
P_22
|
private static int |
P_23
|
private static int |
P_24
|
private static int |
P_30
|
private static int |
P_31
|
private static int |
P_32
|
private static int |
P_33
|
private static int |
P_34
|
private static int |
ROUND_SUBKEYS
|
private static int |
ROUNDS
|
private static int |
RS_GF_FDBK
|
private static int |
SK_BUMP
|
private static int |
SK_ROTL
|
private static int |
SK_STEP
|
private static int |
TOTAL_SUBKEYS
|
| Constructor Summary | |
Twofish()
|
|
| Method Summary | |
private static int |
_b(int x,
int N)
|
private static boolean |
areEqual(byte[] a,
byte[] b)
|
private static int |
b0(int x)
|
private static int |
b1(int x)
|
private static int |
b2(int x)
|
private static int |
b3(int x)
|
static byte[] |
blockDecrypt(byte[] in,
int inOffset,
Object sessionKey)
Decrypt exactly one block of ciphertext. |
static byte[] |
blockEncrypt(byte[] in,
int inOffset,
Object sessionKey)
Encrypt exactly one block of plaintext. |
static int |
blockSize()
|
private static int |
F32(int k64Cnt,
int x,
int[] k32)
|
private static int |
Fe32(int[] sBox,
int x,
int R)
|
private static String |
intToString(int n)
Returns a string of 8 hexadecimal digits (most significant digit first) corresponding to the integer n, which is treated as unsigned. |
private static int |
LFSR1(int x)
|
private static int |
LFSR2(int x)
|
static Object |
makeKey(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)
|
static boolean |
self_test()
A basic symmetric encryption/decryption test. |
private static boolean |
self_test(int keysize)
A basic symmetric encryption/decryption test for a given key size. |
private static String |
toString(byte[] ba)
Returns a string of hexadecimal digits from a byte array. |
private static String |
toString(byte[] ba,
int offset,
int length)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
static final int BLOCK_SIZE
private static final int ROUNDS
private static final int MAX_ROUNDS
private static final int INPUT_WHITEN
private static final int OUTPUT_WHITEN
private static final int ROUND_SUBKEYS
private static final int TOTAL_SUBKEYS
private static final int SK_STEP
private static final int SK_BUMP
private static final int SK_ROTL
private static final byte[][] P
private static final int P_00
private static final int P_01
private static final int P_02
private static final int P_03
private static final int P_04
private static final int P_10
private static final int P_11
private static final int P_12
private static final int P_13
private static final int P_14
private static final int P_20
private static final int P_21
private static final int P_22
private static final int P_23
private static final int P_24
private static final int P_30
private static final int P_31
private static final int P_32
private static final int P_33
private static final int P_34
private static final int GF256_FDBK
private static final int GF256_FDBK_2
private static final int GF256_FDBK_4
private static final int[][] MDS
private static final int RS_GF_FDBK
private static final char[] HEX_DIGITS
| Constructor Detail |
public Twofish()
| Method Detail |
private static final int LFSR1(int x)
private static final int LFSR2(int x)
private static final int Mx_1(int x)
private static final int Mx_X(int x)
private static final int Mx_Y(int x)
public static Object makeKey(byte[] k)
throws InvalidKeyException
k - The 64/128/192/256-bit user-key to use.
InvalidKeyException - If the key is invalid.
public static byte[] blockEncrypt(byte[] in,
int inOffset,
Object sessionKey)
in - The plaintext.inOffset - Index of in from which to start considering data.sessionKey - The session key to use for encryption.
public static byte[] blockDecrypt(byte[] in,
int inOffset,
Object sessionKey)
in - The ciphertext.inOffset - Index of in from which to start considering data.sessionKey - The session key to use for decryption.
public static boolean self_test()
private static final int b0(int x)
private static final int b1(int x)
private static final int b2(int x)
private static final int b3(int x)
private static final int RS_MDS_Encode(int k0,
int k1)
k0 - 1st 32-bit entity.k1 - 2nd 32-bit entity.
private static final int RS_rem(int x)
private static final int F32(int k64Cnt,
int x,
int[] k32)
private static final int Fe32(int[] sBox,
int x,
int R)
private static final int _b(int x,
int N)
public static int blockSize()
private static boolean self_test(int keysize)
private static boolean areEqual(byte[] a,
byte[] b)
private static String intToString(int n)
private static String toString(byte[] ba)
private static String toString(byte[] ba,
int offset,
int length)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||