|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bouncycastle.crypto.engines.TwofishEngine
public final class TwofishEngine
A class that provides Twofish encryption operations. This Java implementation is based on the Java reference implementation provided by Bruce Schneier and developed by Raif S. Naffah.
Field Summary | |
---|---|
private static int |
BLOCK_SIZE
|
private boolean |
encrypting
|
private static int |
GF256_FDBK
|
private static int |
GF256_FDBK_2
|
private static int |
GF256_FDBK_4
|
private int[] |
gMDS0
|
private int[] |
gMDS1
|
private int[] |
gMDS2
|
private int[] |
gMDS3
|
private int[] |
gSBox
|
private int[] |
gSubKeys
gSubKeys[] and gSBox[] are eventually used in the encryption and decryption methods. |
private static int |
INPUT_WHITEN
|
private int |
k64Cnt
|
private static int |
MAX_KEY_BITS
|
private static int |
MAX_ROUNDS
|
private static int |
OUTPUT_WHITEN
|
private static byte[][] |
P
|
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
|
private byte[] |
workingKey
|
Constructor Summary | |
---|---|
TwofishEngine()
|
Method Summary | |
---|---|
private int |
b0(int x)
|
private int |
b1(int x)
|
private int |
b2(int x)
|
private int |
b3(int x)
|
private void |
Bits32ToBytes(int in,
byte[] b,
int offset)
|
private int |
BytesTo32Bits(byte[] b,
int p)
|
private void |
decryptBlock(byte[] src,
int srcIndex,
byte[] dst,
int dstIndex)
Decrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset. |
private void |
encryptBlock(byte[] src,
int srcIndex,
byte[] dst,
int dstIndex)
Encrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset. |
private int |
F32(int x,
int[] k32)
|
private int |
Fe32_0(int x)
|
private int |
Fe32_3(int x)
|
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 encrypting,
CipherParameters params)
initialise a Twofish cipher. |
private int |
LFSR1(int x)
|
private int |
LFSR2(int x)
|
private int |
Mx_X(int x)
|
private int |
Mx_Y(int x)
|
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 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 2 key material 32-bit entities. |
private int |
RS_rem(int x)
Reed-Solomon code parameters: (12,8) reversible code: |
private void |
setKey(byte[] key)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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 RS_GF_FDBK
private static final int ROUNDS
private static final int MAX_ROUNDS
private static final int BLOCK_SIZE
private static final int MAX_KEY_BITS
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 boolean encrypting
private int[] gMDS0
private int[] gMDS1
private int[] gMDS2
private int[] gMDS3
private int[] gSubKeys
private int[] gSBox
private int k64Cnt
private byte[] workingKey
Constructor Detail |
---|
public TwofishEngine()
Method Detail |
---|
public void init(boolean encrypting, CipherParameters params)
init
in interface BlockCipher
encrypting
- whether or not we are for encryption.params
- the parameters required to set up the cipher.
java.lang.IllegalArgumentException
- if the params argument is
inappropriate.public java.lang.String getAlgorithmName()
BlockCipher
getAlgorithmName
in interface BlockCipher
public final int processBlock(byte[] in, int inOff, byte[] out, int outOff)
BlockCipher
processBlock
in interface BlockCipher
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.
public void reset()
BlockCipher
reset
in interface BlockCipher
public int getBlockSize()
BlockCipher
getBlockSize
in interface BlockCipher
private void setKey(byte[] key)
private void encryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)
private void decryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)
private final int F32(int x, int[] k32)
private final int RS_MDS_Encode(int k0, int k1)
k0
- first 32-bit entityk1
- second 32-bit entity
private final int RS_rem(int x)
g(x) = x^4 + (a+1/a)x^3 + ax^2 + (a+1/a)x + 1where a = primitive root of field generator 0x14D
private final int LFSR1(int x)
private final int LFSR2(int x)
private final int Mx_X(int x)
private final int Mx_Y(int x)
private final int b0(int x)
private final int b1(int x)
private final int b2(int x)
private final int b3(int x)
private final int Fe32_0(int x)
private final int Fe32_3(int x)
private final int BytesTo32Bits(byte[] b, int p)
private final void Bits32ToBytes(int in, byte[] b, int offset)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |