Package org.conscrypt

Class HandshakeProtocol

java.lang.Object
org.conscrypt.HandshakeProtocol
Direct Known Subclasses:
ClientHandshakeImpl, ServerHandshakeImpl

public abstract class HandshakeProtocol
extends Object
Base class for ClientHandshakeImpl and ServerHandshakeImpl classes.
See Also:
TLS 1.0 spec., 7.4. Handshake protocol
  • Field Details

    • NEED_UNWRAP

      public static final int NEED_UNWRAP
      Handshake status NEED_UNWRAP - HandshakeProtocol needs to receive data
      See Also:
      Constant Field Values
    • NOT_HANDSHAKING

      public static final int NOT_HANDSHAKING
      Handshake status NOT_HANDSHAKING - is not currently handshaking
      See Also:
      Constant Field Values
    • FINISHED

      public static final int FINISHED
      Handshake status FINISHED - HandshakeProtocol has just finished
      See Also:
      Constant Field Values
    • NEED_TASK

      public static final int NEED_TASK
      Handshake status NEED_TASK - HandshakeProtocol needs the results of delegated task
      See Also:
      Constant Field Values
    • status

      protected int status
      Current handshake status
    • io_stream

      protected HandshakeIODataStream io_stream
      IO stream for income/outcome handshake data
    • recordProtocol

      protected SSLRecordProtocol recordProtocol
      SSL Record Protocol implementation.
    • parameters

      protected SSLParametersImpl parameters
      SSLParametersImpl suplied by SSLSocket or SSLEngine
    • delegatedTasks

      protected Vector<DelegatedTask> delegatedTasks
      Delegated tasks for this handshake implementation
    • nonBlocking

      protected boolean nonBlocking
      Indicates non-blocking handshake
    • session

      protected SSLSessionImpl session
      Pending session
    • clientHello

      protected ClientHello clientHello
      Sent and received handshake messages
    • serverHello

      protected ServerHello serverHello
    • serverCert

      protected CertificateMessage serverCert
    • serverKeyExchange

      protected ServerKeyExchange serverKeyExchange
    • certificateRequest

      protected CertificateRequest certificateRequest
    • serverHelloDone

      protected ServerHelloDone serverHelloDone
    • clientCert

      protected CertificateMessage clientCert
    • clientKeyExchange

      protected ClientKeyExchange clientKeyExchange
    • certificateVerify

      protected CertificateVerify certificateVerify
    • clientFinished

      protected Finished clientFinished
    • serverFinished

      protected Finished serverFinished
    • changeCipherSpecReceived

      protected boolean changeCipherSpecReceived
      Indicates that change cipher spec message has been received
    • isResuming

      protected boolean isResuming
      Indicates previous session resuming
    • preMasterSecret

      protected byte[] preMasterSecret
      Premaster secret
    • delegatedTaskErr

      protected Exception delegatedTaskErr
      Exception occured in delegated task
    • needSendHelloRequest

      protected boolean needSendHelloRequest
    • engineOwner

      public SSLEngineImpl engineOwner
      SSLEngine owning this HandshakeProtocol
    • socketOwner

      public SSLSocketImpl socketOwner
      SSLSocket owning this HandshakeProtocol
  • Constructor Details

    • HandshakeProtocol

      protected HandshakeProtocol​(Object owner)
      Creates HandshakeProtocol instance
      Parameters:
      owner -
  • Method Details

    • setRecordProtocol

      public void setRecordProtocol​(SSLRecordProtocol recordProtocol)
      Sets SSL Record Protocol
      Parameters:
      recordProtocol -
    • start

      public abstract void start()
      Start session negotiation
    • stop

      protected void stop()
      Stops the current session renegotiation process. Such functionality is needed when it is session renegotiation process and no_renegotiation alert message is received from another peer.
      Parameters:
      session -
    • getStatus

      public SSLEngineResult.HandshakeStatus getStatus()
      Returns handshake status
    • getSession

      public SSLSessionImpl getSession()
      Returns pending session
      Returns:
      session
    • sendChangeCipherSpec

      protected void sendChangeCipherSpec()
    • sendHelloRequest

      protected void sendHelloRequest()
    • unwrap

      public abstract void unwrap​(byte[] bytes)
      Proceses inbound handshake messages
      Parameters:
      bytes -
    • unwrapSSLv2

      public abstract void unwrapSSLv2​(byte[] bytes)
      Processes SSLv2 Hello message
      Parameters:
      bytes -
    • wrap

      public byte[] wrap()
      Processes outbound handshake messages
    • sendWarningAlert

      protected void sendWarningAlert​(byte description)
      Sends fatal alert, breaks execution
      Parameters:
      description -
    • fatalAlert

      protected void fatalAlert​(byte description, String reason)
      Sends fatal alert, breaks execution
      Parameters:
      description -
      reason -
    • fatalAlert

      protected void fatalAlert​(byte description, String reason, Exception cause)
      Sends fatal alert, breaks execution
      Parameters:
      description -
      reason -
      cause -
    • fatalAlert

      protected void fatalAlert​(byte description, SSLException cause)
      Sends fatal alert, breaks execution
      Parameters:
      description -
      cause -
    • computerReferenceVerifyDataTLS

      protected void computerReferenceVerifyDataTLS​(String label)
      Computers reference TLS verify_data that is used to verify finished message
      Parameters:
      label -
      See Also:
      TLS spec. 7.4.9. Finished
    • computerVerifyDataTLS

      protected void computerVerifyDataTLS​(String label, byte[] buf)
      Computer TLS verify_data
      Parameters:
      label -
      buf -
      See Also:
      TLS spec. 7.4.9. Finished
    • computerReferenceVerifyDataSSLv3

      protected void computerReferenceVerifyDataSSLv3​(byte[] sender)
      Computer reference SSLv3 verify_data that is used to verify finished message
      Parameters:
      label -
      See Also:
      "SSLv3 spec. 7.6.9. Finished"
    • computerVerifyDataSSLv3

      protected void computerVerifyDataSSLv3​(byte[] sender, byte[] buf)
      Computer SSLv3 verify_data
      Parameters:
      label -
      buf -
      See Also:
      "SSLv3 spec. 7.6.9. Finished"
    • verifyFinished

      protected void verifyFinished​(byte[] data)
      Verifies finished data
      Parameters:
      data -
      isServer -
    • unexpectedMessage

      protected void unexpectedMessage()
      Sends fatal alert "UNEXPECTED MESSAGE"
    • send

      public void send​(Message message)
      Writes message to HandshakeIODataStream
      Parameters:
      message -
    • computerMasterSecret

      public void computerMasterSecret()
      Computers master secret
    • getTask

      public Runnable getTask()
      Returns a delegated task.
      Returns:
      Delegated task or null
    • clearMessages

      protected void clearMessages()
      Clears previously sent and received handshake messages
    • getRSAKeyLength

      protected static int getRSAKeyLength​(PublicKey pk) throws NoSuchAlgorithmException, InvalidKeySpecException
      Returns RSA key length
      Parameters:
      pk -
      Returns:
      Throws:
      NoSuchAlgorithmException
      InvalidKeySpecException
    • shutdown

      protected void shutdown()
      Shuts down the protocol. It will be impossible to use the instance after calling this method.