Class DTLSServerProtocol
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabortServerHandshake(DTLSServerProtocol.ServerHandshakeState state, short alertDescription) accept(TlsServer server, DatagramTransport transport) accept(TlsServer server, DatagramTransport transport, DTLSRequest request) protected voidprotected booleanestablishSession(DTLSServerProtocol.ServerHandshakeState state, TlsSession sessionToResume) protected booleanprotected byte[]generate13EncryptedExtensions(Hashtable serverExtensions) Mirrors TlsServerProtocol.send13EncryptedExtensionsMessage.protected byte[]Mirrors TlsServerProtocol.generate13HelloRetryRequest.protected byte[]generate13ServerHello(DTLSServerProtocol.ServerHandshakeState state, boolean afterHelloRetryRequest) Mirrors TlsServerProtocol.generate13ServerHello.protected byte[]generateCertificateRequest(DTLSServerProtocol.ServerHandshakeState state, CertificateRequest certificateRequest) protected byte[]generateCertificateStatus(DTLSServerProtocol.ServerHandshakeState state, CertificateStatus certificateStatus) protected byte[]generateCertificateVerify(DTLSServerProtocol.ServerHandshakeState state, DigitallySigned certificateVerify) protected byte[]generateNewSessionTicket(DTLSServerProtocol.ServerHandshakeState state, NewSessionTicket newSessionTicket) protected byte[]booleanprotected voidprotected voidnotifyClientCertificate(DTLSServerProtocol.ServerHandshakeState state, Certificate clientCertificate) protected voidprocessCertificateVerify(DTLSServerProtocol.ServerHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) protected voidprocessClientCertificate(DTLSServerProtocol.ServerHandshakeState state, byte[] body) protected voidprocessClientHello(DTLSServerProtocol.ServerHandshakeState state, byte[] body) protected voidprocessClientHello(DTLSServerProtocol.ServerHandshakeState state, ClientHello clientHello) protected voidprocessClientHelloRetry(DTLSServerProtocol.ServerHandshakeState state, byte[] body) RFC 8446 4.1.2.protected voidprocessClientKeyExchange(DTLSServerProtocol.ServerHandshakeState state, byte[] body) protected voidprocessClientSupplementalData(DTLSServerProtocol.ServerHandshakeState state, byte[] body) protected voidreceive13ClientCertificate(DTLSServerProtocol.ServerHandshakeState state, byte[] body) Mirrors TlsServerProtocol.receive13ClientCertificate.protected voidreceive13ClientCertificateVerify(DTLSServerProtocol.ServerHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) Mirrors TlsServerProtocol.receive13ClientCertificateVerify.protected voidreceive13ClientFinished(DTLSServerProtocol.ServerHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) Mirrors TlsServerProtocol.receive13ClientFinished (TlsProtocol.process13FinishedMessage).protected byte[]send13ServerHelloCoda(DTLSServerProtocol.ServerHandshakeState state, org.bouncycastle.tls.DTLSReliableHandshake handshake, boolean afterHelloRetryRequest) Mirrors TlsServerProtocol.send13ServerHelloCoda: install the handshake traffic keys, then send EncryptedExtensions, Certificate, CertificateVerify and Finished.protected DTLSTransportserverHandshake(DTLSServerProtocol.ServerHandshakeState state, DTLSRequest request) protected DTLSTransportserverHandshake13(DTLSServerProtocol.ServerHandshakeState state, org.bouncycastle.tls.DTLSReliableHandshake handshake, boolean afterHelloRetryRequest) The DTLS 1.3 server handshake, entered once the ServerHello selecting DTLS 1.3 has been sent.voidsetVerifyRequests(boolean verifyRequests)
-
Field Details
-
verifyRequests
protected boolean verifyRequests
-
-
Constructor Details
-
DTLSServerProtocol
public DTLSServerProtocol()
-
-
Method Details
-
getVerifyRequests
public boolean getVerifyRequests() -
setVerifyRequests
public void setVerifyRequests(boolean verifyRequests) -
accept
- Throws:
IOException
-
accept
public DTLSTransport accept(TlsServer server, DatagramTransport transport, DTLSRequest request) throws IOException - Throws:
IOException
-
abortServerHandshake
protected void abortServerHandshake(DTLSServerProtocol.ServerHandshakeState state, short alertDescription) -
serverHandshake
protected DTLSTransport serverHandshake(DTLSServerProtocol.ServerHandshakeState state, DTLSRequest request) throws IOException - Throws:
IOException
-
serverHandshake13
protected DTLSTransport serverHandshake13(DTLSServerProtocol.ServerHandshakeState state, org.bouncycastle.tls.DTLSReliableHandshake handshake, boolean afterHelloRetryRequest) throws IOException The DTLS 1.3 server handshake, entered once the ServerHello selecting DTLS 1.3 has been sent. Mirrors the 1.3 portions of TlsServerProtocol.send13ServerHelloCoda and handle13HandshakeMessage: the server's flight goes out under the handshake traffic keys at epoch 2, and both directions move to the application traffic keys at epoch 3 once the client's Finished has been verified.- Throws:
IOException
-
send13ServerHelloCoda
protected byte[] send13ServerHelloCoda(DTLSServerProtocol.ServerHandshakeState state, org.bouncycastle.tls.DTLSReliableHandshake handshake, boolean afterHelloRetryRequest) throws IOException Mirrors TlsServerProtocol.send13ServerHelloCoda: install the handshake traffic keys, then send EncryptedExtensions, Certificate, CertificateVerify and Finished.- Returns:
- the transcript hash through the server's Finished, which the application traffic secrets are derived from once the client's Finished has been received.
- Throws:
IOException
-
generate13ServerHello
protected byte[] generate13ServerHello(DTLSServerProtocol.ServerHandshakeState state, boolean afterHelloRetryRequest) throws IOException Mirrors TlsServerProtocol.generate13ServerHello. Everything the DTLS 1.2 path already performed inprocessClientHello(ServerHandshakeState, ClientHello)- the padding check, server names, client signature algorithms, supported groups, heartbeat and TlsServer.processClientExtensions - is not repeated here.- Throws:
IOException
-
generate13HelloRetryRequest
protected byte[] generate13HelloRetryRequest(DTLSServerProtocol.ServerHandshakeState state) throws IOException Mirrors TlsServerProtocol.generate13HelloRetryRequest. A HelloRetryRequest is a ServerHello - same handshake type, 'random' set to the RFC 8446 4.1.3 magic value - and is sent through the ordinary flight machinery at epoch 0.The "cookie" extension here is the RFC 8446 4.2.2 retry token, opaque to the client and echoed back in its second ClientHello, exactly as TlsServerProtocol's is. It is deliberately not the RFC 9147 5.1 denial-of-service countermeasure: that requires the cookie to be verifiable without any retained per-connection state, which cannot be done from inside accept() - the handshake object already exists by the time this runs. DTLS 1.2 gets that property from
TODO[dtls13] A stateless HelloRetryRequest front end, as above.DTLSVerifiersitting in front of accept(), and DTLS 1.3 needs an equivalent front end, carrying the first ClientHello's transcript hash and the selected parameters in the cookie and reconstructing the transcript from the RFC 8446 4.4.1 "message_hash".- Throws:
IOException
-
processClientHelloRetry
protected void processClientHelloRetry(DTLSServerProtocol.ServerHandshakeState state, byte[] body) throws IOException RFC 8446 4.1.2. The second ClientHello must repeat the first without modification except for the "key_share", "early_data", "cookie", "pre_shared_key" and "padding" extensions, so none of the first-ClientHello processing is repeated: the fields checked here are the ones everything after this depends on having stayed put. The cookie itself is checked ingenerate13ServerHello(ServerHandshakeState, boolean), where the retry state is consumed.TODO[dtls13] Confirm the extensions in the ClientHello haven't changed either, which RFC 8446 4.1.2 also makes a MUST. Only the outer fields are compared below; TlsServerProtocol.generate13ServerHello carries the same gap, under its own "TODO[tls13] Confirm fields in the ClientHello haven't changed".
RFC 9147 5.3. The ClientHello's 'legacy_cookie' field exists for backwards compatibility with the DTLS 1.2 HelloVerifyRequest exchange; a DTLS 1.3 ClientHello must carry it empty, which generate13ServerHello enforces for this ClientHello as for the first.
- Throws:
IOException
-
generate13EncryptedExtensions
Mirrors TlsServerProtocol.send13EncryptedExtensionsMessage.- Throws:
IOException
-
generateCertificateVerify
protected byte[] generateCertificateVerify(DTLSServerProtocol.ServerHandshakeState state, DigitallySigned certificateVerify) throws IOException - Throws:
IOException
-
receive13ClientCertificate
protected void receive13ClientCertificate(DTLSServerProtocol.ServerHandshakeState state, byte[] body) throws IOException Mirrors TlsServerProtocol.receive13ClientCertificate. The message is parsed exactly as the DTLS 1.2 path parses it; RFC 8446 4.4.2's extra rule is only that the client must not send one unasked.- Throws:
IOException
-
receive13ClientCertificateVerify
protected void receive13ClientCertificateVerify(DTLSServerProtocol.ServerHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) throws IOException Mirrors TlsServerProtocol.receive13ClientCertificateVerify. The transcript passed in must exclude the CertificateVerify message itself, which is why it is read with a delayed digest.- Throws:
IOException
-
receive13ClientFinished
protected void receive13ClientFinished(DTLSServerProtocol.ServerHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) throws IOException Mirrors TlsServerProtocol.receive13ClientFinished (TlsProtocol.process13FinishedMessage). The transcript passed in must exclude the Finished message itself.- Throws:
IOException
-
generateCertificateRequest
protected byte[] generateCertificateRequest(DTLSServerProtocol.ServerHandshakeState state, CertificateRequest certificateRequest) throws IOException - Throws:
IOException
-
generateCertificateStatus
protected byte[] generateCertificateStatus(DTLSServerProtocol.ServerHandshakeState state, CertificateStatus certificateStatus) throws IOException - Throws:
IOException
-
generateNewSessionTicket
protected byte[] generateNewSessionTicket(DTLSServerProtocol.ServerHandshakeState state, NewSessionTicket newSessionTicket) throws IOException - Throws:
IOException
-
generateServerHello
protected byte[] generateServerHello(DTLSServerProtocol.ServerHandshakeState state) throws IOException - Throws:
IOException
-
cancelSession
-
establishSession
protected boolean establishSession(DTLSServerProtocol.ServerHandshakeState state, TlsSession sessionToResume) -
invalidateSession
-
notifyClientCertificate
protected void notifyClientCertificate(DTLSServerProtocol.ServerHandshakeState state, Certificate clientCertificate) throws IOException - Throws:
IOException
-
processClientCertificate
protected void processClientCertificate(DTLSServerProtocol.ServerHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processCertificateVerify
protected void processCertificateVerify(DTLSServerProtocol.ServerHandshakeState state, byte[] body, TlsHandshakeHash handshakeHash) throws IOException - Throws:
IOException
-
processClientHello
protected void processClientHello(DTLSServerProtocol.ServerHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processClientHello
protected void processClientHello(DTLSServerProtocol.ServerHandshakeState state, ClientHello clientHello) throws IOException - Throws:
IOException
-
processClientKeyExchange
protected void processClientKeyExchange(DTLSServerProtocol.ServerHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
processClientSupplementalData
protected void processClientSupplementalData(DTLSServerProtocol.ServerHandshakeState state, byte[] body) throws IOException - Throws:
IOException
-
expectCertificateVerifyMessage
-