Package org.cryptacular.bean
Class AbstractBlockCipherBean
java.lang.Object
org.cryptacular.bean.AbstractCipherBean
org.cryptacular.bean.AbstractBlockCipherBean
- All Implemented Interfaces:
CipherBean
- Direct Known Subclasses:
AEADBlockCipherBean
,BufferedBlockCipherBean
Base class for all cipher beans that use block cipher.
- Author:
- Middleware Services
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance.AbstractBlockCipherBean
(KeyStore keyStore, String keyAlias, String keyPassword, Nonce nonce) Creates a new instance by specifying all properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract BlockCipherAdapter
newCipher
(CiphertextHeader header, boolean mode) Creates a new cipher adapter instance suitable for the block cipher used by this class.protected byte[]
process
(CiphertextHeader header, boolean mode, byte[] input) Processes the given data under the action of the cipher.protected void
process
(CiphertextHeader header, boolean mode, InputStream input, OutputStream output) Processes the given data under the action of the cipher.Methods inherited from class org.cryptacular.bean.AbstractCipherBean
decrypt, decrypt, encrypt, encrypt, getKeyAlias, getKeyStore, getNonce, lookupKey, setKeyAlias, setKeyPassword, setKeyStore, setNonce
-
Constructor Details
-
AbstractBlockCipherBean
public AbstractBlockCipherBean()Creates a new instance. -
AbstractBlockCipherBean
Creates a new instance by specifying all properties.- Parameters:
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
-
process
Description copied from class:AbstractCipherBean
Processes the given data under the action of the cipher.- Specified by:
process
in classAbstractCipherBean
- Parameters:
header
- Ciphertext header.mode
- True for encryption; false for decryption.input
- Data to process by cipher.- Returns:
- Ciphertext data under encryption, plaintext data under decryption.
-
process
protected void process(CiphertextHeader header, boolean mode, InputStream input, OutputStream output) Description copied from class:AbstractCipherBean
Processes the given data under the action of the cipher.- Specified by:
process
in classAbstractCipherBean
- Parameters:
header
- Ciphertext header.mode
- True for encryption; false for decryption.input
- Stream containing input data.output
- Stream that receives output of cipher.
-
newCipher
Creates a new cipher adapter instance suitable for the block cipher used by this class.- 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.
-