For further details see: https://csrc.nist.gov/encryption/aes/. This implementation is based on optimizations from Dr. Brian Gladman's paper and C code at https://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 slowest performance version with no static tables for round precomputation, but it has the smallest foot print.
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private boolean | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int[] | |
| private int | |
| private static final byte[] | |
| private static final byte[] | |
| private int[][] |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| private void | |
| private void | |
| private static int | |
| private static int | |
| 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 |
| public String | getAlgorithmName()
Implements org. |
| public int | getBlockSize()
Implements org. |
| public void | init(boolean
whether or not we are for encryption. forEncryption, CipherParameters the parameters required to set up the cipher. params)Implements org. |
| private static int | |
| private static int | |
| public int | 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. |
| public void | |
| private static int | |
| private static int |
| BLOCK_SIZE | back to summary |
|---|---|
| private static final int BLOCK_SIZE | |
| forEncryption | back to summary |
|---|---|
| private boolean forEncryption | |
| m1 | back to summary |
|---|---|
| private static final int m1 | |
| m2 | back to summary |
|---|---|
| private static final int m2 | |
| m3 | back to summary |
|---|---|
| private static final int m3 | |
| m4 | back to summary |
|---|---|
| private static final int m4 | |
| m5 | back to summary |
|---|---|
| private static final int m5 | |
| rcon | back to summary |
|---|---|
| private static final int[] rcon | |
| ROUNDS | back to summary |
|---|---|
| private int ROUNDS | |
| S | back to summary |
|---|---|
| private static final byte[] S | |
| Si | back to summary |
|---|---|
| private static final byte[] Si | |
| WorkingKey | back to summary |
|---|---|
| private int[][] WorkingKey | |
| AESLightEngine | back to summary |
|---|---|
| public AESLightEngine() default constructor - 128 bit block size. | |
| bitsOfSecurity | back to summary |
|---|---|
| private int bitsOfSecurity() | |
| decryptBlock | back to summary |
|---|---|
| private void decryptBlock(byte[] in, int inOff, byte[] out, int outOff, int[][] KW) | |
| encryptBlock | back to summary |
|---|---|
| private void encryptBlock(byte[] in, int inOff, byte[] out, int outOff, int[][] KW) | |
| FFmulX | back to summary |
|---|---|
| private static int FFmulX(int x) | |
| FFmulX2 | back to summary |
|---|---|
| private static int FFmulX2(int x) | |
| generateWorkingKey | back to summary |
|---|---|
| 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 | |
| getAlgorithmName | back to summary |
|---|---|
| public String getAlgorithmName() Implements org. Doc from org. Return the name of the algorithm the cipher implements.
| |
| getBlockSize | back to summary |
|---|---|
| public int getBlockSize() Implements org. Doc from org. Return the block size for this cipher (in bytes).
| |
| init | back to summary |
|---|---|
| public void init(boolean forEncryption, CipherParameters params) Implements org. initialise an AES cipher.
| |
| inv_mcol | back to summary |
|---|---|
| private static int inv_mcol(int x) | |
| mcol | back to summary |
|---|---|
| private static int mcol(int x) | |
| processBlock | back to summary |
|---|---|
| public int processBlock(byte[] in, int inOff, byte[] out, int outOff) Implements org. Doc from org. Process one block of input from the array in and write it to the out array.
| |
| reset | back to summary |
|---|---|
| public void reset() Implements org. Doc from org. Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one). | |
| shift | back to summary |
|---|---|
| private static int shift(int r, int shift) | |
| subWord | back to summary |
|---|---|
| private static int subWord(int x) | |