Package org.h2.security
Class AES
- java.lang.Object
-
- org.h2.security.AES
-
- All Implemented Interfaces:
BlockCipher
public class AES extends java.lang.Object implements BlockCipher
An implementation of the AES block cipher algorithm, also known as Rijndael. Only AES-128 is supported by this class.
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
decKey
private int[]
encKey
private static int[]
FS
private static int[]
FT0
private static int[]
FT1
private static int[]
FT2
private static int[]
FT3
private static int[]
RCON
private static int[]
RS
private static int[]
RT0
private static int[]
RT1
private static int[]
RT2
private static int[]
RT3
-
Fields inherited from interface org.h2.security.BlockCipher
ALIGN
-
-
Constructor Summary
Constructors Constructor Description AES()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
decrypt(byte[] bytes, int off, int len)
Decrypt a number of bytes.private void
decryptBlock(byte[] in, byte[] out, int off)
void
encrypt(byte[] bytes, int off, int len)
Encrypt a number of bytes.private void
encryptBlock(byte[] in, byte[] out, int off)
private static int
getDec(int t)
int
getKeyLength()
Get the length of the key in bytes.private static int
mul(int[] pow, int[] log, int x, int y)
private static int
rot8(int x)
void
setKey(byte[] key)
Set the encryption key used for encrypting and decrypting.private static int
xtime(int x)
-
-
-
Field Detail
-
RCON
private static final int[] RCON
-
FS
private static final int[] FS
-
FT0
private static final int[] FT0
-
FT1
private static final int[] FT1
-
FT2
private static final int[] FT2
-
FT3
private static final int[] FT3
-
RS
private static final int[] RS
-
RT0
private static final int[] RT0
-
RT1
private static final int[] RT1
-
RT2
private static final int[] RT2
-
RT3
private static final int[] RT3
-
encKey
private final int[] encKey
-
decKey
private final int[] decKey
-
-
Method Detail
-
rot8
private static int rot8(int x)
-
xtime
private static int xtime(int x)
-
mul
private static int mul(int[] pow, int[] log, int x, int y)
-
getDec
private static int getDec(int t)
-
setKey
public void setKey(byte[] key)
Description copied from interface:BlockCipher
Set the encryption key used for encrypting and decrypting. The key needs to be 16 bytes long.- Specified by:
setKey
in interfaceBlockCipher
- Parameters:
key
- the key
-
encrypt
public void encrypt(byte[] bytes, int off, int len)
Description copied from interface:BlockCipher
Encrypt a number of bytes. This is done in-place, that means the bytes are overwritten.- Specified by:
encrypt
in interfaceBlockCipher
- Parameters:
bytes
- the byte arrayoff
- the start indexlen
- the number of bytes to encrypt
-
decrypt
public void decrypt(byte[] bytes, int off, int len)
Description copied from interface:BlockCipher
Decrypt a number of bytes. This is done in-place, that means the bytes are overwritten.- Specified by:
decrypt
in interfaceBlockCipher
- Parameters:
bytes
- the byte arrayoff
- the start indexlen
- the number of bytes to decrypt
-
encryptBlock
private void encryptBlock(byte[] in, byte[] out, int off)
-
decryptBlock
private void decryptBlock(byte[] in, byte[] out, int off)
-
getKeyLength
public int getKeyLength()
Description copied from interface:BlockCipher
Get the length of the key in bytes.- Specified by:
getKeyLength
in interfaceBlockCipher
- Returns:
- the length of the key
-
-