Package org.h2.security
Class XTEA
java.lang.Object
org.h2.security.XTEA
- All Implemented Interfaces:
BlockCipher
An implementation of the XTEA block cipher algorithm.
This implementation uses 32 rounds. The best attack reported as of 2009 is 36 rounds (Wikipedia).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
private int
Fields inherited from interface org.h2.security.BlockCipher
ALIGN
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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) int
Get the length of the key in bytes.void
setKey
(byte[] b) Set the encryption key used for encrypting and decrypting.
-
Field Details
-
DELTA
private static final int DELTA- See Also:
-
k0
private int k0 -
k1
private int k1 -
k2
private int k2 -
k3
private int k3 -
k4
private int k4 -
k5
private int k5 -
k6
private int k6 -
k7
private int k7 -
k8
private int k8 -
k9
private int k9 -
k10
private int k10 -
k11
private int k11 -
k12
private int k12 -
k13
private int k13 -
k14
private int k14 -
k15
private int k15 -
k16
private int k16 -
k17
private int k17 -
k18
private int k18 -
k19
private int k19 -
k20
private int k20 -
k21
private int k21 -
k22
private int k22 -
k23
private int k23 -
k24
private int k24 -
k25
private int k25 -
k26
private int k26 -
k27
private int k27 -
k28
private int k28 -
k29
private int k29 -
k30
private int k30 -
k31
private int k31
-
-
Constructor Details
-
XTEA
public XTEA()
-
-
Method Details
-
setKey
public void setKey(byte[] b) 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:
b
- 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
-