public class BlowFish extends java.lang.Object implements BlockCipher
Modifier and Type | Field and Description |
---|---|
private static int |
BLOCK_SIZE |
private boolean |
doEncrypt |
private static int[] |
KP |
private static int[] |
KS0 |
private static int[] |
KS1 |
private static int[] |
KS2 |
private static int[] |
KS3 |
private int[] |
P |
private static int |
P_SZ |
private static int |
ROUNDS |
private int[] |
S0 |
private int[] |
S1 |
private int[] |
S2 |
private int[] |
S3 |
private static int |
SBOX_SK |
private byte[] |
workingKey |
Constructor and Description |
---|
BlowFish() |
Modifier and Type | Method and Description |
---|---|
private void |
Bits32ToBytes(int in,
byte[] b,
int offset) |
private int |
BytesTo32bits(byte[] b,
int i) |
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 |
F(int x) |
java.lang.String |
getAlgorithmName() |
int |
getBlockSize() |
void |
init(boolean encrypting,
byte[] key)
initialise a Blowfish cipher.
|
private void |
processTable(int xl,
int xr,
int[] table)
apply the encryption cycle to each value pair in the table.
|
void |
reset() |
private void |
setKey(byte[] key) |
void |
transformBlock(byte[] in,
int inOff,
byte[] out,
int outOff) |
private static final int[] KP
private static final int[] KS0
private static final int[] KS1
private static final int[] KS2
private static final int[] KS3
private static final int ROUNDS
private static final int BLOCK_SIZE
private static final int SBOX_SK
private static final int P_SZ
private final int[] S0
private final int[] S1
private final int[] S2
private final int[] S3
private final int[] P
private boolean doEncrypt
private byte[] workingKey
public void init(boolean encrypting, byte[] key)
init
in interface BlockCipher
encrypting
- whether or not we are for encryption.key
- the key required to set up the cipher.java.lang.IllegalArgumentException
- if the params argument is inappropriate.public java.lang.String getAlgorithmName()
public final void transformBlock(byte[] in, int inOff, byte[] out, int outOff)
transformBlock
in interface BlockCipher
public void reset()
public int getBlockSize()
getBlockSize
in interface BlockCipher
private int F(int x)
private void processTable(int xl, int xr, int[] table)
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 int BytesTo32bits(byte[] b, int i)
private void Bits32ToBytes(int in, byte[] b, int offset)