Class AEADBlockCipherBean

All Implemented Interfaces:
CipherBean

public class AEADBlockCipherBean extends AbstractBlockCipherBean
Cipher bean that performs encryption with a block cipher in AEAD mode (e.g. GCM, CCM).
Author:
Middleware Services
  • Field Details

    • MAC_SIZE_BITS

      public static final int MAC_SIZE_BITS
      Mac size in bits.
      See Also:
  • Constructor Details

    • AEADBlockCipherBean

      public AEADBlockCipherBean()
      Creates a new instance.
    • AEADBlockCipherBean

      public AEADBlockCipherBean(Spec<org.bouncycastle.crypto.modes.AEADBlockCipher> blockCipherSpec, KeyStore keyStore, String keyAlias, String keyPassword, Nonce nonce)
      Creates a new instance by specifying all properties.
      Parameters:
      blockCipherSpec - Block cipher specification.
      keyStore - Key store containing encryption key.
      keyAlias - Name of encryption key entry in key store.
      keyPassword - Password used to decrypt key entry in keystore.
      nonce - Nonce/IV generator.
  • Method Details

    • getBlockCipherSpec

      public Spec<org.bouncycastle.crypto.modes.AEADBlockCipher> getBlockCipherSpec()
      Returns:
      Block cipher specification.
    • setBlockCipherSpec

      public void setBlockCipherSpec(Spec<org.bouncycastle.crypto.modes.AEADBlockCipher> blockCipherSpec)
      Sets the AEAD block cipher specification.
      Parameters:
      blockCipherSpec - Describes a block cipher in terms of algorithm, mode, and padding.
    • encrypt

      public void encrypt(InputStream input, OutputStream output)
      Description copied from interface: CipherBean
      Encrypts the data from the input stream onto the output stream using a symmetric cipher.

      The caller is responsible for providing and managing the streams (e.g. closing them when finished).

      Specified by:
      encrypt in interface CipherBean
      Overrides:
      encrypt in class AbstractCipherBean
      Parameters:
      input - Input stream containing plaintext data to encrypt.
      output - Output stream containing ciphertext produced by cipher in encryption mode.
    • decrypt

      public void decrypt(InputStream input, OutputStream output)
      Description copied from interface: CipherBean
      Decrypts the data from the input stream onto the output stream using a symmetric cipher.

      The caller is responsible for providing and managing the streams (e.g. closing them when finished).

      Specified by:
      decrypt in interface CipherBean
      Overrides:
      decrypt in class AbstractCipherBean
      Parameters:
      input - Input stream containing ciphertext data to decrypt.
      output - Output stream containing plaintext produced by cipher in decryption mode.
    • newCipher

      protected AEADBlockCipherAdapter newCipher(CiphertextHeader header, boolean mode)
      Description copied from class: AbstractBlockCipherBean
      Creates a new cipher adapter instance suitable for the block cipher used by this class.
      Specified by:
      newCipher in class AbstractBlockCipherBean
      Parameters:
      header - Ciphertext header.
      mode - True for encryption; false for decryption.
      Returns:
      Block cipher adapter that wraps an initialized block cipher that is ready for use in the given mode.