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 Summary
Fields Modifier and Type Field Description protected CertificateRequestcertificateRequestprotected CertificateVerifycertificateVerifyprotected booleanchangeCipherSpecReceivedIndicates that change cipher spec message has been receivedprotected CertificateMessageclientCertprotected FinishedclientFinishedprotected ClientHelloclientHelloSent and received handshake messagesprotected ClientKeyExchangeclientKeyExchangeprotected ExceptiondelegatedTaskErrException occured in delegated taskprotected Vector<DelegatedTask>delegatedTasksDelegated tasks for this handshake implementationSSLEngineImplengineOwnerSSLEngine owning this HandshakeProtocolstatic intFINISHEDHandshake status FINISHED - HandshakeProtocol has just finishedprotected HandshakeIODataStreamio_streamIO stream for income/outcome handshake dataprotected booleanisResumingIndicates previous session resumingstatic intNEED_TASKHandshake status NEED_TASK - HandshakeProtocol needs the results of delegated taskstatic intNEED_UNWRAPHandshake status NEED_UNWRAP - HandshakeProtocol needs to receive dataprotected booleanneedSendHelloRequestprotected booleannonBlockingIndicates non-blocking handshakestatic intNOT_HANDSHAKINGHandshake status NOT_HANDSHAKING - is not currently handshakingprotected SSLParametersImplparametersSSLParametersImpl suplied by SSLSocket or SSLEngineprotected byte[]preMasterSecretPremaster secretprotected SSLRecordProtocolrecordProtocolSSL Record Protocol implementation.protected CertificateMessageserverCertprotected FinishedserverFinishedprotected ServerHelloserverHelloprotected ServerHelloDoneserverHelloDoneprotected ServerKeyExchangeserverKeyExchangeprotected SSLSessionImplsessionPending sessionSSLSocketImplsocketOwnerSSLSocket owning this HandshakeProtocolprotected intstatusCurrent handshake status -
Constructor Summary
Constructors Modifier Constructor Description protectedHandshakeProtocol(Object owner)Creates HandshakeProtocol instance -
Method Summary
Modifier and Type Method Description protected voidclearMessages()Clears previously sent and received handshake messagesvoidcomputerMasterSecret()Computers master secretprotected voidcomputerReferenceVerifyDataSSLv3(byte[] sender)Computer reference SSLv3 verify_data that is used to verify finished messageprotected voidcomputerReferenceVerifyDataTLS(String label)Computers reference TLS verify_data that is used to verify finished messageprotected voidcomputerVerifyDataSSLv3(byte[] sender, byte[] buf)Computer SSLv3 verify_dataprotected voidcomputerVerifyDataTLS(String label, byte[] buf)Computer TLS verify_dataprotected voidfatalAlert(byte description, String reason)Sends fatal alert, breaks executionprotected voidfatalAlert(byte description, String reason, Exception cause)Sends fatal alert, breaks executionprotected voidfatalAlert(byte description, SSLException cause)Sends fatal alert, breaks executionprotected static intgetRSAKeyLength(PublicKey pk)Returns RSA key lengthSSLSessionImplgetSession()Returns pending sessionSSLEngineResult.HandshakeStatusgetStatus()Returns handshake statusRunnablegetTask()Returns a delegated task.voidsend(Message message)Writes message to HandshakeIODataStreamprotected voidsendChangeCipherSpec()protected voidsendHelloRequest()protected voidsendWarningAlert(byte description)Sends fatal alert, breaks executionvoidsetRecordProtocol(SSLRecordProtocol recordProtocol)Sets SSL Record Protocolprotected voidshutdown()Shuts down the protocol.abstract voidstart()Start session negotiationprotected voidstop()Stops the current session renegotiation process.protected voidunexpectedMessage()Sends fatal alert "UNEXPECTED MESSAGE"abstract voidunwrap(byte[] bytes)Proceses inbound handshake messagesabstract voidunwrapSSLv2(byte[] bytes)Processes SSLv2 Hello messageprotected voidverifyFinished(byte[] data)Verifies finished databyte[]wrap()Processes outbound handshake messages
-
Field Details
-
NEED_UNWRAP
public static final int NEED_UNWRAPHandshake status NEED_UNWRAP - HandshakeProtocol needs to receive data- See Also:
- Constant Field Values
-
NOT_HANDSHAKING
public static final int NOT_HANDSHAKINGHandshake status NOT_HANDSHAKING - is not currently handshaking- See Also:
- Constant Field Values
-
FINISHED
public static final int FINISHEDHandshake status FINISHED - HandshakeProtocol has just finished- See Also:
- Constant Field Values
-
NEED_TASK
public static final int NEED_TASKHandshake status NEED_TASK - HandshakeProtocol needs the results of delegated task- See Also:
- Constant Field Values
-
status
protected int statusCurrent handshake status -
io_stream
IO stream for income/outcome handshake data -
recordProtocol
SSL Record Protocol implementation. -
parameters
SSLParametersImpl suplied by SSLSocket or SSLEngine -
delegatedTasks
Delegated tasks for this handshake implementation -
nonBlocking
protected boolean nonBlockingIndicates non-blocking handshake -
session
Pending session -
clientHello
Sent and received handshake messages -
serverHello
-
serverCert
-
serverKeyExchange
-
certificateRequest
-
serverHelloDone
-
clientCert
-
clientKeyExchange
-
certificateVerify
-
clientFinished
-
serverFinished
-
changeCipherSpecReceived
protected boolean changeCipherSpecReceivedIndicates that change cipher spec message has been received -
isResuming
protected boolean isResumingIndicates previous session resuming -
preMasterSecret
protected byte[] preMasterSecretPremaster secret -
delegatedTaskErr
Exception occured in delegated task -
needSendHelloRequest
protected boolean needSendHelloRequest -
engineOwner
SSLEngine owning this HandshakeProtocol -
socketOwner
SSLSocket owning this HandshakeProtocol
-
-
Constructor Details
-
HandshakeProtocol
Creates HandshakeProtocol instance- Parameters:
owner-
-
-
Method Details
-
setRecordProtocol
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
Returns handshake status -
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
Sends fatal alert, breaks execution- Parameters:
description-reason-
-
fatalAlert
Sends fatal alert, breaks execution- Parameters:
description-reason-cause-
-
fatalAlert
Sends fatal alert, breaks execution- Parameters:
description-cause-
-
computerReferenceVerifyDataTLS
Computers reference TLS verify_data that is used to verify finished message- Parameters:
label-- See Also:
- TLS spec. 7.4.9. Finished
-
computerVerifyDataTLS
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
Writes message to HandshakeIODataStream- Parameters:
message-
-
computerMasterSecret
public void computerMasterSecret()Computers master secret -
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, InvalidKeySpecExceptionReturns RSA key length- Parameters:
pk-- Returns:
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
shutdown
protected void shutdown()Shuts down the protocol. It will be impossible to use the instance after calling this method.
-