|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bouncycastle.crypto.engines.SerpentEngine
public class SerpentEngine
Serpent is a 128-bit 32-round block cipher with variable key lengths, including 128, 192 and 256 bit keys conjectured to be at least as secure as three-key triple-DES.
Serpent was designed by Ross Anderson, Eli Biham and Lars Knudsen as a candidate algorithm for the NIST AES Quest.>
For full details see the The Serpent home page
Field Summary | |
---|---|
private static int |
BLOCK_SIZE
|
private boolean |
encrypting
|
(package private) static int |
PHI
|
(package private) static int |
ROUNDS
|
private int[] |
wKey
|
private int |
X0
|
private int |
X1
|
private int |
X2
|
private int |
X3
|
Constructor Summary | |
---|---|
SerpentEngine()
|
Method Summary | |
---|---|
private int |
bytesToWord(byte[] src,
int srcOff)
|
private void |
decryptBlock(byte[] in,
int inOff,
byte[] out,
int outOff)
Decrypt one block of ciphertext. |
private void |
encryptBlock(byte[] in,
int inOff,
byte[] out,
int outOff)
Encrypt one block of plaintext. |
java.lang.String |
getAlgorithmName()
Return the name of the algorithm the cipher implements. |
int |
getBlockSize()
Return the block size for this cipher (in bytes). |
private 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. |
private 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. |
private 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. |
private 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 |
private 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. |
private 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. |
private 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. |
private 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. |
private void |
inverseLT()
Apply the inverse of the linear transformation to the register set. |
private void |
LT()
Apply the linear transformation to the register set. |
private int[] |
makeWorkingKey(byte[] key)
Expand a user-supplied key material into a session 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. |
private int |
rotateLeft(int x,
int bits)
|
private int |
rotateRight(int x,
int bits)
|
private 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. |
private 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. |
private 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. |
private 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. |
private 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. |
private 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. |
private 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. |
private 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. |
private void |
wordToBytes(int word,
byte[] dst,
int dstOff)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final int BLOCK_SIZE
static final int ROUNDS
static final int PHI
private boolean encrypting
private int[] wKey
private int X0
private int X1
private int X2
private int X3
Constructor Detail |
---|
public SerpentEngine()
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 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
private int[] makeWorkingKey(byte[] key) throws java.lang.IllegalArgumentException
key
- The user-key bytes (multiples of 4) to use.
java.lang.IllegalArgumentException
private int rotateLeft(int x, int bits)
private int rotateRight(int x, int bits)
private int bytesToWord(byte[] src, int srcOff)
private void wordToBytes(int word, byte[] dst, int dstOff)
private void encryptBlock(byte[] in, int inOff, byte[] out, int outOff)
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.private void decryptBlock(byte[] in, int inOff, byte[] out, int outOff)
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.private void sb0(int a, int b, int c, int d)
private void ib0(int a, int b, int c, int d)
private void sb1(int a, int b, int c, int d)
private void ib1(int a, int b, int c, int d)
private void sb2(int a, int b, int c, int d)
private void ib2(int a, int b, int c, int d)
private void sb3(int a, int b, int c, int d)
private void ib3(int a, int b, int c, int d)
private void sb4(int a, int b, int c, int d)
private void ib4(int a, int b, int c, int d)
private void sb5(int a, int b, int c, int d)
private void ib5(int a, int b, int c, int d)
private void sb6(int a, int b, int c, int d)
private void ib6(int a, int b, int c, int d)
private void sb7(int a, int b, int c, int d)
private void ib7(int a, int b, int c, int d)
private void LT()
private void inverseLT()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |