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 intblock_sizeThe block size, or zero if not a block cipherprotected CipherdecCipherThe cipher used for decode operationsprotected CipherencCipherThe cipher used for encode operationsprotected inthash_sizeThe size of MAC used under this connection stateprotected Logger.Streamloggerprotected byte[]read_seq_numRead sequence number which is incremented after each decrypt callprotected byte[]write_seq_numWrite 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 intgetContentSize(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 intgetFragmentSize(int content_size)Returns the size of the Generic[Stream|Block]Cipher structure corresponding to the content data of specified size.protected intgetMinFragmentSize()Returns the minimal possible size of the Generic[Stream|Block]Cipher structure under this connection state.protected intgetPaddingSize(int content_size)Returns the number of bytes of padding required to round the content up to the required block size.protected static voidincSequenceNumber(byte[] seq_num)Increments the sequence number.protected voidshutdown()Shutdownes the protocol.
-
Field Details
-
encCipher
The cipher used for encode operations -
decCipher
The cipher used for decode operations -
block_size
protected int block_sizeThe block size, or zero if not a block cipher -
hash_size
protected int hash_sizeThe size of MAC used under this connection state -
write_seq_num
protected final byte[] write_seq_numWrite sequence number which is incremented after each encrypt call -
read_seq_num
protected final byte[] read_seq_numRead sequence number which is incremented after each decrypt call -
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 datafragment- - 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 datafragment- - 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.
-