Class JceAEADCipherImpl
java.lang.Object
org.bouncycastle.tls.crypto.impl.jcajce.JceAEADCipherImpl
- All Implemented Interfaces:
TlsAEADCipherImpl
A basic wrapper for a JCE Cipher class to provide the needed AEAD cipher functionality for TLS.
-
Constructor Summary
ConstructorsConstructorDescriptionJceAEADCipherImpl(JcaTlsCrypto crypto, org.bouncycastle.jcajce.util.JcaJceHelper helper, String cipherName, String algorithm, int keySize, boolean isEncrypting) -
Method Summary
Modifier and TypeMethodDescriptionintdoFinal(byte[] additionalData, 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) 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.
-
Constructor Details
-
JceAEADCipherImpl
public JceAEADCipherImpl(JcaTlsCrypto crypto, org.bouncycastle.jcajce.util.JcaJceHelper helper, String cipherName, String algorithm, int keySize, boolean isEncrypting) throws GeneralSecurityException - Throws:
GeneralSecurityException
-
-
Method Details
-
setKey
public void setKey(byte[] key, int keyOff, int keyLen) Description copied from interface:TlsAEADCipherImplSet the key to be used by the AEAD cipher implementation supporting this service.- Specified by:
setKeyin interfaceTlsAEADCipherImpl- 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.
-
init
public void init(byte[] nonce, int macSize) Description copied from interface:TlsAEADCipherImplInitialise the parameters for the AEAD operator.- Specified by:
initin interfaceTlsAEADCipherImpl- Parameters:
nonce- the nonce.macSize- MAC size in bytes.
-
getOutputSize
public int getOutputSize(int inputLength) Description copied from interface:TlsAEADCipherImplReturn the maximum size of the output for input of inputLength bytes.- Specified by:
getOutputSizein interfaceTlsAEADCipherImpl- Parameters:
inputLength- the length (in bytes) of the proposed input.- Returns:
- the maximum size of the output.
-
doFinal
public int doFinal(byte[] additionalData, byte[] input, int inputOffset, int inputLength, byte[] output, int outputOffset) throws IOException Description copied from interface:TlsAEADCipherImplPerform 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.
- Specified by:
doFinalin interfaceTlsAEADCipherImpl- Parameters:
additionalData- any additional data to be included in the MAC calculation.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:
IOException- in case of failure.
-