Package com.nimbusds.jose.crypto.impl
Class LegacyAESGCM
java.lang.Object
com.nimbusds.jose.crypto.impl.LegacyAESGCM
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
FieldsModifier and TypeFieldDescriptionstatic final int
The standard authentication tag length (128 bits). -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bouncycastle.crypto.engines.AESEngine
createAESCipher
(SecretKey secretKey, boolean forEncryption) Creates a new AES cipher.static byte[]
Decrypts the specified cipher text using AES/GCM/NoPadding.static AuthenticatedCipherText
Encrypts the specified plain text using AES/GCM/NoPadding.
-
Field Details
-
AUTH_TAG_BIT_LENGTH
The standard authentication tag length (128 bits).- See Also:
-
-
Method Details
-
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.
-