public class AES
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static int |
AES_KEY_SIZE
The AES key size
We do not use 256 bit, because it makes all tests fail on Gitlab.
|
private static java.lang.String |
ALGO_TRANSFORMATION_STRING
Strings that describes all algorithm details (algorithm name + mode + padding)
|
static java.lang.String |
ALGORITHM_NAME |
Constructor and Description |
---|
AES() |
Modifier and Type | Method and Description |
---|---|
static javax.crypto.SecretKey |
createKey(byte[] aesKey)
Returns the SecretKey representing from the AES key bytes
|
static byte[] |
decrypt(byte[] encryptedMessage,
javax.crypto.SecretKey aesKey)
Decrypt a byte array message using AES algorithm
|
private static byte[] |
decrypt(byte[] encryptedMessage,
javax.crypto.SecretKey aesKey,
javax.crypto.spec.IvParameterSpec ivParameterSpec)
Decrypt a byte array message using AES algorithm and IvParameterSpec
|
static byte[] |
encrypt(byte[] message,
javax.crypto.SecretKey aesKey)
Encrypt a byte array message using AES algorithm
|
private static byte[] |
encrypt(byte[] message,
javax.crypto.SecretKey aesKey,
javax.crypto.spec.IvParameterSpec ivParameterSpec)
Encrypt a byte array message using AES algorithm and IvParameterSpec
|
static byte[] |
encrypt(java.lang.String message,
javax.crypto.SecretKey aesKey)
Encrypt a string message using AES algorithm
|
private static byte[] |
encrypt(java.lang.String message,
javax.crypto.SecretKey aesKey,
javax.crypto.spec.IvParameterSpec ivParameterSpec)
Encrypt a string message using AES algorithm and IvParameters
|
static javax.crypto.SecretKey |
generateAESKey() |
private static javax.crypto.spec.IvParameterSpec |
getIvParameterSpec()
Build the initialization vector, this vector is used to prevent for bruteforce (Rainbow) attack,
which is required for our AES encryption scheme.
|
public static final java.lang.String ALGORITHM_NAME
private static final int AES_KEY_SIZE
private static final java.lang.String ALGO_TRANSFORMATION_STRING
public static javax.crypto.SecretKey generateAESKey()
public static javax.crypto.SecretKey createKey(byte[] aesKey)
aesKey
- private static javax.crypto.spec.IvParameterSpec getIvParameterSpec()
public static byte[] encrypt(java.lang.String message, javax.crypto.SecretKey aesKey)
message
- aesKey
- public static byte[] encrypt(byte[] message, javax.crypto.SecretKey aesKey)
message
- aesKey
- private static byte[] encrypt(java.lang.String message, javax.crypto.SecretKey aesKey, javax.crypto.spec.IvParameterSpec ivParameterSpec)
message
- aesKey
- ivParameterSpec
- private static byte[] encrypt(byte[] message, javax.crypto.SecretKey aesKey, javax.crypto.spec.IvParameterSpec ivParameterSpec)
message
- aesKey
- ivParameterSpec
- public static byte[] decrypt(byte[] encryptedMessage, javax.crypto.SecretKey aesKey)
encryptedMessage
- aesKey
- private static byte[] decrypt(byte[] encryptedMessage, javax.crypto.SecretKey aesKey, javax.crypto.spec.IvParameterSpec ivParameterSpec)
encryptedMessage
- aesKey
- ivParameterSpec
-