Package org.bouncycastle.tls
Class TlsClientProtocol
java.lang.Object
org.bouncycastle.tls.TlsProtocol
org.bouncycastle.tls.TlsClientProtocol
- All Implemented Interfaces:
TlsCloseable
-
Field Summary
Modifier and TypeFieldDescriptionprotected TlsAuthentication
protected CertificateRequest
protected CertificateStatus
protected Hashtable
protected ClientHello
protected TlsKeyExchange
protected TlsClient
Fields inherited from class org.bouncycastle.tls.TlsProtocol
ADS_MODE_0_N, ADS_MODE_0_N_FIRSTONLY, ADS_MODE_1_Nsub1, blocking, clientExtensions, connection_state, CS_CLIENT_CERTIFICATE, CS_CLIENT_CERTIFICATE_VERIFY, CS_CLIENT_END_OF_EARLY_DATA, CS_CLIENT_FINISHED, CS_CLIENT_HELLO, CS_CLIENT_HELLO_RETRY, CS_CLIENT_KEY_EXCHANGE, CS_CLIENT_SUPPLEMENTAL_DATA, CS_END, CS_SERVER_CERTIFICATE, CS_SERVER_CERTIFICATE_REQUEST, CS_SERVER_CERTIFICATE_STATUS, CS_SERVER_CERTIFICATE_VERIFY, CS_SERVER_ENCRYPTED_EXTENSIONS, CS_SERVER_FINISHED, CS_SERVER_HELLO, CS_SERVER_HELLO_DONE, CS_SERVER_HELLO_RETRY_REQUEST, CS_SERVER_KEY_EXCHANGE, CS_SERVER_SESSION_TICKET, CS_SERVER_SUPPLEMENTAL_DATA, CS_START, expectSessionTicket, EXT_RenegotiationInfo, EXT_SessionTicket, inputBuffers, outputBuffer, receivedChangeCipherSpec, retryCookie, retryGroup, selectedPSK13, serverExtensions, sessionMasterSecret, sessionParameters, tlsSession
-
Constructor Summary
ConstructorDescriptionConstructor for non-blocking mode.
When data is received, useTlsProtocol.offerInput(byte[])
to provide the received ciphertext, then useTlsProtocol.readInput(byte[], int, int)
to read the corresponding cleartext.
Similarly, when data needs to be sent, useTlsProtocol.writeApplicationData(byte[], int, int)
to provide the cleartext, then useTlsProtocol.readOutput(byte[], int, int)
to get the corresponding ciphertext.TlsClientProtocol
(InputStream input, OutputStream output) Constructor for blocking mode. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
beginHandshake
(boolean renegotiation) protected void
void
Initiates a TLS handshake in the role of client.
In blocking mode, this will not return until the handshake is complete.protected TlsContext
protected TlsPeer
getPeer()
protected void
handle13HandshakeMessage
(short type, HandshakeMessageInput buf) protected void
handleHandshakeMessage
(short type, HandshakeMessageInput buf) protected void
protected void
handleSupplementalData
(Vector serverSupplementalData) protected void
process13HelloRetryRequest
(ServerHello helloRetryRequest) protected void
process13ServerHello
(ServerHello serverHello, boolean afterHelloRetryRequest) protected void
process13ServerHelloCoda
(ServerHello serverHello, boolean afterHelloRetryRequest) protected void
processServerHello
(ServerHello serverHello) protected void
receive13CertificateRequest
(ByteArrayInputStream buf, boolean postHandshakeAuth) protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected ServerHello
protected void
protected void
sendCertificateVerifyMessage
(DigitallySigned certificateVerify) protected void
protected void
protected void
protected void
protected void
Methods inherited from class org.bouncycastle.tls.TlsProtocol
applicationDataAvailable, applyMaxFragmentLengthExtension, assertEmpty, blockForHandshake, cancelSession, checkReceivedChangeCipherSpec, close, closeConnection, closeInput, completeHandshake, createRandomBlock, createRenegotiationInfo, establishMasterSecret, establishSession, flush, getAppDataSplitMode, getApplicationDataLimit, getAvailableInputBytes, getAvailableOutputBytes, getInputStream, getOutputStream, getRenegotiationPolicy, handleAlertMessage, handleAlertWarningMessage, handleChangeCipherSpecMessage, handleClose, handleException, handleFailure, handleRenegotiation, invalidateSession, isClosed, isConnected, isHandshaking, isLegacyConnectionState, isResumableHandshake, isTLSv13ConnectionState, offerInput, offerInput, previewInputRecord, previewOutputRecord, previewOutputRecord, process13FinishedMessage, processFinishedMessage, processMaxFragmentLengthExtension, processRecord, raiseAlertFatal, raiseAlertWarning, readApplicationData, readExtensions, readExtensionsData, readExtensionsData13, readExtensionsDataClientHello, readInput, readInput, readOutput, readOutput, readSupplementalDataMessage, receive13KeyUpdate, refuseRenegotiation, resumeHandshake, safePreviewRecordHeader, safeReadFullRecord, safeReadRecord, safeWriteRecord, send13CertificateMessage, send13CertificateVerifyMessage, send13FinishedMessage, send13KeyUpdate, sendCertificateMessage, sendChangeCipherSpec, sendChangeCipherSpecMessage, sendFinishedMessage, sendSupplementalDataMessage, setAppDataSplitMode, setResumableHandshake, writeApplicationData, writeExtensions, writeExtensions, writeExtensionsData, writeExtensionsData, writeExtensionsData, writePreSharedKeyExtension, writeSelectedExtensions, writeSupplementalData
-
Field Details
-
tlsClient
-
clientAgreements
-
clientHello
-
keyExchange
-
authentication
-
certificateStatus
-
certificateRequest
-
-
Constructor Details
-
TlsClientProtocol
public TlsClientProtocol()Constructor for non-blocking mode.
When data is received, useTlsProtocol.offerInput(byte[])
to provide the received ciphertext, then useTlsProtocol.readInput(byte[], int, int)
to read the corresponding cleartext.
Similarly, when data needs to be sent, useTlsProtocol.writeApplicationData(byte[], int, int)
to provide the cleartext, then useTlsProtocol.readOutput(byte[], int, int)
to get the corresponding ciphertext. -
TlsClientProtocol
Constructor for blocking mode.- Parameters:
input
- The stream of data from the serveroutput
- The stream of data to the server
-
-
Method Details
-
connect
Initiates a TLS handshake in the role of client.
In blocking mode, this will not return until the handshake is complete. In non-blocking mode, useTlsPeer.notifyHandshakeComplete()
to receive a callback when the handshake is complete.- Parameters:
tlsClient
- TheTlsClient
to use for the handshake.- Throws:
IOException
- If in blocking mode and handshake was not successful.
-
beginHandshake
- Overrides:
beginHandshake
in classTlsProtocol
- Throws:
IOException
-
cleanupHandshake
protected void cleanupHandshake()- Overrides:
cleanupHandshake
in classTlsProtocol
-
getContext
- Specified by:
getContext
in classTlsProtocol
-
getPeer
- Specified by:
getPeer
in classTlsProtocol
-
handle13HandshakeMessage
- Throws:
IOException
-
handleHandshakeMessage
- Specified by:
handleHandshakeMessage
in classTlsProtocol
- Throws:
IOException
-
handleServerCertificate
- Throws:
IOException
-
handleSupplementalData
- Throws:
IOException
-
process13HelloRetryRequest
- Throws:
IOException
-
process13ServerHello
protected void process13ServerHello(ServerHello serverHello, boolean afterHelloRetryRequest) throws IOException - Throws:
IOException
-
process13ServerHelloCoda
protected void process13ServerHelloCoda(ServerHello serverHello, boolean afterHelloRetryRequest) throws IOException - Throws:
IOException
-
processServerHello
- Throws:
IOException
-
receive13CertificateRequest
protected void receive13CertificateRequest(ByteArrayInputStream buf, boolean postHandshakeAuth) throws IOException - Throws:
IOException
-
receive13EncryptedExtensions
- Throws:
IOException
-
receive13NewSessionTicket
- Throws:
IOException
-
receive13ServerCertificate
- Throws:
IOException
-
receive13ServerCertificateVerify
- Throws:
IOException
-
receive13ServerFinished
- Throws:
IOException
-
receiveCertificateRequest
- Throws:
IOException
-
receiveNewSessionTicket
- Throws:
IOException
-
receiveServerHelloMessage
- Throws:
IOException
-
send13ClientHelloRetry
- Throws:
IOException
-
sendCertificateVerifyMessage
- Throws:
IOException
-
sendClientHello
- Throws:
IOException
-
sendClientHelloMessage
- Throws:
IOException
-
sendClientKeyExchange
- Throws:
IOException
-
skip13CertificateRequest
- Throws:
IOException
-
skip13ServerCertificate
- Throws:
IOException
-