Skip to content

Commit

Permalink
Update key share group ranking algorithm
Browse files Browse the repository at this point in the history
In case no user group ranking is set, all groups are now ranked equally
instead of the order in the `preferredGroup` array. This is the
behavior already indicated in the comment header of the function.

This change is necessary for applications that do not set their own
group ranking (via `wolfSSL_CTX_set_groups()` for example). When such an
application creates a TLS server and receives a ClientHello message with
multiple key shares, now the first key share is selected instead of the
one with the lowest index in the `preferredGroup` array.

Recent browsers with PQC support place two key shares in their
ClientHello message: a hybrid PQC + X25519 one and at least one
classic-only one. The hybrid one is the first one, indicating a
preference. Without this change, however, always the classic-only key
share has been selected, as these algorithms have a lower index in the
`preferredGroup` array compared to the PQC hybrids.

Tested using a patched version of NGINX.

Signed-off-by: Tobias Frauenschläger <tobias.frauenschlaeger@oth-regensburg.de>
  • Loading branch information
Frauschi committed Nov 12, 2024
1 parent dc14001 commit 8858ac7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -10545,8 +10545,7 @@ static int TLSX_KeyShare_GroupRank(const WOLFSSL* ssl, int group)
byte numGroups;

if (ssl->numGroups == 0) {
groups = preferredGroup;
numGroups = PREFERRED_GROUP_SZ;
return 0;
}
else {
groups = ssl->group;
Expand Down

0 comments on commit 8858ac7

Please sign in to comment.