Class TlsBlockCipher

  • All Implemented Interfaces:
    TlsCipher

    public final class TlsBlockCipher
    extends java.lang.Object
    implements TlsCipher
    A generic TLS 1.0-1.2 block cipher. This can be used for AES or 3DES for example.
    • Method Detail

      • getCiphertextDecodeLimit

        public int getCiphertextDecodeLimit​(int plaintextLimit)
        Description copied from interface: TlsCipher
        Return the maximum input size for a ciphertext given a maximum output size for the plaintext of plaintextLimit bytes.
        Specified by:
        getCiphertextDecodeLimit in interface TlsCipher
        Parameters:
        plaintextLimit - the maximum output size for the plaintext.
        Returns:
        the maximum input size of the ciphertext for plaintextLimit bytes of output.
      • getCiphertextEncodeLimit

        public int getCiphertextEncodeLimit​(int plaintextLimit)
        Description copied from interface: TlsCipher
        Return the maximum output size for a ciphertext given a maximum input size for the plaintext of plaintextLimit bytes.
        Specified by:
        getCiphertextEncodeLimit in interface TlsCipher
        Parameters:
        plaintextLimit - the maximum input size for the plaintext.
        Returns:
        the maximum output size of the ciphertext for plaintextLimit bytes of input.
      • getPlaintextDecodeLimit

        public int getPlaintextDecodeLimit​(int ciphertextLimit)
        Description copied from interface: TlsCipher
        Return the maximum output size for the plaintext given a maximum input size for the ciphertext of ciphertextLimit bytes.
        Specified by:
        getPlaintextDecodeLimit in interface TlsCipher
        Parameters:
        ciphertextLimit - the maximum input size for the ciphertext.
        Returns:
        the maximum output size of the plaintext for ciphertextLimit bytes of input.
      • getPlaintextEncodeLimit

        public int getPlaintextEncodeLimit​(int ciphertextLimit)
        Description copied from interface: TlsCipher
        Return the maximum input size for the plaintext given a maximum output size for the ciphertext of ciphertextLimit bytes.
        Specified by:
        getPlaintextEncodeLimit in interface TlsCipher
        Parameters:
        ciphertextLimit - the maximum output size for the ciphertext.
        Returns:
        the maximum input size of the plaintext for ciphertextLimit bytes of output.
      • encodePlaintext

        public TlsEncodeResult encodePlaintext​(long seqNo,
                                               short contentType,
                                               ProtocolVersion recordVersion,
                                               int headerAllocation,
                                               byte[] plaintext,
                                               int offset,
                                               int len)
                                        throws java.io.IOException
        Description copied from interface: TlsCipher
        Encode the passed in plaintext using the current bulk cipher.
        Specified by:
        encodePlaintext in interface TlsCipher
        Parameters:
        seqNo - sequence number of the message represented by plaintext.
        contentType - content type of the message represented by plaintext.
        recordVersion - ProtocolVersion used for the record.
        headerAllocation - extra bytes to allocate at start of returned byte array.
        plaintext - array holding input plaintext to the cipher.
        offset - offset into input array the plaintext starts at.
        len - length of the plaintext in the array.
        Returns:
        A TlsEncodeResult containing the result of encoding (after 'headerAllocation' unused bytes).
        Throws:
        java.io.IOException
      • decodeCiphertext

        public TlsDecodeResult decodeCiphertext​(long seqNo,
                                                short recordType,
                                                ProtocolVersion recordVersion,
                                                byte[] ciphertext,
                                                int offset,
                                                int len)
                                         throws java.io.IOException
        Description copied from interface: TlsCipher
        Decode the passed in ciphertext using the current bulk cipher.
        Specified by:
        decodeCiphertext in interface TlsCipher
        Parameters:
        seqNo - sequence number of the message represented by ciphertext.
        recordType - content type used in the record for this message.
        recordVersion - ProtocolVersion used for the record.
        ciphertext - array holding input ciphertext to the cipher.
        offset - offset into input array the ciphertext starts at.
        len - length of the ciphertext in the array.
        Returns:
        A TlsDecodeResult containing the result of decoding.
        Throws:
        java.io.IOException
      • rekeyDecoder

        public void rekeyDecoder()
                          throws java.io.IOException
        Specified by:
        rekeyDecoder in interface TlsCipher
        Throws:
        java.io.IOException
      • rekeyEncoder

        public void rekeyEncoder()
                          throws java.io.IOException
        Specified by:
        rekeyEncoder in interface TlsCipher
        Throws:
        java.io.IOException