|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.bouncycastle.crypto.engines.AESEngine
public class AESEngine
an implementation of the AES (Rijndael), from FIPS-197.
For further details see: http://csrc.nist.gov/encryption/aes/. This implementation is based on optimizations from Dr. Brian Gladman's paper and C code at http://fp.gladman.plus.com/cryptography_technology/rijndael/ There are three levels of tradeoff of speed vs memory Because java has no preprocessor, they are written as three separate classes from which to choose The fastest uses 8Kbytes of static tables to precompute round calculations, 4 256 word tables for encryption and 4 for decryption. The middle performance version uses only one 256 word table for each, for a total of 2Kbytes, adding 12 rotate operations per round to compute the values contained in the other tables from the contents of the first. The slowest version uses no static tables at all and computes the values in each round.
This file contains the middle performance version with 2Kbytes of static tables for round precomputation.
Field Summary | |
---|---|
private static int |
BLOCK_SIZE
|
private int |
C0
|
private int |
C1
|
private int |
C2
|
private int |
C3
|
private boolean |
forEncryption
|
private static int |
m1
|
private static int |
m2
|
private static int |
m3
|
private static int[] |
rcon
|
private int |
ROUNDS
|
private static byte[] |
S
|
private static byte[] |
Si
|
private static int[] |
T0
|
private static int[] |
Tinv0
|
private int[][] |
WorkingKey
|
Constructor Summary | |
---|---|
AESEngine()
default constructor - 128 bit block size. |
Method Summary | |
---|---|
private void |
decryptBlock(int[][] KW)
|
private void |
encryptBlock(int[][] KW)
|
private int |
FFmulX(int x)
|
private int[][] |
generateWorkingKey(byte[] key,
boolean forEncryption)
Calculate the necessary round keys The number of calculations depends on key size and block size AES specified a fixed block size of 128 bits and key sizes 128/192/256 bits This code is written assuming those are the only possible values |
java.lang.String |
getAlgorithmName()
Return the name of the algorithm the cipher implements. |
int |
getBlockSize()
Return the block size for this cipher (in bytes). |
void |
init(boolean forEncryption,
CipherParameters params)
initialise an AES cipher. |
private int |
inv_mcol(int x)
|
private void |
packBlock(byte[] bytes,
int off)
|
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 |
shift(int r,
int shift)
|
private int |
subWord(int x)
|
private void |
unpackBlock(byte[] bytes,
int off)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final byte[] S
private static final byte[] Si
private static final int[] rcon
private static final int[] T0
private static final int[] Tinv0
private static final int m1
private static final int m2
private static final int m3
private int ROUNDS
private int[][] WorkingKey
private int C0
private int C1
private int C2
private int C3
private boolean forEncryption
private static final int BLOCK_SIZE
Constructor Detail |
---|
public AESEngine()
Method Detail |
---|
private int shift(int r, int shift)
private int FFmulX(int x)
private int inv_mcol(int x)
private int subWord(int x)
private int[][] generateWorkingKey(byte[] key, boolean forEncryption)
public void init(boolean forEncryption, CipherParameters params)
init
in interface BlockCipher
forEncryption
- 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 int processBlock(byte[] in, int inOff, byte[] out, int outOff)
BlockCipher
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.
public void reset()
BlockCipher
reset
in interface BlockCipher
private final void unpackBlock(byte[] bytes, int off)
private final void packBlock(byte[] bytes, int off)
private final void encryptBlock(int[][] KW)
private final void decryptBlock(int[][] KW)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |