Conversation
bbd8d66 to
62750e1
Compare
17c2e54 to
26b593c
Compare
62750e1 to
09dc896
Compare
83d36e5 to
8d8f518
Compare
Codecov ReportBase: 91.80% // Head: 91.80% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #2988 +/- ##
==========================================
- Coverage 91.80% 91.80% -0.01%
==========================================
Files 599 599
Lines 72086 72138 +52
Branches 6601 6609 +8
==========================================
+ Hits 66181 66225 +44
- Misses 5905 5913 +8
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
This provides a hook for the application to decide whether a received close_notify from the peer should be echoed or not.
... that allows applications to provide stapled OCSP responses for all (or some) certificates added to the Certificate hand- shake message.
8d8f518 to
f5d7228
Compare
randombit
left a comment
There was a problem hiding this comment.
Change itself looks fine. My only real comment would be - should we really bother maintaining the deprecated 2-argument versions of the extensions manipulation functions? These are not used by typical applications anyway, and it would be easier to just update the signatures and mention the change in the migration guide.
|
Fully Agree on the extension manipulations. I'd be interested in your take on the |
|
The DH/ECDH callbacks where IIRC added at the request of @securitykernel in order to handle a few uses cases RSCS had namely around using custom (non-standard) ECC curves and also supporting hardware acceleration of the operations. We could IMO remove those entirely if you don't have a need along these lines anymore. It would simplify things a bit, especially if we did not have to account for any non-standard curves. For HW operations it might be better to approach this in some other way entirely, since as it is it only works in the context of TLS and not for general operations. |
|
Alternately your proposal with |
|
On session resumption, a strawman proposal: IIRC |
|
Thanks for your comments. Re: Session resumption: That's roughly what I had in mind 👍. I'll introduce those changes in a separate PR dealing with server-side session resumption (hopefully before the end of the year). Re: KEX callbacks: A quick glance into the consuming code didn't seem to use those. But I could certainly miss other internal products that might use it. @securitykernel ? I'll merge this now but might come back to this discussion. |
Status
This is meant to collect changes to the TLS callbacks (i.e. user-facing API changes). Currently, it is based on
masterwhere all client-side TLS 1.3 feature branches are merged. Changes required for the server implementation are additionally cherry-picked here. Note that this builds on the ideas outlined here.Callbacks that need attention
Here is a collection of insights we had during implementation with suggestions how to tackle the new requirements TLS 1.3 brings to the implementations. Those changes are not yet implemented and might require some discussion.
A word on 0-RTT
We don't have immediate plans to implement it. However, it would certainly have user-facing API implications. I have some hope to be able restrict the changes to additional API, rather than breaking changes, though. I.e. deferring 0-RTT support to after Botan 3.0 is released seems feasible to me.
tls_session_established(const Session&)(mandatory callback)Currently, applications are required to override that. The TLS 1.2 implementation calls it once a session is established, provides the established session's descriptor and applications must decide whether to persist the session for resumption or discard it. TLS 1.3 got rid of this type of session resumption. Instead it exclusively uses session tickets and allows multiple such tickets per connection (see
Callbacks::tls_session_ticket_received).I don't see a reasonable way to serve this callback with TLS 1.3. @randombit
Ideas:
tls_session_establishedusing a dedicated "session descriptor"tls_session_ticket_receivedfor TLS 1.2 session resumption storage decisiontls_session_should_be_stored?)tls_session_establishedTLS::Summaryobject, containing info about the new session, e.gvoid)tls_session_activated()as it carries roughly the same info without theTLS::Summarytls_session_established()totls_12_session_established()true, I guessTLS::Summaryas described above)Side-Note: New
TLS::ServerAPI to send new ticketsTLS 1.3 allows for an arbitrary number of tickets at any time after the handshake not just exactly one at the end of the handshake. Hence, we'll need something like
TLS::Server::send_new_session_ticket(std::chrono::seconds lifetime)allowing applications to send tickets at their own discretion.Side-Note: Application-defined Session Ticket content
RFC 8446 4.6.1: "The ticket itself is an opaque label. It MAY be either a database lookup key or a self-encrypted and self-authenticated value." And I think we should allow the application to decide that.
Given the current
Session_ManagerAPI, we might extend the sematics of::save(const Session&)to return the "ticket" where applications could return a lookup handle or the result ofSession::encrypt().Session_Manager::load_from_session_id()already has the right function signature to act as a counter-part. Nevertheless, I'd suggest to rename it to something likerestore_from_ticket()for clarity.tls_dh_agree()/tls_ecdh_agree()along withtls_decode_group_param()The agreement callbacks receive a public value along with a group specification. They generate a new keypair, perform an agreement and return a tuple of the shared secret and the public value to pass to the peer.
TLS 1.3 encourages clients to offer initial key share values. That allows the server to encrypt most of its first flight. In contrast to TLS 1.2 where the initial key offer is provided by the server in its first flight.
Technically, we could use the above-mentioned callbacks for TLS 1.3 as well. Main difference: The
tls_xx_agree()callbacks would be called in clients in a TLS 1.2 session establishment and in servers in a TLS 1.3 session establishment. That might cause confusion.Additionally, the callbacks are currently not used for the key agreement in the opposite direction. Instead the
PK_Key_Agreementis hard-coded.With KEMs entering the game for PQC-ready TLS we would likely want to add a
tls_kem_agree()if we decide to keep those callbacks at all.If we decide to keep these callbacks, I would suggest to separate ephemeral key generation from the actual agreement. Then both client and server as well as TLS 1.2 and 1.3 could make use of the same callback. To really be useful, one would probably also want to extract the key generation into a callback. Also, we might even abstract from the DH, ECDH (and KEM) differentiation and just have two callbacks, like so:
Does that sound about right? Somehow, I feel I'm missing the gist of that interface. @randombit
tls_log_error(),...debug()anddebug_bin()Not actually related to TLS 1.3; though none of these callbacks are used. Now might be a good time to remove them. YAGNI. ;)
Modifications at a Glance
Those modifications are already implemented and merged or are proposed as working implementations in this pull request.
tls_modify_extensions
Now has an additional parameter (
which_message) that provides context on what handshake message contains the extensions to be modified. The new overload is called for extensible messages introduced in TLS 1.3. The old overload is marked deprecated and is called by the default implementation of the new overload (after filtering out new TLS 1.3 extensible messages to keep its behaviour as close to legacy as possible).tls_examine_extensions
Analogous to the modify callback above.
tls_session_ticket_received
Added for TLS 1.3 session tickets. Not touched in this pull request.
tls_parse_ocsp_response
Added to influence the OCSP parsing behaviour. Mainly used to better support BoGo tests which send invalid responses that need to be ignored. Not touched in this pull request.
tls_current_timestamp
Added to inject user-defined timestamps. Mainly used for deterministic testing (using test vectors from RFC 8448) and certain BoGo tests that define a specific waiting period. Not touched in this pull request.
tls_peer_closed_connection
In contrast to older revisions, TLS 1.3 does not mandate an immediate in-kind response when receiving "close_notify". Applications can override this callback to get notified that no more data is to be expected from the peer. With TLS 1.3 they might legally continue sending data and finish with
Channel::close()at their own discretion. Returningtruefrom this callback will make TLS 1.3 behave just like 1.2 and reply with a "close_notify" immediately. This is the default behaviour.tls_provide_cert_chain_status
This allows applications to provide stapled OCSP responses for all (or some) intermediate certificates added to the Certificate handshake message. To the best of my understanding, previous versions of TLS allowed stapled OCSP responses for the leaf certificate, only.
By default, this callback invokes the old tls_provide_cert_status() callback: mimicking the behavior of TLS 1.2 and stapling an OCSP response for the leaf certificate, only.