Package org.bouncycastle.crypto.engines
Class SerpentEngineBase
java.lang.Object
org.bouncycastle.crypto.engines.SerpentEngineBase
- All Implemented Interfaces:
BlockCipher
- Direct Known Subclasses:
SerpentEngine,TnepresEngine
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected booleanprotected intprotected int[] -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voiddecryptBlock(byte[] input, int inOff, byte[] output, int outOff) protected abstract voidencryptBlock(byte[] input, int inOff, byte[] output, int outOff) Return the name of the algorithm the cipher implements.intReturn the block size for this cipher (in bytes).protected final voidib0(int[] X, 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 final voidib1(int[] X, 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 final voidib2(int[] X, 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 final voidib3(int[] X, 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 termsprotected final voidib4(int[] X, 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 final voidib5(int[] X, 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 final voidib6(int[] X, 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 final voidib7(int[] X, 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.voidinit(boolean encrypting, CipherParameters params) initialise a Serpent cipher.protected final voidinverseLT(int[] X) Apply the inverse of the linear transformation to the register set.protected final voidLT(int[] X) Apply the linear transformation to the register set.protected abstract int[]makeWorkingKey(byte[] key) final intprocessBlock(byte[] in, int inOff, byte[] out, int outOff) Process one block of input from the array in and write it to the out array.voidreset()Reset the cipher.protected static introtateLeft(int x, int bits) protected static introtateRight(int x, int bits) protected final voidsb0(int[] X, 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 final voidsb1(int[] X, 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 final voidsb2(int[] X, 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 final voidsb3(int[] X, 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 final voidsb4(int[] X, 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 final voidsb5(int[] X, 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 final voidsb6(int[] X, 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 final voidsb7(int[] X, 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.
-
Field Details
-
BLOCK_SIZE
protected static final int BLOCK_SIZE- See Also:
-
encrypting
protected boolean encrypting -
wKey
protected int[] wKey -
keyBits
protected int keyBits
-
-
Method Details
-
init
initialise a Serpent cipher.- Specified by:
initin interfaceBlockCipher- Parameters:
encrypting- whether or not we are for encryption.params- the parameters required to set up the cipher.- Throws:
IllegalArgumentException- if the params argument is inappropriate.
-
getAlgorithmName
Description copied from interface:BlockCipherReturn the name of the algorithm the cipher implements.- Specified by:
getAlgorithmNamein interfaceBlockCipher- Returns:
- the name of the algorithm the cipher implements.
-
getBlockSize
public int getBlockSize()Description copied from interface:BlockCipherReturn the block size for this cipher (in bytes).- Specified by:
getBlockSizein interfaceBlockCipher- Returns:
- the block size for this cipher in bytes.
-
processBlock
public final 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.- Specified by:
processBlockin interfaceBlockCipher- Parameters:
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.- Returns:
- the number of bytes processed and produced.
- Throws:
DataLengthException- if there isn't enough data in in, or space in out.IllegalStateException- if the cipher isn't initialised.
-
reset
public void reset()Description copied from interface:BlockCipherReset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).- Specified by:
resetin interfaceBlockCipher
-
rotateLeft
protected static int rotateLeft(int x, int bits) -
rotateRight
protected static int rotateRight(int x, int bits) -
sb0
protected final void sb0(int[] X, 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. -
ib0
protected final void ib0(int[] X, 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. -
sb1
protected final void sb1(int[] X, 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. -
ib1
protected final void ib1(int[] X, 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. -
sb2
protected final void sb2(int[] X, 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. -
ib2
protected final void ib2(int[] X, 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. -
sb3
protected final void sb3(int[] X, 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. -
ib3
protected final void ib3(int[] X, 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 -
sb4
protected final void sb4(int[] X, 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. -
ib4
protected final void ib4(int[] X, 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. -
sb5
protected final void sb5(int[] X, 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. -
ib5
protected final void ib5(int[] X, 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. -
sb6
protected final void sb6(int[] X, 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. -
ib6
protected final void ib6(int[] X, 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. -
sb7
protected final void sb7(int[] X, 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. -
ib7
protected final void ib7(int[] X, 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. -
LT
protected final void LT(int[] X) Apply the linear transformation to the register set. -
inverseLT
protected final void inverseLT(int[] X) Apply the inverse of the linear transformation to the register set. -
makeWorkingKey
protected abstract int[] makeWorkingKey(byte[] key) -
encryptBlock
protected abstract void encryptBlock(byte[] input, int inOff, byte[] output, int outOff) -
decryptBlock
protected abstract void decryptBlock(byte[] input, int inOff, byte[] output, int outOff)
-