Bouncy Castle Cryptography Library 1.64

org.bouncycastle.crypto.tls
Class TlsProtocol

java.lang.Object
  |
  +--org.bouncycastle.crypto.tls.TlsProtocol
All Implemented Interfaces:
TlsCloseable
Direct Known Subclasses:
TlsClientProtocol, TlsServerProtocol

Deprecated. Migrate to the (D)TLS API in org.bouncycastle.tls (bctls jar).

public abstract class TlsProtocol
extends java.lang.Object
implements TlsCloseable


Field Summary
protected static short ADS_MODE_0_N
          Deprecated.  
protected static short ADS_MODE_0_N_FIRSTONLY
          Deprecated.  
protected static short ADS_MODE_1_Nsub1
          Deprecated.  
protected  boolean allowCertificateStatus
          Deprecated.  
protected  boolean blocking
          Deprecated.  
protected  java.util.Hashtable clientExtensions
          Deprecated.  
protected  short connection_state
          Deprecated.  
protected static short CS_CERTIFICATE_REQUEST
          Deprecated.  
protected static short CS_CERTIFICATE_STATUS
          Deprecated.  
protected static short CS_CERTIFICATE_VERIFY
          Deprecated.  
protected static short CS_CLIENT_CERTIFICATE
          Deprecated.  
protected static short CS_CLIENT_FINISHED
          Deprecated.  
protected static short CS_CLIENT_HELLO
          Deprecated.  
protected static short CS_CLIENT_KEY_EXCHANGE
          Deprecated.  
protected static short CS_CLIENT_SUPPLEMENTAL_DATA
          Deprecated.  
protected static short CS_END
          Deprecated.  
protected static short CS_SERVER_CERTIFICATE
          Deprecated.  
protected static short CS_SERVER_FINISHED
          Deprecated.  
protected static short CS_SERVER_HELLO
          Deprecated.  
protected static short CS_SERVER_HELLO_DONE
          Deprecated.  
protected static short CS_SERVER_KEY_EXCHANGE
          Deprecated.  
protected static short CS_SERVER_SESSION_TICKET
          Deprecated.  
protected static short CS_SERVER_SUPPLEMENTAL_DATA
          Deprecated.  
protected static short CS_START
          Deprecated.  
protected  boolean expectSessionTicket
          Deprecated.  
protected static java.lang.Integer EXT_RenegotiationInfo
          Deprecated.  
protected static java.lang.Integer EXT_SessionTicket
          Deprecated.  
protected  ByteQueueInputStream inputBuffers
          Deprecated.  
protected  int[] offeredCipherSuites
          Deprecated.  
protected  short[] offeredCompressionMethods
          Deprecated.  
protected  ByteQueueOutputStream outputBuffer
          Deprecated.  
protected  Certificate peerCertificate
          Deprecated.  
protected  boolean receivedChangeCipherSpec
          Deprecated.  
protected  boolean resumedSession
          Deprecated.  
protected  boolean secure_renegotiation
          Deprecated.  
protected  java.security.SecureRandom secureRandom
          Deprecated.  
protected  SecurityParameters securityParameters
          Deprecated.  
protected  java.util.Hashtable serverExtensions
          Deprecated.  
protected  SessionParameters sessionParameters
          Deprecated.  
protected  TlsSession tlsSession
          Deprecated.  
 
Constructor Summary
TlsProtocol(java.io.InputStream input, java.io.OutputStream output, java.security.SecureRandom secureRandom)
          Deprecated.  
TlsProtocol(java.security.SecureRandom secureRandom)
          Deprecated.  
 
Method Summary
protected  int applicationDataAvailable()
          Deprecated.  
protected  void applyMaxFragmentLengthExtension()
          Deprecated.  
protected static void assertEmpty(java.io.ByteArrayInputStream buf)
          Deprecated. Make sure the InputStream 'buf' now empty.
protected  void blockForHandshake()
          Deprecated.  
protected  void checkReceivedChangeCipherSpec(boolean expected)
          Deprecated.  
protected  void cleanupHandshake()
          Deprecated.  
 void close()
          Deprecated. Closes this connection.
 void closeInput()
          Deprecated. Should be called in non-blocking mode when the input data reaches EOF.
protected  void completeHandshake()
          Deprecated.  
protected static byte[] createRandomBlock(boolean useGMTUnixTime, RandomGenerator randomGenerator)
          Deprecated.  
protected static byte[] createRenegotiationInfo(byte[] renegotiated_connection)
          Deprecated.  
protected  byte[] createVerifyData(boolean isServer)
          Deprecated.  
protected static void establishMasterSecret(TlsContext context, TlsKeyExchange keyExchange)
          Deprecated.  
protected  void flush()
          Deprecated.  
 int getAvailableInputBytes()
          Deprecated. Gets the amount of received application data.
 int getAvailableOutputBytes()
          Deprecated. Gets the amount of encrypted data available to be sent.
protected abstract  TlsContext getContext()
          Deprecated.  
protected static byte[] getCurrentPRFHash(TlsContext context, TlsHandshakeHash handshakeHash, byte[] sslSender)
          Deprecated. 'sender' only relevant to SSLv3
 java.io.InputStream getInputStream()
          Deprecated.  
 java.io.OutputStream getOutputStream()
          Deprecated.  
protected abstract  TlsPeer getPeer()
          Deprecated.  
protected static int getPRFAlgorithm(TlsContext context, int ciphersuite)
          Deprecated.  
protected  void handleAlertMessage(short alertLevel, short alertDescription)
          Deprecated.  
protected  void handleAlertWarningMessage(short alertDescription)
          Deprecated.  
protected  void handleChangeCipherSpecMessage()
          Deprecated.  
protected  void handleClose(boolean user_canceled)
          Deprecated.  
protected  void handleException(short alertDescription, java.lang.String message, java.lang.Throwable cause)
          Deprecated.  
protected  void handleFailure()
          Deprecated.  
protected abstract  void handleHandshakeMessage(short type, java.io.ByteArrayInputStream buf)
          Deprecated.  
protected  void invalidateSession()
          Deprecated.  
 boolean isClosed()
          Deprecated.  
 void offerInput(byte[] input)
          Deprecated. Equivalent to offerInput(input, 0, input.length)
 void offerInput(byte[] input, int inputOff, int inputLen)
          Deprecated. Offer input from an arbitrary source.
 void offerOutput(byte[] buffer, int offset, int length)
          Deprecated. Offer output from an arbitrary source.
protected  void processFinishedMessage(java.io.ByteArrayInputStream buf)
          Deprecated.  
protected  short processMaxFragmentLengthExtension(java.util.Hashtable clientExtensions, java.util.Hashtable serverExtensions, short alertDescription)
          Deprecated.  
protected  void processRecord(short protocol, byte[] buf, int off, int len)
          Deprecated.  
protected  void raiseAlertFatal(short alertDescription, java.lang.String message, java.lang.Throwable cause)
          Deprecated.  
protected  void raiseAlertWarning(short alertDescription, java.lang.String message)
          Deprecated.  
protected  int readApplicationData(byte[] buf, int offset, int len)
          Deprecated. Read data from the network.
protected static java.util.Hashtable readExtensions(java.io.ByteArrayInputStream input)
          Deprecated.  
 int readInput(byte[] buffer, int offset, int length)
          Deprecated. Retrieves received application data.
 int readOutput(byte[] buffer, int offset, int length)
          Deprecated. Retrieves encrypted data to be sent.
protected static java.util.Vector readSupplementalDataMessage(java.io.ByteArrayInputStream input)
          Deprecated.  
protected  void refuseRenegotiation()
          Deprecated.  
protected  void safeCheckRecordHeader(byte[] recordHeader)
          Deprecated.  
protected  void safeReadRecord()
          Deprecated.  
protected  void safeWriteRecord(short type, byte[] buf, int offset, int len)
          Deprecated.  
protected  void sendCertificateMessage(Certificate certificate)
          Deprecated.  
protected  void sendChangeCipherSpecMessage()
          Deprecated.  
protected  void sendFinishedMessage()
          Deprecated.  
protected  void sendSupplementalDataMessage(java.util.Vector supplementalData)
          Deprecated.  
protected  void setAppDataSplitMode(int appDataSplitMode)
          Deprecated.  
protected  void writeData(byte[] buf, int offset, int len)
          Deprecated. Send some application data to the remote system.
protected static void writeExtensions(java.io.OutputStream output, java.util.Hashtable extensions)
          Deprecated.  
protected  void writeHandshakeMessage(byte[] buf, int off, int len)
          Deprecated.  
protected static void writeSelectedExtensions(java.io.OutputStream output, java.util.Hashtable extensions, boolean selectEmpty)
          Deprecated.  
protected static void writeSupplementalData(java.io.OutputStream output, java.util.Vector supplementalData)
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXT_RenegotiationInfo

protected static final java.lang.Integer EXT_RenegotiationInfo
Deprecated. 

EXT_SessionTicket

protected static final java.lang.Integer EXT_SessionTicket
Deprecated. 

CS_START

protected static final short CS_START
Deprecated. 

CS_CLIENT_HELLO

protected static final short CS_CLIENT_HELLO
Deprecated. 

CS_SERVER_HELLO

protected static final short CS_SERVER_HELLO
Deprecated. 

CS_SERVER_SUPPLEMENTAL_DATA

protected static final short CS_SERVER_SUPPLEMENTAL_DATA
Deprecated. 

CS_SERVER_CERTIFICATE

protected static final short CS_SERVER_CERTIFICATE
Deprecated. 

CS_CERTIFICATE_STATUS

protected static final short CS_CERTIFICATE_STATUS
Deprecated. 

CS_SERVER_KEY_EXCHANGE

protected static final short CS_SERVER_KEY_EXCHANGE
Deprecated. 

CS_CERTIFICATE_REQUEST

protected static final short CS_CERTIFICATE_REQUEST
Deprecated. 

CS_SERVER_HELLO_DONE

protected static final short CS_SERVER_HELLO_DONE
Deprecated. 

CS_CLIENT_SUPPLEMENTAL_DATA

protected static final short CS_CLIENT_SUPPLEMENTAL_DATA
Deprecated. 

CS_CLIENT_CERTIFICATE

protected static final short CS_CLIENT_CERTIFICATE
Deprecated. 

CS_CLIENT_KEY_EXCHANGE

protected static final short CS_CLIENT_KEY_EXCHANGE
Deprecated. 

CS_CERTIFICATE_VERIFY

protected static final short CS_CERTIFICATE_VERIFY
Deprecated. 

CS_CLIENT_FINISHED

protected static final short CS_CLIENT_FINISHED
Deprecated. 

CS_SERVER_SESSION_TICKET

protected static final short CS_SERVER_SESSION_TICKET
Deprecated. 

CS_SERVER_FINISHED

protected static final short CS_SERVER_FINISHED
Deprecated. 

CS_END

protected static final short CS_END
Deprecated. 

ADS_MODE_1_Nsub1

protected static final short ADS_MODE_1_Nsub1
Deprecated. 

ADS_MODE_0_N

protected static final short ADS_MODE_0_N
Deprecated. 

ADS_MODE_0_N_FIRSTONLY

protected static final short ADS_MODE_0_N_FIRSTONLY
Deprecated. 

secureRandom

protected java.security.SecureRandom secureRandom
Deprecated. 

tlsSession

protected TlsSession tlsSession
Deprecated. 

sessionParameters

protected SessionParameters sessionParameters
Deprecated. 

securityParameters

protected SecurityParameters securityParameters
Deprecated. 

peerCertificate

protected Certificate peerCertificate
Deprecated. 

offeredCipherSuites

protected int[] offeredCipherSuites
Deprecated. 

offeredCompressionMethods

protected short[] offeredCompressionMethods
Deprecated. 

clientExtensions

protected java.util.Hashtable clientExtensions
Deprecated. 

serverExtensions

protected java.util.Hashtable serverExtensions
Deprecated. 

connection_state

protected short connection_state
Deprecated. 

resumedSession

protected boolean resumedSession
Deprecated. 

receivedChangeCipherSpec

protected boolean receivedChangeCipherSpec
Deprecated. 

secure_renegotiation

protected boolean secure_renegotiation
Deprecated. 

allowCertificateStatus

protected boolean allowCertificateStatus
Deprecated. 

expectSessionTicket

protected boolean expectSessionTicket
Deprecated. 

blocking

protected boolean blocking
Deprecated. 

inputBuffers

protected ByteQueueInputStream inputBuffers
Deprecated. 

outputBuffer

protected ByteQueueOutputStream outputBuffer
Deprecated. 
Constructor Detail

TlsProtocol

public TlsProtocol(java.io.InputStream input,
                   java.io.OutputStream output,
                   java.security.SecureRandom secureRandom)
Deprecated. 

TlsProtocol

public TlsProtocol(java.security.SecureRandom secureRandom)
Deprecated. 
Method Detail

getContext

protected abstract TlsContext getContext()
Deprecated. 

getPeer

protected abstract TlsPeer getPeer()
Deprecated. 

handleAlertMessage

protected void handleAlertMessage(short alertLevel,
                                  short alertDescription)
                           throws java.io.IOException
Deprecated. 

handleAlertWarningMessage

protected void handleAlertWarningMessage(short alertDescription)
                                  throws java.io.IOException
Deprecated. 

handleChangeCipherSpecMessage

protected void handleChangeCipherSpecMessage()
                                      throws java.io.IOException
Deprecated. 

handleClose

protected void handleClose(boolean user_canceled)
                    throws java.io.IOException
Deprecated. 

handleException

protected void handleException(short alertDescription,
                               java.lang.String message,
                               java.lang.Throwable cause)
                        throws java.io.IOException
Deprecated. 

handleFailure

protected void handleFailure()
Deprecated. 

handleHandshakeMessage

protected abstract void handleHandshakeMessage(short type,
                                               java.io.ByteArrayInputStream buf)
                                        throws java.io.IOException
Deprecated. 

applyMaxFragmentLengthExtension

protected void applyMaxFragmentLengthExtension()
                                        throws java.io.IOException
Deprecated. 

checkReceivedChangeCipherSpec

protected void checkReceivedChangeCipherSpec(boolean expected)
                                      throws java.io.IOException
Deprecated. 

cleanupHandshake

protected void cleanupHandshake()
Deprecated. 

blockForHandshake

protected void blockForHandshake()
                          throws java.io.IOException
Deprecated. 

completeHandshake

protected void completeHandshake()
                          throws java.io.IOException
Deprecated. 

processRecord

protected void processRecord(short protocol,
                             byte[] buf,
                             int off,
                             int len)
                      throws java.io.IOException
Deprecated. 

applicationDataAvailable

protected int applicationDataAvailable()
Deprecated. 

readApplicationData

protected int readApplicationData(byte[] buf,
                                  int offset,
                                  int len)
                           throws java.io.IOException
Deprecated. 
Read data from the network. The method will return immediately, if there is still some data left in the buffer, or block until some application data has been read from the network.
Parameters:
buf - The buffer where the data will be copied to.
offset - The position where the data will be placed in the buffer.
len - The maximum number of bytes to read.
Returns:
The number of bytes read.
Throws:
java.io.IOException - If something goes wrong during reading data.

safeCheckRecordHeader

protected void safeCheckRecordHeader(byte[] recordHeader)
                              throws java.io.IOException
Deprecated. 

safeReadRecord

protected void safeReadRecord()
                       throws java.io.IOException
Deprecated. 

safeWriteRecord

protected void safeWriteRecord(short type,
                               byte[] buf,
                               int offset,
                               int len)
                        throws java.io.IOException
Deprecated. 

writeData

protected void writeData(byte[] buf,
                         int offset,
                         int len)
                  throws java.io.IOException
Deprecated. 
Send some application data to the remote system.

The method will handle fragmentation internally.

Parameters:
buf - The buffer with the data.
offset - The position in the buffer where the data is placed.
len - The length of the data.
Throws:
java.io.IOException - If something goes wrong during sending.

setAppDataSplitMode

protected void setAppDataSplitMode(int appDataSplitMode)
Deprecated. 

writeHandshakeMessage

protected void writeHandshakeMessage(byte[] buf,
                                     int off,
                                     int len)
                              throws java.io.IOException
Deprecated. 

getOutputStream

public java.io.OutputStream getOutputStream()
Deprecated. 
Returns:
An OutputStream which can be used to send data. Only allowed in blocking mode.

getInputStream

public java.io.InputStream getInputStream()
Deprecated. 
Returns:
An InputStream which can be used to read data. Only allowed in blocking mode.

closeInput

public void closeInput()
                throws java.io.IOException
Deprecated. 
Should be called in non-blocking mode when the input data reaches EOF.

offerInput

public void offerInput(byte[] input)
                throws java.io.IOException
Deprecated. 
Equivalent to offerInput(input, 0, input.length)
Parameters:
input - The input buffer to offer
Throws:
java.io.IOException - If an error occurs while decrypting or processing a record
See Also:
offerInput(byte[], int, int)

offerInput

public void offerInput(byte[] input,
                       int inputOff,
                       int inputLen)
                throws java.io.IOException
Deprecated. 
Offer input from an arbitrary source. Only allowed in non-blocking mode. This method will decrypt and process all records that are fully available. If only part of a record is available, the buffer will be retained until the remainder of the record is offered. If any records containing application data were processed, the decrypted data can be obtained using readInput(byte[], int, int). If any records containing protocol data were processed, a response may have been generated. You should always check to see if there is any available output after calling this method by calling getAvailableOutputBytes().
Parameters:
input - The input buffer to offer
inputOff - The offset within the input buffer that input begins
inputLen - The number of bytes of input being offered
Throws:
java.io.IOException - If an error occurs while decrypting or processing a record

getAvailableInputBytes

public int getAvailableInputBytes()
Deprecated. 
Gets the amount of received application data. A call to readInput(byte[], int, int) is guaranteed to be able to return at least this much data. Only allowed in non-blocking mode.
Returns:
The number of bytes of available application data

readInput

public int readInput(byte[] buffer,
                     int offset,
                     int length)
Deprecated. 
Retrieves received application data. Use getAvailableInputBytes() to check how much application data is currently available. This method functions similarly to InputStream.read(byte[], int, int), except that it never blocks. If no data is available, nothing will be copied and zero will be returned. Only allowed in non-blocking mode.
Parameters:
buffer - The buffer to hold the application data
offset - The start offset in the buffer at which the data is written
length - The maximum number of bytes to read
Returns:
The total number of bytes copied to the buffer. May be less than the length specified if the length was greater than the amount of available data.

offerOutput

public void offerOutput(byte[] buffer,
                        int offset,
                        int length)
                 throws java.io.IOException
Deprecated. 
Offer output from an arbitrary source. Only allowed in non-blocking mode. After this method returns, the specified section of the buffer will have been processed. Use readOutput(byte[], int, int) to get the bytes to transmit to the other peer. This method must not be called until after the handshake is complete! Attempting to call it before the handshake is complete will result in an exception.
Parameters:
buffer - The buffer containing application data to encrypt
offset - The offset at which to begin reading data
length - The number of bytes of data to read
Throws:
java.io.IOException - If an error occurs encrypting the data, or the handshake is not complete

getAvailableOutputBytes

public int getAvailableOutputBytes()
Deprecated. 
Gets the amount of encrypted data available to be sent. A call to readOutput(byte[], int, int) is guaranteed to be able to return at least this much data. Only allowed in non-blocking mode.
Returns:
The number of bytes of available encrypted data

readOutput

public int readOutput(byte[] buffer,
                      int offset,
                      int length)
Deprecated. 
Retrieves encrypted data to be sent. Use getAvailableOutputBytes() to check how much encrypted data is currently available. This method functions similarly to InputStream.read(byte[], int, int), except that it never blocks. If no data is available, nothing will be copied and zero will be returned. Only allowed in non-blocking mode.
Parameters:
buffer - The buffer to hold the encrypted data
offset - The start offset in the buffer at which the data is written
length - The maximum number of bytes to read
Returns:
The total number of bytes copied to the buffer. May be less than the length specified if the length was greater than the amount of available data.

invalidateSession

protected void invalidateSession()
Deprecated. 

processFinishedMessage

protected void processFinishedMessage(java.io.ByteArrayInputStream buf)
                               throws java.io.IOException
Deprecated. 

raiseAlertFatal

protected void raiseAlertFatal(short alertDescription,
                               java.lang.String message,
                               java.lang.Throwable cause)
                        throws java.io.IOException
Deprecated. 

raiseAlertWarning

protected void raiseAlertWarning(short alertDescription,
                                 java.lang.String message)
                          throws java.io.IOException
Deprecated. 

sendCertificateMessage

protected void sendCertificateMessage(Certificate certificate)
                               throws java.io.IOException
Deprecated. 

sendChangeCipherSpecMessage

protected void sendChangeCipherSpecMessage()
                                    throws java.io.IOException
Deprecated. 

sendFinishedMessage

protected void sendFinishedMessage()
                            throws java.io.IOException
Deprecated. 

sendSupplementalDataMessage

protected void sendSupplementalDataMessage(java.util.Vector supplementalData)
                                    throws java.io.IOException
Deprecated. 

createVerifyData

protected byte[] createVerifyData(boolean isServer)
Deprecated. 

close

public void close()
           throws java.io.IOException
Deprecated. 
Closes this connection.
Specified by:
close in interface TlsCloseable
Throws:
java.io.IOException - If something goes wrong during closing.

flush

protected void flush()
              throws java.io.IOException
Deprecated. 

isClosed

public boolean isClosed()
Deprecated. 

processMaxFragmentLengthExtension

protected short processMaxFragmentLengthExtension(java.util.Hashtable clientExtensions,
                                                  java.util.Hashtable serverExtensions,
                                                  short alertDescription)
                                           throws java.io.IOException
Deprecated. 

refuseRenegotiation

protected void refuseRenegotiation()
                            throws java.io.IOException
Deprecated. 

assertEmpty

protected static void assertEmpty(java.io.ByteArrayInputStream buf)
                           throws java.io.IOException
Deprecated. 
Make sure the InputStream 'buf' now empty. Fail otherwise.
Parameters:
buf - The InputStream to check.
Throws:
java.io.IOException - If 'buf' is not empty.

createRandomBlock

protected static byte[] createRandomBlock(boolean useGMTUnixTime,
                                          RandomGenerator randomGenerator)
Deprecated. 

createRenegotiationInfo

protected static byte[] createRenegotiationInfo(byte[] renegotiated_connection)
                                         throws java.io.IOException
Deprecated. 

establishMasterSecret

protected static void establishMasterSecret(TlsContext context,
                                            TlsKeyExchange keyExchange)
                                     throws java.io.IOException
Deprecated. 

getCurrentPRFHash

protected static byte[] getCurrentPRFHash(TlsContext context,
                                          TlsHandshakeHash handshakeHash,
                                          byte[] sslSender)
Deprecated. 
'sender' only relevant to SSLv3

readExtensions

protected static java.util.Hashtable readExtensions(java.io.ByteArrayInputStream input)
                                             throws java.io.IOException
Deprecated. 

readSupplementalDataMessage

protected static java.util.Vector readSupplementalDataMessage(java.io.ByteArrayInputStream input)
                                                       throws java.io.IOException
Deprecated. 

writeExtensions

protected static void writeExtensions(java.io.OutputStream output,
                                      java.util.Hashtable extensions)
                               throws java.io.IOException
Deprecated. 

writeSelectedExtensions

protected static void writeSelectedExtensions(java.io.OutputStream output,
                                              java.util.Hashtable extensions,
                                              boolean selectEmpty)
                                       throws java.io.IOException
Deprecated. 

writeSupplementalData

protected static void writeSupplementalData(java.io.OutputStream output,
                                            java.util.Vector supplementalData)
                                     throws java.io.IOException
Deprecated. 

getPRFAlgorithm

protected static int getPRFAlgorithm(TlsContext context,
                                     int ciphersuite)
                              throws java.io.IOException
Deprecated. 

Bouncy Castle Cryptography Library 1.64