Package org.cryptacular.bean
Class AEADBlockCipherBean
java.lang.Object
org.cryptacular.bean.AbstractCipherBean
org.cryptacular.bean.AbstractBlockCipherBean
org.cryptacular.bean.AEADBlockCipherBean
- All Implemented Interfaces:
CipherBean
Cipher bean that performs encryption with a block cipher in AEAD mode (e.g. GCM, CCM).
- Author:
- Middleware Services
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
decrypt
(InputStream input, OutputStream output) Decrypts the data from the input stream onto the output stream using a symmetric cipher.void
encrypt
(InputStream input, OutputStream output) Encrypts the data from the input stream onto the output stream using a symmetric cipher.Spec<org.bouncycastle.crypto.modes.AEADBlockCipher>
protected AEADBlockCipherAdapter
newCipher
(CiphertextHeader header, boolean mode) Creates a new cipher adapter instance suitable for the block cipher used by this class.void
setBlockCipherSpec
(Spec<org.bouncycastle.crypto.modes.AEADBlockCipher> blockCipherSpec) Sets the AEAD block cipher specification.Methods inherited from class org.cryptacular.bean.AbstractBlockCipherBean
process, process
Methods inherited from class org.cryptacular.bean.AbstractCipherBean
decrypt, encrypt, getKeyAlias, getKeyStore, getNonce, lookupKey, setKeyAlias, setKeyPassword, setKeyStore, setNonce
-
Field Details
-
MAC_SIZE_BITS
public static final int MAC_SIZE_BITSMac 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
- Returns:
- Block cipher specification.
-
setBlockCipherSpec
Sets the AEAD block cipher specification.- Parameters:
blockCipherSpec
- Describes a block cipher in terms of algorithm, mode, and padding.
-
encrypt
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 interfaceCipherBean
- Overrides:
encrypt
in classAbstractCipherBean
- Parameters:
input
- Input stream containing plaintext data to encrypt.output
- Output stream containing ciphertext produced by cipher in encryption mode.
-
decrypt
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 interfaceCipherBean
- Overrides:
decrypt
in classAbstractCipherBean
- Parameters:
input
- Input stream containing ciphertext data to decrypt.output
- Output stream containing plaintext produced by cipher in decryption mode.
-
newCipher
Description copied from class:AbstractBlockCipherBean
Creates a new cipher adapter instance suitable for the block cipher used by this class.- Specified by:
newCipher
in classAbstractBlockCipherBean
- 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.
-