Top Fields Constructors Methods
org.bouncycastle.crypto.general

pack-priv abstract Class SerpentEngineBase

extends Object
implements BlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.internal.BlockCipher
Known Direct Subclasses
org.bouncycastle.crypto.general.SerpentEngine
Imports
org.bouncycastle.crypto.internal.BlockCipher, .CipherParameters, .DataLengthException, .OutputLengthException, org.bouncycastle.crypto.internal.params.KeyParameter

Field Summary

Modifier and TypeField and Description
protected static final int
protected boolean
pack-priv static final int
pack-priv static final int
protected int[]
protected int
protected int
protected int
protected int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod 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)

public String
getAlgorithmName()

Implements org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.
public int
getBlockSize()

Implements org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).
protected final 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 final 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 final 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 final 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 final 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 final 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 final 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 final 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.

public void
init(boolean
whether or not we are for encryption.
encrypting
,
CipherParameters
the parameters required to set up the cipher.
params
)

Implements org.bouncycastle.crypto.internal.BlockCipher.init.

initialise a Serpent cipher.
protected final void
inverseLT()

Apply the inverse of the linear transformation to the register set.

protected final void
LT()

Apply the linear transformation to the register set.

protected abstract int[]
makeWorkingKey(byte[] key)

public final int

Returns:

the number of bytes processed and produced.
processBlock
(byte[]
the array containing the input data.
in
,
int
offset into the in array the data starts at.
inOff
,
byte[]
the array the output data will be copied into.
out
,
int
the offset into the out array the output will start at.
outOff
)

Implements org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.
public void
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)

S0 - { 3, 8,15, 1,10, 6, 5,11,14,13, 4, 2, 7, 0, 9,12 } - 15 terms.

protected final 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 final 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 final 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 final 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 final 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 final 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 final 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLOCK_SIZEback to summary
protected static final int BLOCK_SIZE
encryptingback to summary
protected boolean encrypting
PHIback to summary
pack-priv static final int PHI
ROUNDSback to summary
pack-priv static final int ROUNDS
wKeyback to summary
protected int[] wKey
X0back to summary
protected int X0
X1back to summary
protected int X1
X2back to summary
protected int X2
X3back to summary
protected int X3

Constructor Detail

SerpentEngineBaseback to summary
pack-priv SerpentEngineBase()

Method Detail

decryptBlockback to summary
protected abstract void decryptBlock(byte[] input, int inOff, byte[] output, int outOff)
encryptBlockback to summary
protected abstract void encryptBlock(byte[] input, int inOff, byte[] output, int outOff)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.

Returns:String

the name of the algorithm the cipher implements.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Doc from org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).

Returns:int

the block size for this cipher in bytes.

ib0back to summary
protected final 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.

ib1back to summary
protected final 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.

ib2back to summary
protected final 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.

ib3back to summary
protected final 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

ib4back to summary
protected final 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.

ib5back to summary
protected final 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.

ib6back to summary
protected final 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.

ib7back to summary
protected final 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.

initback to summary
public void init(boolean encrypting, CipherParameters params)

Implements org.bouncycastle.crypto.internal.BlockCipher.init.

initialise a Serpent cipher.

Parameters
encrypting:boolean

whether or not we are for encryption.

params:CipherParameters

the parameters required to set up the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
inverseLTback to summary
protected final void inverseLT()

Apply the inverse of the linear transformation to the register set.

LTback to summary
protected final void LT()

Apply the linear transformation to the register set.

makeWorkingKeyback to summary
protected abstract int[] makeWorkingKey(byte[] key)
processBlockback to summary
public final int processBlock(byte[] in, int inOff, byte[] out, int outOff)

Implements org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.

Parameters
in:byte[]

the array containing the input data.

inOff:int

offset into the in array the data starts at.

out:byte[]

the array the output data will be copied into.

outOff:int

the offset into the out array the output will start at.

Returns:int

the number of bytes processed and produced.

Exceptions
DataLengthException:
if there isn't enough data in in, or space in out.
IllegalStateException:
if the cipher isn't initialised.
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.internal.BlockCipher.reset.

Doc from org.bouncycastle.crypto.internal.BlockCipher.reset.

Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).

rotateLeftback to summary
protected static int rotateLeft(int x, int bits)
rotateRightback to summary
protected static int rotateRight(int x, int bits)
sb0back to summary
protected final 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.

sb1back to summary
protected final 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.

sb2back to summary
protected final 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.

sb3back to summary
protected final 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.

sb4back to summary
protected final 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.

sb5back to summary
protected final 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.

sb6back to summary
protected final 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.

sb7back to summary
protected final 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.