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 Details

  • 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 be null.
      forEncryption - If true 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 be null.
      plainText - The plain text. Must not be null.
      iv - The initialisation vector (IV). Must not be null.
      authData - The authenticated data. Must not be null.
      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 be null.
      iv - The initialisation vector (IV). Must not be null.
      cipherText - The cipher text. Must not be null.
      authData - The authenticated data. Must not be null.
      authTag - The authentication tag. Must not be null.
      Returns:
      The decrypted plain text.
      Throws:
      JOSEException - If decryption failed.