Skip to content

Expose TLS Group through MsQuic API #5030

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

Merged
merged 7 commits into from
May 1, 2025
Merged

Expose TLS Group through MsQuic API #5030

merged 7 commits into from
May 1, 2025

Conversation

nibanks
Copy link
Member

@nibanks nibanks commented Apr 19, 2025

Description

The TLS group is useful to understand exactly what level of security is being negotiated during the TLS handshake. For instance, this allows perf tests to ensure they are apples to apples.

On a side note, OpenSSL negotiates weaker/simpler/less-CPU-intensive groups by default which is why their HPS numbers were so high. A follow up PR needs to fix that.

Testing

Local testing

Documentation

Added some minimal docs.

Copy link

Cargo

The rust bindings need to be updated. Please apply (git apply) this diff:

diff --git a/src/rs/ffi/linux_bindings.rs b/src/rs/ffi/linux_bindings.rs
index 3a7af63..e812b9e 100644
--- a/src/rs/ffi/linux_bindings.rs
+++ b/src/rs/ffi/linux_bindings.rs
@@ -718,6 +718,17 @@ pub type QUIC_HASH_ALGORITHM = ::std::os::raw::c_uint;
 pub const QUIC_KEY_EXCHANGE_ALGORITHM_QUIC_KEY_EXCHANGE_ALGORITHM_NONE:
     QUIC_KEY_EXCHANGE_ALGORITHM = 0;
 pub type QUIC_KEY_EXCHANGE_ALGORITHM = ::std::os::raw::c_uint;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_NONE: QUIC_TLS_GROUP = 0;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP256R1: QUIC_TLS_GROUP = 23;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP384R1: QUIC_TLS_GROUP = 24;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_X25519: QUIC_TLS_GROUP = 29;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_MLKEM512: QUIC_TLS_GROUP = 512;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_MLKEM768: QUIC_TLS_GROUP = 513;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_MLKEM1024: QUIC_TLS_GROUP = 514;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP256R1MLKEM768: QUIC_TLS_GROUP = 4587;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_X25519MLKEM768: QUIC_TLS_GROUP = 4588;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP384R1MLKEM1024: QUIC_TLS_GROUP = 4589;
+pub type QUIC_TLS_GROUP = ::std::os::raw::c_uint;
 pub const QUIC_CIPHER_SUITE_QUIC_CIPHER_SUITE_TLS_AES_128_GCM_SHA256: QUIC_CIPHER_SUITE = 4865;
 pub const QUIC_CIPHER_SUITE_QUIC_CIPHER_SUITE_TLS_AES_256_GCM_SHA384: QUIC_CIPHER_SUITE = 4866;
 pub const QUIC_CIPHER_SUITE_QUIC_CIPHER_SUITE_TLS_CHACHA20_POLY1305_SHA256: QUIC_CIPHER_SUITE =
@@ -741,10 +752,11 @@ pub struct QUIC_HANDSHAKE_INFO {
     pub KeyExchangeAlgorithm: QUIC_KEY_EXCHANGE_ALGORITHM,
     pub KeyExchangeStrength: i32,
     pub CipherSuite: QUIC_CIPHER_SUITE,
+    pub TlsGroup: QUIC_TLS_GROUP,
 }
 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
 const _: () = {
-    ["Size of QUIC_HANDSHAKE_INFO"][::std::mem::size_of::<QUIC_HANDSHAKE_INFO>() - 32usize];
+    ["Size of QUIC_HANDSHAKE_INFO"][::std::mem::size_of::<QUIC_HANDSHAKE_INFO>() - 36usize];
     ["Alignment of QUIC_HANDSHAKE_INFO"][::std::mem::align_of::<QUIC_HANDSHAKE_INFO>() - 4usize];
     ["Offset of field: QUIC_HANDSHAKE_INFO::TlsProtocolVersion"]
         [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, TlsProtocolVersion) - 0usize];
@@ -762,6 +774,8 @@ const _: () = {
         [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, KeyExchangeStrength) - 24usize];
     ["Offset of field: QUIC_HANDSHAKE_INFO::CipherSuite"]
         [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, CipherSuite) - 28usize];
+    ["Offset of field: QUIC_HANDSHAKE_INFO::TlsGroup"]
+        [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, TlsGroup) - 32usize];
 };
 #[repr(C)]
 #[derive(Debug, Copy, Clone)]

Copy link

Cargo

The rust bindings need to be updated. Please apply (git apply) this diff:

diff --git a/src/rs/ffi/win_bindings.rs b/src/rs/ffi/win_bindings.rs
index 7963fe1..421fbe4 100644
--- a/src/rs/ffi/win_bindings.rs
+++ b/src/rs/ffi/win_bindings.rs
@@ -712,6 +712,17 @@ pub type QUIC_HASH_ALGORITHM = ::std::os::raw::c_int;
 pub const QUIC_KEY_EXCHANGE_ALGORITHM_QUIC_KEY_EXCHANGE_ALGORITHM_NONE:
     QUIC_KEY_EXCHANGE_ALGORITHM = 0;
 pub type QUIC_KEY_EXCHANGE_ALGORITHM = ::std::os::raw::c_int;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_NONE: QUIC_TLS_GROUP = 0;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP256R1: QUIC_TLS_GROUP = 23;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP384R1: QUIC_TLS_GROUP = 24;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_X25519: QUIC_TLS_GROUP = 29;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_MLKEM512: QUIC_TLS_GROUP = 512;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_MLKEM768: QUIC_TLS_GROUP = 513;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_MLKEM1024: QUIC_TLS_GROUP = 514;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP256R1MLKEM768: QUIC_TLS_GROUP = 4587;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_X25519MLKEM768: QUIC_TLS_GROUP = 4588;
+pub const QUIC_TLS_GROUP_QUIC_TLS_GROUP_SECP384R1MLKEM1024: QUIC_TLS_GROUP = 4589;
+pub type QUIC_TLS_GROUP = ::std::os::raw::c_int;
 pub const QUIC_CIPHER_SUITE_QUIC_CIPHER_SUITE_TLS_AES_128_GCM_SHA256: QUIC_CIPHER_SUITE = 4865;
 pub const QUIC_CIPHER_SUITE_QUIC_CIPHER_SUITE_TLS_AES_256_GCM_SHA384: QUIC_CIPHER_SUITE = 4866;
 pub const QUIC_CIPHER_SUITE_QUIC_CIPHER_SUITE_TLS_CHACHA20_POLY1305_SHA256: QUIC_CIPHER_SUITE =
@@ -735,10 +746,11 @@ pub struct QUIC_HANDSHAKE_INFO {
     pub KeyExchangeAlgorithm: QUIC_KEY_EXCHANGE_ALGORITHM,
     pub KeyExchangeStrength: i32,
     pub CipherSuite: QUIC_CIPHER_SUITE,
+    pub TlsGroup: QUIC_TLS_GROUP,
 }
 #[allow(clippy::unnecessary_operation, clippy::identity_op)]
 const _: () = {
-    ["Size of QUIC_HANDSHAKE_INFO"][::std::mem::size_of::<QUIC_HANDSHAKE_INFO>() - 32usize];
+    ["Size of QUIC_HANDSHAKE_INFO"][::std::mem::size_of::<QUIC_HANDSHAKE_INFO>() - 36usize];
     ["Alignment of QUIC_HANDSHAKE_INFO"][::std::mem::align_of::<QUIC_HANDSHAKE_INFO>() - 4usize];
     ["Offset of field: QUIC_HANDSHAKE_INFO::TlsProtocolVersion"]
         [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, TlsProtocolVersion) - 0usize];
@@ -756,6 +768,8 @@ const _: () = {
         [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, KeyExchangeStrength) - 24usize];
     ["Offset of field: QUIC_HANDSHAKE_INFO::CipherSuite"]
         [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, CipherSuite) - 28usize];
+    ["Offset of field: QUIC_HANDSHAKE_INFO::TlsGroup"]
+        [::std::mem::offset_of!(QUIC_HANDSHAKE_INFO, TlsGroup) - 32usize];
 };
 #[repr(C)]
 #[derive(Debug, Copy, Clone)]

Copy link

codecov bot commented Apr 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.01%. Comparing base (d6af38c) to head (2889424).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5030      +/-   ##
==========================================
- Coverage   87.19%   87.01%   -0.18%     
==========================================
  Files          59       59              
  Lines       17927    17927              
==========================================
- Hits        15632    15600      -32     
- Misses       2295     2327      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nibanks nibanks merged commit 64c7089 into main May 1, 2025
288 of 290 checks passed
@nibanks nibanks deleted the tls-group branch May 1, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants