public abstract class SerpentEngineBase extends java.lang.Object implements BlockCipher
Modifier and Type | Field and Description |
---|---|
protected static int |
BLOCK_SIZE |
protected boolean |
encrypting |
protected int[] |
wKey |
protected int |
X0 |
protected int |
X1 |
protected int |
X2 |
protected int |
X3 |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
decryptBlock(byte[] input,
int inOff,
byte[] output,
int outOff) |
protected abstract void |
encryptBlock(byte[] input,
int inOff,
byte[] output,
int outOff) |
java.lang.String |
getAlgorithmName()
Return the name of the algorithm the cipher implements.
|
int |
getBlockSize()
Return the block size for this cipher (in bytes).
|
protected void |
ib0(int a,
int b,
int c,
int d)
InvSO - {13, 3,11, 0,10, 6, 5,12, 1,14, 4, 7,15, 9, 8, 2 } - 15 terms.
|
protected void |
ib1(int a,
int b,
int c,
int d)
InvS1 - { 5, 8, 2,14,15, 6,12, 3,11, 4, 7, 9, 1,13,10, 0 } - 14 steps.
|
protected void |
ib2(int a,
int b,
int c,
int d)
InvS2 - {12, 9,15, 4,11,14, 1, 2, 0, 3, 6,13, 5, 8,10, 7 } - 16 steps.
|
protected void |
ib3(int a,
int b,
int c,
int d)
InvS3 - { 0, 9,10, 7,11,14, 6,13, 3, 5,12, 2, 4, 8,15, 1 } - 15 terms
|
protected void |
ib4(int a,
int b,
int c,
int d)
InvS4 - { 5, 0, 8, 3,10, 9, 7,14, 2,12,11, 6, 4,15,13, 1 } - 15 terms.
|
protected void |
ib5(int a,
int b,
int c,
int d)
InvS5 - { 8,15, 2, 9, 4, 1,13,14,11, 6, 5, 3, 7,12,10, 0 } - 16 terms.
|
protected void |
ib6(int a,
int b,
int c,
int d)
InvS6 - {15,10, 1,13, 5, 3, 6, 0, 4, 9,14, 7, 2,12, 8,11 } - 15 terms.
|
protected void |
ib7(int a,
int b,
int c,
int d)
InvS7 - { 3, 0, 6,13, 9,14,15, 8, 5,12,11, 7,10, 1, 4, 2 } - 17 terms.
|
void |
init(boolean encrypting,
CipherParameters params)
initialise a Serpent cipher.
|
protected void |
inverseLT()
Apply the inverse of the linear transformation to the register set.
|
protected void |
LT()
Apply the linear transformation to the register set.
|
protected abstract int[] |
makeWorkingKey(byte[] key) |
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.
|
protected static int |
rotateLeft(int x,
int bits) |
protected static int |
rotateRight(int x,
int bits) |
protected void |
sb0(int a,
int b,
int c,
int d)
S0 - { 3, 8,15, 1,10, 6, 5,11,14,13, 4, 2, 7, 0, 9,12 } - 15 terms.
|
protected void |
sb1(int a,
int b,
int c,
int d)
S1 - {15,12, 2, 7, 9, 0, 5,10, 1,11,14, 8, 6,13, 3, 4 } - 14 terms.
|
protected void |
sb2(int a,
int b,
int c,
int d)
S2 - { 8, 6, 7, 9, 3,12,10,15,13, 1,14, 4, 0,11, 5, 2 } - 16 terms.
|
protected void |
sb3(int a,
int b,
int c,
int d)
S3 - { 0,15,11, 8,12, 9, 6, 3,13, 1, 2, 4,10, 7, 5,14 } - 16 terms.
|
protected void |
sb4(int a,
int b,
int c,
int d)
S4 - { 1,15, 8, 3,12, 0,11, 6, 2, 5, 4,10, 9,14, 7,13 } - 15 terms.
|
protected void |
sb5(int a,
int b,
int c,
int d)
S5 - {15, 5, 2,11, 4,10, 9,12, 0, 3,14, 8,13, 6, 7, 1 } - 16 terms.
|
protected void |
sb6(int a,
int b,
int c,
int d)
S6 - { 7, 2,12, 5, 8, 4, 6,11,14, 9, 1,15,13, 3,10, 0 } - 15 terms.
|
protected void |
sb7(int a,
int b,
int c,
int d)
S7 - { 1,13,15, 0,14, 8, 2,11, 7, 4,12,10, 9, 3, 5, 6 } - 16 terms.
|
protected static final int BLOCK_SIZE
protected boolean encrypting
protected int[] wKey
protected int X0
protected int X1
protected int X2
protected int X3
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 int getBlockSize()
BlockCipher
getBlockSize
in interface BlockCipher
public final int processBlock(byte[] in, int inOff, byte[] out, int outOff)
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.DataLengthException
- if there isn't enough data in in, or
space in out.java.lang.IllegalStateException
- if the cipher isn't initialised.public void reset()
BlockCipher
reset
in interface BlockCipher
protected static int rotateLeft(int x, int bits)
protected static int rotateRight(int x, int bits)
protected final void sb0(int a, int b, int c, int d)
protected final void ib0(int a, int b, int c, int d)
protected final void sb1(int a, int b, int c, int d)
protected final void ib1(int a, int b, int c, int d)
protected final void sb2(int a, int b, int c, int d)
protected final void ib2(int a, int b, int c, int d)
protected final void sb3(int a, int b, int c, int d)
protected final void ib3(int a, int b, int c, int d)
protected final void sb4(int a, int b, int c, int d)
protected final void ib4(int a, int b, int c, int d)
protected final void sb5(int a, int b, int c, int d)
protected final void ib5(int a, int b, int c, int d)
protected final void sb6(int a, int b, int c, int d)
protected final void ib6(int a, int b, int c, int d)
protected final void sb7(int a, int b, int c, int d)
protected final void ib7(int a, int b, int c, int d)
protected final void LT()
protected final void inverseLT()
protected abstract int[] makeWorkingKey(byte[] key)
protected abstract void encryptBlock(byte[] input, int inOff, byte[] output, int outOff)
protected abstract void decryptBlock(byte[] input, int inOff, byte[] output, int outOff)