Package org.bouncycastle.tls.crypto.impl
Interface TlsAEADCipherImpl
-
- All Known Implementing Classes:
BcChaCha20Poly1305,JceAEADCipherImpl,JceChaCha20Poly1305
public interface TlsAEADCipherImplBase interface for services supporting AEAD encryption/decryption.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intdoFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset)Perform the cipher encryption/decryption returning the output in output.intgetOutputSize(int inputLength)Return the maximum size of the output for input of inputLength bytes.voidinit(byte[] nonce, int macSize, byte[] additionalData)Initialise the parameters for the AEAD operator.voidsetKey(byte[] key, int keyOff, int keyLen)Set the key to be used by the AEAD cipher implementation supporting this service.
-
-
-
Method Detail
-
setKey
void setKey(byte[] key, int keyOff, int keyLen) throws java.io.IOExceptionSet the key to be used by the AEAD cipher implementation supporting this service.- Parameters:
key- array holding the AEAD cipher key.keyOff- offset into the array the key starts at.keyLen- length of the key in the array.- Throws:
java.io.IOException
-
init
void init(byte[] nonce, int macSize, byte[] additionalData) throws java.io.IOExceptionInitialise the parameters for the AEAD operator.- Parameters:
nonce- the nonce.macSize- MAC size in bytes.additionalData- any additional data to be included in the MAC calculation.- Throws:
java.io.IOException- if the parameters are inappropriate.
-
getOutputSize
int getOutputSize(int inputLength)
Return the maximum size of the output for input of inputLength bytes.- Parameters:
inputLength- the length (in bytes) of the proposed input.- Returns:
- the maximum size of the output.
-
doFinal
int doFinal(byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws java.io.IOExceptionPerform the cipher encryption/decryption returning the output in output.Note: we have to use doFinal() here as it is the only way to guarantee output from the underlying cipher.
- Parameters:
input- array holding input data to the cipher.inputOffset- offset into input array data starts at.inputLength- length of the input data in the array.output- array to hold the cipher output.outputOffset- offset into output array to start saving output.- Returns:
- the amount of data written to output.
- Throws:
java.io.IOException- in case of failure.
-
-