Package org.conscrypt

Class ConnectionState

java.lang.Object
org.conscrypt.ConnectionState
Direct Known Subclasses:
ConnectionStateSSLv3, ConnectionStateTLS

public abstract class ConnectionState
extends Object
This abstract class is a base for Record Protocol operating environmet of different SSL protocol versions.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected int block_size
    The block size, or zero if not a block cipher
    protected Cipher decCipher
    The cipher used for decode operations
    protected Cipher encCipher
    The cipher used for encode operations
    protected int hash_size
    The size of MAC used under this connection state
    protected Logger.Stream logger  
    protected byte[] read_seq_num
    Read sequence number which is incremented after each decrypt call
    protected byte[] write_seq_num
    Write sequence number which is incremented after each encrypt call
  • Constructor Summary

    Constructors
    Constructor Description
    ConnectionState()  
  • Method Summary

    Modifier and Type Method Description
    protected byte[] decrypt​(byte type, byte[] fragment)
    Retrieves the fragment of the Plaintext structure of the specified type from the provided data.
    protected abstract byte[] decrypt​(byte type, byte[] fragment, int offset, int len)
    Retrieves the fragment of the Plaintext structure of the specified type from the provided data.
    protected byte[] encrypt​(byte type, byte[] fragment)
    Creates the GenericStreamCipher or GenericBlockCipher data structure for specified data of specified type.
    protected abstract byte[] encrypt​(byte type, byte[] fragment, int offset, int len)
    Creates the GenericStreamCipher or GenericBlockCipher data structure for specified data of specified type.
    protected int getContentSize​(int generic_cipher_size)
    Returns the minimal upper bound of the content size enclosed into the Generic[Stream|Block]Cipher structure of specified size.
    protected int getFragmentSize​(int content_size)
    Returns the size of the Generic[Stream|Block]Cipher structure corresponding to the content data of specified size.
    protected int getMinFragmentSize()
    Returns the minimal possible size of the Generic[Stream|Block]Cipher structure under this connection state.
    protected int getPaddingSize​(int content_size)
    Returns the number of bytes of padding required to round the content up to the required block size.
    protected static void incSequenceNumber​(byte[] seq_num)
    Increments the sequence number.
    protected void shutdown()
    Shutdownes the protocol.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • encCipher

      protected Cipher encCipher
      The cipher used for encode operations
    • decCipher

      protected Cipher decCipher
      The cipher used for decode operations
    • block_size

      protected int block_size
      The block size, or zero if not a block cipher
    • hash_size

      protected int hash_size
      The size of MAC used under this connection state
    • write_seq_num

      protected final byte[] write_seq_num
      Write sequence number which is incremented after each encrypt call
    • read_seq_num

      protected final byte[] read_seq_num
      Read sequence number which is incremented after each decrypt call
    • logger

      protected Logger.Stream logger
  • Constructor Details

    • ConnectionState

      public ConnectionState()
  • Method Details

    • getMinFragmentSize

      protected int getMinFragmentSize()
      Returns the minimal possible size of the Generic[Stream|Block]Cipher structure under this connection state.
    • getFragmentSize

      protected int getFragmentSize​(int content_size)
      Returns the size of the Generic[Stream|Block]Cipher structure corresponding to the content data of specified size.
    • getContentSize

      protected int getContentSize​(int generic_cipher_size)
      Returns the minimal upper bound of the content size enclosed into the Generic[Stream|Block]Cipher structure of specified size. For stream ciphers the returned value will be exact value.
    • getPaddingSize

      protected int getPaddingSize​(int content_size)
      Returns the number of bytes of padding required to round the content up to the required block size. Assumes power of two block size.
    • encrypt

      protected byte[] encrypt​(byte type, byte[] fragment)
      Creates the GenericStreamCipher or GenericBlockCipher data structure for specified data of specified type.
      Parameters:
      type - - the ContentType of the provided data
      fragment - - the byte array containing the data to be encrypted under the current connection state.
    • encrypt

      protected abstract byte[] encrypt​(byte type, byte[] fragment, int offset, int len)
      Creates the GenericStreamCipher or GenericBlockCipher data structure for specified data of specified type.
      Parameters:
      type - - the ContentType of the provided data
      fragment - - the byte array containing the data to be encrypted under the current connection state.
      offset - - the offset from which the data begins with.
      len - - the length of the data.
    • decrypt

      protected byte[] decrypt​(byte type, byte[] fragment)
      Retrieves the fragment of the Plaintext structure of the specified type from the provided data.
      Parameters:
      type - - the ContentType of the data to be decrypted.
      fragment - - the byte array containing the data to be encrypted under the current connection state.
    • decrypt

      protected abstract byte[] decrypt​(byte type, byte[] fragment, int offset, int len)
      Retrieves the fragment of the Plaintext structure of the specified type from the provided data.
      Parameters:
      type - - the ContentType of the data to be decrypted.
      fragment - - the byte array containing the data to be encrypted under the current connection state.
      offset - - the offset from which the data begins with.
      len - - the length of the data.
    • incSequenceNumber

      protected static void incSequenceNumber​(byte[] seq_num)
      Increments the sequence number.
    • shutdown

      protected void shutdown()
      Shutdownes the protocol. It will be impossiblke to use the instance after the calling of this method.