-
Notifications
You must be signed in to change notification settings - Fork 568
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable the post-quantum x25519+ML-KEM-768 TLS 1.3 ciphersuite by default #4305
Open
randombit
wants to merge
1
commit into
master
Choose a base branch
from
jack/enable-pqc
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -128,8 +128,30 @@ Group_Params Policy::choose_key_exchange_group(const std::vector<Group_Params>& | |||||||||
|
||||||||||
const std::vector<Group_Params> our_groups = key_exchange_groups(); | ||||||||||
|
||||||||||
// Prefer groups that were offered by the peer for the sake of saving | ||||||||||
// an additional round trip. For TLS 1.2, this won't be used. | ||||||||||
const bool client_supports_pqc = std::any_of( | ||||||||||
supported_by_peer.begin(), supported_by_peer.end(), [](const Group_Params& g) { return g.is_post_quantum(); }); | ||||||||||
|
||||||||||
if(client_supports_pqc) { | ||||||||||
// If the client supports PQ and sent us a PQ key share we can use, take it | ||||||||||
for(auto g : offered_by_peer) { | ||||||||||
if(g.is_post_quantum() && value_exists(our_groups, g)) { | ||||||||||
return g; | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
// If the client supports PQ but not a PQ key share, still prefer PQ | ||||||||||
for(auto g : supported_by_peer) { | ||||||||||
if(g.is_post_quantum() && value_exists(our_groups, g)) { | ||||||||||
return g; | ||||||||||
} | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
// If we are here, the client did not offer any (mutually supported) | ||||||||||
// post quantum algorithms | ||||||||||
|
||||||||||
// Prefer groups that were offered by the peer, for the sake of saving an | ||||||||||
// additional round trip. For TLS 1.2, this won't be used. | ||||||||||
for(auto g : offered_by_peer) { | ||||||||||
if(value_exists(our_groups, g)) { | ||||||||||
return g; | ||||||||||
|
@@ -161,31 +183,63 @@ Group_Params Policy::default_dh_group() const { | |||||||||
} | ||||||||||
|
||||||||||
std::vector<Group_Params> Policy::key_exchange_groups() const { | ||||||||||
// Default list is ordered by performance | ||||||||||
return { | ||||||||||
// clang-format off | ||||||||||
#if defined(BOTAN_HAS_TLS_13_PQC) && defined(BOTAN_HAS_ML_KEM) && defined(BOTAN_HAS_X25519) | ||||||||||
Group_Params::HYBRID_X25519_ML_KEM_768, | ||||||||||
#endif | ||||||||||
|
||||||||||
#if defined(BOTAN_HAS_X25519) | ||||||||||
Group_Params::X25519, | ||||||||||
#endif | ||||||||||
|
||||||||||
Group_Params::SECP256R1, | ||||||||||
|
||||||||||
#if defined(BOTAN_HAS_X448) | ||||||||||
Group_Params::X448, | ||||||||||
Group_Params::X448, | ||||||||||
#endif | ||||||||||
|
||||||||||
Group_Params::SECP256R1, Group_Params::BRAINPOOL256R1, Group_Params::SECP384R1, Group_Params::BRAINPOOL384R1, | ||||||||||
Group_Params::SECP521R1, Group_Params::BRAINPOOL512R1, | ||||||||||
Group_Params::SECP384R1, | ||||||||||
Group_Params::SECP521R1, | ||||||||||
|
||||||||||
Group_Params::FFDHE_2048, Group_Params::FFDHE_3072, Group_Params::FFDHE_4096, Group_Params::FFDHE_6144, | ||||||||||
Group_Params::FFDHE_8192, | ||||||||||
Group_Params::BRAINPOOL256R1, | ||||||||||
Group_Params::BRAINPOOL384R1, | ||||||||||
Group_Params::BRAINPOOL512R1, | ||||||||||
|
||||||||||
Group_Params::FFDHE_2048, | ||||||||||
Group_Params::FFDHE_3072, | ||||||||||
|
||||||||||
// clang-format on | ||||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
std::vector<Group_Params> Policy::key_exchange_groups_to_offer() const { | ||||||||||
// by default, we offer a key share for the most-preferred group, only | ||||||||||
std::vector<Group_Params> groups_to_offer; | ||||||||||
const auto supported_groups = key_exchange_groups(); | ||||||||||
if(!supported_groups.empty()) { | ||||||||||
groups_to_offer.push_back(supported_groups.front()); | ||||||||||
/* | ||||||||||
By default, we offer a key share for the most-preferred pure ECC group | ||||||||||
by default, if any pure ECC group is enabled in the policy. | ||||||||||
Comment on lines
+218
to
+219
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
We skip PQC (or hybrids) since the keys are much larger and they are not | ||||||||||
yet widely supported; the most common case is we waste a lot of packet | ||||||||||
space sending a key share that the peer will ignore. | ||||||||||
|
||||||||||
Likewise we skip DH since the keys are large | ||||||||||
|
||||||||||
However if no pure ECC is enabled then we offer the first enabled | ||||||||||
key exchange group, no matter what kind it is. | ||||||||||
*/ | ||||||||||
const auto kex_groups = key_exchange_groups(); | ||||||||||
|
||||||||||
for(auto group : kex_groups) { | ||||||||||
if(group.is_pure_ecc_group()) { | ||||||||||
return {group}; | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
if(kex_groups.empty()) { | ||||||||||
return {}; | ||||||||||
} else { | ||||||||||
return {kex_groups[0]}; | ||||||||||
} | ||||||||||
return groups_to_offer; | ||||||||||
} | ||||||||||
|
||||||||||
size_t Policy::minimum_dh_group_size() const { | ||||||||||
|
@@ -651,7 +705,7 @@ void Policy::print(std::ostream& o) const { | |||||||||
} | ||||||||||
o << "maximum_session_tickets_per_client_hello = " << maximum_session_tickets_per_client_hello() << '\n'; | ||||||||||
o << "session_ticket_lifetime = " << session_ticket_lifetime().count() << '\n'; | ||||||||||
o << "reuse_session_tickets = " << reuse_session_tickets() << '\n'; | ||||||||||
print_bool(o, "reuse_session_tickets", reuse_session_tickets()); | ||||||||||
o << "new_session_tickets_upon_handshake_success = " << new_session_tickets_upon_handshake_success() << '\n'; | ||||||||||
o << "minimum_dh_group_size = " << minimum_dh_group_size() << '\n'; | ||||||||||
o << "minimum_ecdh_group_size = " << minimum_ecdh_group_size() << '\n'; | ||||||||||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a public API. I think we'll have to go with deprecation of
is_pure_kyber()
here.