Class JceAEADCipherImpl

  • All Implemented Interfaces:
    TlsAEADCipherImpl

    public class JceAEADCipherImpl
    extends java.lang.Object
    implements TlsAEADCipherImpl
    A basic wrapper for a JCE Cipher class to provide the needed AEAD cipher functionality for TLS.
    • Constructor Summary

      Constructors 
      Constructor Description
      JceAEADCipherImpl​(org.bouncycastle.jcajce.util.JcaJceHelper helper, java.lang.String cipherName, java.lang.String algorithm, int keySize, boolean isEncrypting)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int doFinal​(byte[] input, int inputOffset, int inputLength, byte[] extraInput, byte[] output, int outputOffset)
      Perform the cipher encryption/decryption returning the output in output.
      int getOutputSize​(int inputLength)
      Return the maximum size of the output for input of inputLength bytes.
      void init​(byte[] nonce, int macSize, byte[] additionalData)
      Initialise the parameters for the AEAD operator.
      void setKey​(byte[] key, int keyOff, int keyLen)
      Set the key to be used by the AEAD cipher implementation supporting this service.
      protected int updateCipher​(byte[] input, int inOff, int inLen, byte[] output, int outOff)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JceAEADCipherImpl

        public JceAEADCipherImpl​(org.bouncycastle.jcajce.util.JcaJceHelper helper,
                                 java.lang.String cipherName,
                                 java.lang.String algorithm,
                                 int keySize,
                                 boolean isEncrypting)
                          throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException
    • Method Detail

      • setKey

        public void setKey​(byte[] key,
                           int keyOff,
                           int keyLen)
        Description copied from interface: TlsAEADCipherImpl
        Set the key to be used by the AEAD cipher implementation supporting this service.
        Specified by:
        setKey in interface TlsAEADCipherImpl
        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,
                         byte[] additionalData)
        Description copied from interface: TlsAEADCipherImpl
        Initialise the parameters for the AEAD operator.
        Specified by:
        init in interface TlsAEADCipherImpl
        Parameters:
        nonce - the nonce.
        macSize - MAC size in bytes.
        additionalData - any additional data to be included in the MAC calculation.
      • getOutputSize

        public int getOutputSize​(int inputLength)
        Description copied from interface: TlsAEADCipherImpl
        Return the maximum size of the output for input of inputLength bytes.
        Specified by:
        getOutputSize in interface TlsAEADCipherImpl
        Parameters:
        inputLength - the length (in bytes) of the proposed input.
        Returns:
        the maximum size of the output.
      • doFinal

        public int doFinal​(byte[] input,
                           int inputOffset,
                           int inputLength,
                           byte[] extraInput,
                           byte[] output,
                           int outputOffset)
                    throws java.io.IOException
        Description copied from interface: TlsAEADCipherImpl
        Perform 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:
        doFinal in interface TlsAEADCipherImpl
        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.
        extraInput - extra input data to the cipher. Only allowed when encrypting.
        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.
      • updateCipher

        protected int updateCipher​(byte[] input,
                                   int inOff,
                                   int inLen,
                                   byte[] output,
                                   int outOff)
                            throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException