Skip to content

[TLS 1.3] Server-Side Client Authentication#3081

Merged
reneme merged 5 commits intomasterfrom
tls13/server_side_client_auth
Dec 30, 2022
Merged

[TLS 1.3] Server-Side Client Authentication#3081
reneme merged 5 commits intomasterfrom
tls13/server_side_client_auth

Conversation

@reneme
Copy link
Copy Markdown
Collaborator

@reneme reneme commented Nov 30, 2022

Pull Request Dependencies

Description

Adds support for client authentication to the TLS 1.3 server implementation. Respective RFC 8448 test is passing, BoGo tests are passing.

Messages Certificate, Certificate_Request and CertificateVerify

The refactoring in this patch aims at making construction of those messages more self-contained. Instead of handing in the detailed information those messages need for their own construction, we hand in the higher-level objects that contain the necessary information. E.g. instead of passing the correct private key to CertificateVerify, it now gets a reference to the Credentials_Manager enabling its constructor to gather the correct private key pointer internally. This moves low-level logic and orchestration out of the Client/Server implementation classes.

For Certificate_Request_13 this even moves the decision whether or not to even request certificate authentication from the client into a factory method (see Certificate_Request_13::maybe_create()). I'm myself not sure yet, whether I actually like that pattern. Though, it takes complexity out of tls_server_impl_13.cpp which I consider a good thing.

Certificate::setup_entries() might seem to be overly simple, but it was created as a pre-text to the OCSP stapling pull request where it will be filled with more logic.

FIX: Unprotected Alerts

During the development of this functionality, BoGo tests replied with a plaintext TLS alert when we (the server) already exclusively expected encrypted records. Turns out, that is not okay and needed a fix (TLS::Cipher_State::must_expect_unprotected_alert_traffic()).

Scenario: After receiving a Client Hello we (the server) respond with our first flight. Having just sent the server hello (with enough cryptographic information to encrypt further traffic) we expected the client to respond with protected records only. However, if the client fails to decode the Server Hello and must respond with an Alert, it is forced to send this alert in the clear, as it didn't understand our key negotiation info. We (as the server) need to expect that and allow unprotected Alerts, despite already having derived valid key material.

It appears to me, that the described situation is the only scenario where unprotected records need to be expected by either the client or the server despite cryptographic material already being available. Unfortunately, that was not explicitly pointed out in the RFC it seems.

@reneme reneme added this to the Botan 3.0.0 milestone Nov 30, 2022
@randombit randombit self-requested a review November 30, 2022 15:25
@reneme reneme force-pushed the tls13/server_side_client_auth branch 2 times, most recently from aa3818b to 8ff80d0 Compare December 9, 2022 13:06
@reneme reneme mentioned this pull request Dec 9, 2022
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Dec 9, 2022

Codecov Report

Base: 87.97% // Head: 87.99% // Increases project coverage by +0.01% 🎉

Coverage data is based on head (a009a56) compared to base (cb1eb53).
Patch coverage: 87.34% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3081      +/-   ##
==========================================
+ Coverage   87.97%   87.99%   +0.01%     
==========================================
  Files         600      600              
  Lines       66902    67054     +152     
  Branches     6687     6698      +11     
==========================================
+ Hits        58857    59003     +146     
- Misses       5223     5235      +12     
+ Partials     2822     2816       -6     
Impacted Files Coverage Δ
src/bogo_shim/bogo_shim.cpp 72.99% <ø> (ø)
src/lib/tls/msg_client_hello.cpp 78.52% <ø> (+0.35%) ⬆️
src/lib/tls/tls_extensions.cpp 82.01% <0.00%> (-0.40%) ⬇️
src/lib/tls/msg_cert_verify.cpp 90.36% <60.00%> (-2.14%) ⬇️
src/lib/tls/tls13/tls_server_impl_13.cpp 76.42% <73.17%> (+2.95%) ⬆️
src/lib/tls/tls13/msg_certificate_req_13.cpp 73.17% <73.68%> (-0.75%) ⬇️
src/tests/test_tls_rfc8448.cpp 90.16% <85.89%> (-0.12%) ⬇️
src/lib/tls/tls13/msg_certificate_13.cpp 87.85% <100.00%> (+7.60%) ⬆️
src/lib/tls/tls13/tls_cipher_state.cpp 98.93% <100.00%> (+0.02%) ⬆️
src/lib/tls/tls13/tls_client_impl_13.cpp 84.10% <100.00%> (-0.19%) ⬇️
... and 20 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

@reneme reneme force-pushed the tls13/server_side_client_auth branch from 8ff80d0 to cf095ed Compare December 9, 2022 13:54
@reneme reneme mentioned this pull request Dec 9, 2022
7 tasks
@reneme reneme force-pushed the tls13/server_side_client_auth branch from cf095ed to 17d2c97 Compare December 15, 2022 09:58
Copy link
Copy Markdown
Owner

@randombit randombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reviewed the final 5 commits

// This will call the modification callback multiple times. Once for
// each certificate in the `cert_chain`. Users that want to add an
// extension to a specific Certificate Entry might have a hard time
// to distinguish them.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could perhaps add a variant that additionally accepts the certificate in question, which by default just forwards the call to tls_modify_extensions and discards the cert. This could happen later on, even post-3.0, so I don't consider it at all essential.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's roughly what I had in mind writing this comment. I'd add it when the need comes up.

Scenario: After receiving a Client Hello the server responds with its
first flight. The client fails to decode the Server Hello and responds
with an Alert. It cannot protect this Alert, as it didn't understand the
server's key negotiation messages and is forced to send the Alert in the
clear. The server needs to expect that and allow unprotected Alerts,
despite it already having derived key material.
This makes Certificate_13 smarter. The class now takes care of
gathering the necessary information in its own constructor.
The message class now takes full care of it's own creation by
pulling the required private key from the credentials manager
@reneme reneme force-pushed the tls13/server_side_client_auth branch from 17d2c97 to a009a56 Compare December 30, 2022 10:16
@reneme reneme merged commit 7793d70 into master Dec 30, 2022
@randombit randombit deleted the tls13/server_side_client_auth branch December 30, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants