Package com.nimbusds.jose.crypto.impl
Class LegacyAESGCM
- java.lang.Object
-
- com.nimbusds.jose.crypto.impl.LegacyAESGCM
-
@ThreadSafe public class LegacyAESGCM extends Object
Legacy AES/GSM/NoPadding encryption and decryption methods. Uses the BouncyCastle.org API. This class is thread-safe.- Version:
- 2015-11-15
- Author:
- Vladimir Dzhuvinov, Axel Nennker
-
-
Field Summary
Fields Modifier and Type Field Description static int
AUTH_TAG_BIT_LENGTH
The standard authentication tag length (128 bits).
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.bouncycastle.crypto.engines.AESEngine
createAESCipher(SecretKey secretKey, boolean forEncryption)
Creates a new AES cipher.static byte[]
decrypt(SecretKey secretKey, byte[] iv, byte[] cipherText, byte[] authData, byte[] authTag)
Decrypts the specified cipher text using AES/GCM/NoPadding.static AuthenticatedCipherText
encrypt(SecretKey secretKey, byte[] iv, byte[] plainText, byte[] authData)
Encrypts the specified plain text using AES/GCM/NoPadding.
-
-
-
Field Detail
-
AUTH_TAG_BIT_LENGTH
public static final int AUTH_TAG_BIT_LENGTH
The standard authentication tag length (128 bits).- See Also:
- Constant Field Values
-
-
Method Detail
-
createAESCipher
public static org.bouncycastle.crypto.engines.AESEngine createAESCipher(SecretKey secretKey, boolean forEncryption)
Creates a new AES cipher.- Parameters:
secretKey
- The AES key. Must not benull
.forEncryption
- Iftrue
creates an AES encryption cipher, else creates an AES decryption cipher.- Returns:
- The AES cipher.
-
encrypt
public static AuthenticatedCipherText encrypt(SecretKey secretKey, byte[] iv, byte[] plainText, byte[] authData) throws JOSEException
Encrypts the specified plain text using AES/GCM/NoPadding.- Parameters:
secretKey
- The AES key. Must not benull
.plainText
- The plain text. Must not benull
.iv
- The initialisation vector (IV). Must not benull
.authData
- The authenticated data. Must not benull
.- Returns:
- The authenticated cipher text.
- Throws:
JOSEException
- If encryption failed.
-
decrypt
public static byte[] decrypt(SecretKey secretKey, byte[] iv, byte[] cipherText, byte[] authData, byte[] authTag) throws JOSEException
Decrypts the specified cipher text using AES/GCM/NoPadding.- Parameters:
secretKey
- The AES key. Must not benull
.iv
- The initialisation vector (IV). Must not benull
.cipherText
- The cipher text. Must not benull
.authData
- The authenticated data. Must not benull
.authTag
- The authentication tag. Must not benull
.- Returns:
- The decrypted plain text.
- Throws:
JOSEException
- If decryption failed.
-
-