Package org.cryptacular.adapter
Class AEADBlockCipherAdapter
java.lang.Object
org.cryptacular.adapter.AEADBlockCipherAdapter
- All Implemented Interfaces:
BlockCipherAdapter
,CipherAdapter
Adapts a
AEADBlockCipherAdapter
.- Author:
- Middleware Services
-
Constructor Summary
ConstructorsConstructorDescriptionAEADBlockCipherAdapter
(org.bouncycastle.crypto.modes.AEADBlockCipher delegate) Creates a new instance that delegates to the given cipher. -
Method Summary
Modifier and TypeMethodDescriptionint
doFinal
(byte[] out, int outOff) Finish the encryption/decryption operation (e.g.int
getOutputSize
(int len) Gets the size of the output buffer required to hold the output of an input buffer of the given size.void
init
(boolean forEncryption, org.bouncycastle.crypto.CipherParameters params) Initialize the underlying cipher.int
processBytes
(byte[] in, int inOff, int len, byte[] out, int outOff) Process an array of bytes, producing output if necessary.void
reset()
Reset the cipher.
-
Constructor Details
-
AEADBlockCipherAdapter
public AEADBlockCipherAdapter(org.bouncycastle.crypto.modes.AEADBlockCipher delegate) Creates a new instance that delegates to the given cipher.- Parameters:
delegate
- Adapted cipher.
-
-
Method Details
-
getOutputSize
public int getOutputSize(int len) Description copied from interface:BlockCipherAdapter
Gets the size of the output buffer required to hold the output of an input buffer of the given size.- Specified by:
getOutputSize
in interfaceBlockCipherAdapter
- Parameters:
len
- Length of input buffer.- Returns:
- Size of output buffer.
-
init
public void init(boolean forEncryption, org.bouncycastle.crypto.CipherParameters params) throws CryptoException Description copied from interface:CipherAdapter
Initialize the underlying cipher.- Specified by:
init
in interfaceCipherAdapter
- Parameters:
forEncryption
- True for encryption mode, false for decryption mode.params
- Cipher initialization parameters.- Throws:
CryptoException
- on underlying cipher initialization errors.
-
processBytes
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff) throws CryptoException Description copied from interface:CipherAdapter
Process an array of bytes, producing output if necessary.- Specified by:
processBytes
in interfaceCipherAdapter
- Parameters:
in
- Input data.inOff
- Offset at which the input data starts.len
- The number of bytes in the input data to process.out
- Array to receive any data produced by cipher.outOff
- Offset into output array.- Returns:
- The number of bytes produced by the cipher.
- Throws:
CryptoException
- on underlying cipher data handling errors.
-
doFinal
Description copied from interface:BlockCipherAdapter
Finish the encryption/decryption operation (e.g. apply padding).- Specified by:
doFinal
in interfaceBlockCipherAdapter
- Parameters:
out
- Output buffer to receive final processing output.outOff
- Offset into output buffer where processed data should start.- Returns:
- Number of bytes written to output buffer.
- Throws:
CryptoException
- on underlying cipher finalization errors.
-
reset
public void reset()Description copied from interface:CipherAdapter
Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).- Specified by:
reset
in interfaceCipherAdapter
-