Class DTLSClientProtocol
java.lang.Object
org.bouncycastle.tls.DTLSProtocol
org.bouncycastle.tls.DTLSClientProtocol
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabortClientHandshake(DTLSClientProtocol.ClientHandshakeState state, short alertDescription) protected voidprotected DTLSTransportprotected DTLSTransportclientHandshake13(DTLSClientProtocol.ClientHandshakeState state, org.bouncycastle.tls.DTLSReliableHandshake handshake) RFC 9147: the client half of a DTLS 1.3 handshake, from just after the ServerHello (handshake traffic keys installed at epoch 2) through to sending the client's Finished and installing the application traffic keys at epoch 3.connect(TlsClient client, DatagramTransport transport) protected booleanestablishSession(DTLSClientProtocol.ClientHandshakeState state, TlsSession sessionToResume) protected byte[]Mirrors TlsClientProtocol.send13ClientHelloRetry, except that the message goes out through DTLSReliableHandshake and RFC 9147 5 drops the TLS 1.3 compatibility-mode change_cipher_spec that precedes it there.protected byte[]generateCertificateVerify(DTLSClientProtocol.ClientHandshakeState state, DigitallySigned certificateVerify) protected byte[]protected byte[]protected voidprotected static booleanisHelloRetryRequest(byte[] body) Whether a ServerHello body is a HelloRetryRequest (RFC 8446 4.1.3: a ServerHello whose 'random' is the special value).protected static byte[]patchClientHelloWithCookie(byte[] clientHelloBody, byte[] cookie) protected voidprocess13HelloRetryRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) Mirrors TlsClientProtocol.process13HelloRetryRequest.protected voidprocess13ServerHello(DTLSClientProtocol.ClientHandshakeState state, ServerHello serverHello, boolean afterHelloRetryRequest) Mirrors TlsClientProtocol.process13ServerHello: check the ServerHello against the ClientHello that was sent, then run the RFC 8446 7.1 key schedule as far as the handshake secret.protected voidprocess13ServerHelloCoda(DTLSClientProtocol.ClientHandshakeState state, TlsHandshakeHash handshakeHash, boolean afterHelloRetryRequest) Mirrors TlsClientProtocol.process13ServerHelloCoda.protected voidprocessCertificateRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected voidprocessCertificateStatus(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected byte[]processHelloVerifyRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected voidprocessNewSessionTicket(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected voidprocessServerCertificate(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected voidprocessServerHello(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected voidprocessServerKeyExchange(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected voidprocessServerSupplementalData(DTLSClientProtocol.ClientHandshakeState state, byte[] body) protected static ProtocolVersionreadSelectedVersion(byte[] body) Determine the protocol version a ServerHello selects, without otherwise processing it: the "supported_versions" extension if present (RFC 8446 4.2.1), else 'legacy_version'.protected voidreceive13CertificateRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) Mirrors TlsClientProtocol.receive13CertificateRequest.protected voidreceive13EncryptedExtensions(DTLSClientProtocol.ClientHandshakeState state, byte[] body) Mirrors TlsClientProtocol.receive13EncryptedExtensions.protected voidreceive13ServerCertificate(DTLSClientProtocol.ClientHandshakeState state, byte[] body) Mirrors TlsClientProtocol.receive13ServerCertificate.protected voidreceive13ServerCertificateVerify(DTLSClientProtocol.ClientHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) Mirrors TlsClientProtocol.receive13ServerCertificateVerify.protected voidreceive13ServerFinished(DTLSClientProtocol.ClientHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) Mirrors TlsClientProtocol.receive13ServerFinished (TlsProtocol.process13FinishedMessage).protected voidreportServerVersion(DTLSClientProtocol.ClientHandshakeState state, ProtocolVersion server_version)
-
Constructor Details
-
DTLSClientProtocol
public DTLSClientProtocol()
-
-
Method Details
-
connect
- Throws:
IOException
-
abortClientHandshake
protected void abortClientHandshake(DTLSClientProtocol.ClientHandshakeState state, short alertDescription) -
clientHandshake
protected DTLSTransport clientHandshake(DTLSClientProtocol.ClientHandshakeState state) throws IOException - Throws:
IOException
-
clientHandshake13
protected DTLSTransport clientHandshake13(DTLSClientProtocol.ClientHandshakeState state, org.bouncycastle.tls.DTLSReliableHandshake handshake) throws IOException RFC 9147: the client half of a DTLS 1.3 handshake, from just after the ServerHello (handshake traffic keys installed at epoch 2) through to sending the client's Finished and installing the application traffic keys at epoch 3.- Throws:
IOException
-
generateCertificateVerify
protected byte[] generateCertificateVerify(DTLSClientProtocol.ClientHandshakeState state, DigitallySigned certificateVerify) throws IOException - Throws:
IOException
-
generateClientHello
protected byte[] generateClientHello(DTLSClientProtocol.ClientHandshakeState state) throws IOException - Throws:
IOException
-
generateClientKeyExchange
protected byte[] generateClientKeyExchange(DTLSClientProtocol.ClientHandshakeState state) throws IOException - Throws:
IOException
-
cancelSession
-
establishSession
protected boolean establishSession(DTLSClientProtocol.ClientHandshakeState state, TlsSession sessionToResume) -
invalidateSession
-
isHelloRetryRequest
Whether a ServerHello body is a HelloRetryRequest (RFC 8446 4.1.3: a ServerHello whose 'random' is the special value). Used only to route the message; all validation is left toprocess13HelloRetryRequest(DTLSClientProtocol.ClientHandshakeState, byte[])orprocessServerHello(DTLSClientProtocol.ClientHandshakeState, byte[]).- Throws:
IOException
-
process13HelloRetryRequest
protected void process13HelloRetryRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException Mirrors TlsClientProtocol.process13HelloRetryRequest. The "cookie" extension carried here is the RFC 8446 4.2.2 retry token: opaque to the client, which simply echoes it in its second ClientHello.- Throws:
IOException
-
generate13ClientHelloRetry
protected byte[] generate13ClientHelloRetry(DTLSClientProtocol.ClientHandshakeState state) throws IOException Mirrors TlsClientProtocol.send13ClientHelloRetry, except that the message goes out through DTLSReliableHandshake and RFC 9147 5 drops the TLS 1.3 compatibility-mode change_cipher_spec that precedes it there.RFC 8446 4.1.2: the second ClientHello repeats the first unchanged except for the "key_share", "early_data", "cookie", "pre_shared_key" and "padding" extensions, which is why the ClientHello object itself is kept and re-encoded. Its 'legacy_cookie' field stays empty: RFC 9147 5.3 keeps that field only for backwards compatibility with the DTLS 1.2 HelloVerifyRequest exchange.
- Throws:
IOException
-
process13ServerHello
protected void process13ServerHello(DTLSClientProtocol.ClientHandshakeState state, ServerHello serverHello, boolean afterHelloRetryRequest) throws IOException Mirrors TlsClientProtocol.process13ServerHello: check the ServerHello against the ClientHello that was sent, then run the RFC 8446 7.1 key schedule as far as the handshake secret.- Throws:
IOException
-
process13ServerHelloCoda
protected void process13ServerHelloCoda(DTLSClientProtocol.ClientHandshakeState state, TlsHandshakeHash handshakeHash, boolean afterHelloRetryRequest) throws IOException Mirrors TlsClientProtocol.process13ServerHelloCoda. Where the stream class hands the new cipher to RecordStream, DTLS installs it as the pending epoch and switches both directions to it: RFC 9147 6.1 reserves epoch 1 for early data, so the handshake traffic keys are epoch 2. RFC 9147 5 drops the TLS 1.3 compatibility-mode change_cipher_spec, so none is sent.- Throws:
IOException
-
receive13CertificateRequest
protected void receive13CertificateRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException Mirrors TlsClientProtocol.receive13CertificateRequest.- Throws:
IOException
-
receive13EncryptedExtensions
protected void receive13EncryptedExtensions(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException Mirrors TlsClientProtocol.receive13EncryptedExtensions.- Throws:
IOException
-
receive13ServerCertificate
protected void receive13ServerCertificate(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException Mirrors TlsClientProtocol.receive13ServerCertificate.- Throws:
IOException
-
receive13ServerCertificateVerify
protected void receive13ServerCertificateVerify(DTLSClientProtocol.ClientHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) throws IOException Mirrors TlsClientProtocol.receive13ServerCertificateVerify. The transcript passed in must exclude the CertificateVerify message itself, which is why it is read with a delayed digest.- Throws:
IOException
-
receive13ServerFinished
protected void receive13ServerFinished(DTLSClientProtocol.ClientHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) throws IOException Mirrors TlsClientProtocol.receive13ServerFinished (TlsProtocol.process13FinishedMessage). The transcript passed in must exclude the Finished message itself.- Throws:
IOException
-
processCertificateRequest
protected void processCertificateRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processCertificateStatus
protected void processCertificateStatus(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processHelloVerifyRequest
protected byte[] processHelloVerifyRequest(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processNewSessionTicket
protected void processNewSessionTicket(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processServerCertificate
protected void processServerCertificate(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processServerHello
protected void processServerHello(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processServerKeyExchange
protected void processServerKeyExchange(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processServerSupplementalData
protected void processServerSupplementalData(DTLSClientProtocol.ClientHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
readSelectedVersion
Determine the protocol version a ServerHello selects, without otherwise processing it: the "supported_versions" extension if present (RFC 8446 4.2.1), else 'legacy_version'. Used only to route the ServerHello; all validation of the pair is left toprocessServerHello(DTLSClientProtocol.ClientHandshakeState, byte[]).- Throws:
IOException
-
reportServerVersion
protected void reportServerVersion(DTLSClientProtocol.ClientHandshakeState state, ProtocolVersion server_version) throws IOException - Throws:
IOException
-
patchClientHelloWithCookie
protected static byte[] patchClientHelloWithCookie(byte[] clientHelloBody, byte[] cookie) throws IOException - Throws:
IOException
-