Skip to content
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

Add MLKEM768 Hybrid Groups to libssl #1849

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Conversation

alexw91
Copy link
Contributor

@alexw91 alexw91 commented Sep 11, 2024

Issues:

None

Description of changes:

Add support for X25519MLKEM768 and SecP256r1MLKEM768 from https://datatracker.ietf.org/doc/html/draft-kwiatkowski-tls-ecdhe-mlkem

Call-outs:

A bug in BadHybridKeyShareAcceptTest and BadHybridKeyShareFinishTest was fixed. The for loop to corrupt each half of the Hybrid key share did not correctly calculate the bounds index after the 1st iteration. This bug would only partially corrupt the buffer on later iterations, and not corrupt the buffer at all if the 2nd KeyShare was smaller than the first (which is true for X25519MLKEM768).

Testing:

All existing unit tests for X25519Kyber768Draft00 and SecP256r1Kyber768Draft00 were updated or copied, and equivalent tests added for X25519MLKEM768 and SecP256r1MLKEM768 .

Interoperability with BoringSSL for X25519MLKEM768 has been confirmed to work with AWS-LC as both client and server. BoringSSL does not implement SecP256r1MLKEM768.

./boringssl/build/tool/bssl s_server -curves X25519MLKEM768:X25519Kyber768Draft00:X25519 -accept 44330 
./aws-lc/build/tool/bssl s_client -curves X25519MLKEM768 -connect 127.0.0.1:44330
./aws-lc/build/tool/bssl s_server -curves X25519MLKEM768:X25519Kyber768Draft00:X25519 -accept 44330
./boringssl/build/tool/bssl s_client -curves X25519MLKEM768 -connect 127.0.0.1:44330

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.52%. Comparing base (9d21f38) to head (1fc854f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1849   +/-   ##
=======================================
  Coverage   78.51%   78.52%           
=======================================
  Files         583      583           
  Lines       98809    98821   +12     
  Branches    14159    14160    +1     
=======================================
+ Hits        77583    77598   +15     
+ Misses      20598    20596    -2     
+ Partials      628      627    -1     

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

ssl/ssl_key_share.cc Outdated Show resolved Hide resolved
ssl/ssl_key_share.cc Show resolved Hide resolved
ssl/ssl_key_share.cc Outdated Show resolved Hide resolved
ssl/ssl_test.cc Outdated Show resolved Hide resolved
torben-hansen
torben-hansen previously approved these changes Sep 12, 2024
@WillChilds-Klein
Copy link
Contributor

Hm, I'm getting 404'd on the description's linked draft RFC.

},

{
SSL_GROUP_SECP256R1_MLKEM768, // group_id
Copy link
Contributor

Choose a reason for hiding this comment

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

where do we configure AWS-LC's group preference? is that done by the caller's configuration of SupportedGroups, or do we maintain an ordered list somewhere as with s2n security policies?

Copy link
Contributor Author

@alexw91 alexw91 Sep 13, 2024

Choose a reason for hiding this comment

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

If no supported group override preference list is configured for the SSL connection, the default supported group list is used here:
https://github.com/aws/aws-lc/blob/main/ssl/extensions.cc#L309-L320

Copy link
Contributor

Choose a reason for hiding this comment

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

should we add the hybrid MLKEM groups to this list and prefer them over regular ECDH? that would enable PQ TLS by default for consumers who don't configure a preference list (i'm not sure how common this is among our libssl consumers).

include/openssl/ssl.h Show resolved Hide resolved
crypto/obj/objects.txt Show resolved Hide resolved
ssl/ssl_test.cc Show resolved Hide resolved
ssl/ssl_test.cc Show resolved Hide resolved
@andrewhop
Copy link
Contributor

Interoperability with BoringSSL for X25519MLKEM768 has been confirmed to work with AWS-LC as both client and server. BoringSSL does not implement SecP256r1MLKEM768.

Can you add this as an automated test to our CI to ensure we don't break in the future. Have you tested this with s2n-tls?

@alexw91
Copy link
Contributor Author

alexw91 commented Sep 13, 2024

Interoperability with BoringSSL for X25519MLKEM768 has been confirmed to work with AWS-LC as both client and server. BoringSSL does not implement SecP256r1MLKEM768.

Can you add this as an automated test to our CI to ensure we don't break in the future. Have you tested this with s2n-tls?

If this was a small addition to an existing test, I'd be happy to, but creating a brand new AWS-LC to BoringSSL CI integration test seems out of scope for this PR. s2n-tls does not yet have support for either of these algorithms.

@alexw91
Copy link
Contributor Author

alexw91 commented Sep 13, 2024

@torben-hansen torben-hansen merged commit efa9d6c into aws:main Sep 17, 2024
110 checks passed
smittals2 added a commit that referenced this pull request Sep 19, 2024
## What's Changed
* More tweaks for Ruby integration by @samuel40791765 in
#1852
* Implementation of EVP_PKEY_CTX_ctrl_str for various key types by
@justsmth in #1850
* Add MLKEM768 Hybrid Groups to libssl by @alexw91 in
#1849
* add support for PEM_write_bio_PrivateKey_traditional by
@samuel40791765 in #1845
* Update s2n-bignum subtree by @torben-hansen in
#1861
* Add asserts in testing to fix Coverity alert by @smittals2 in
#1864
* Disable CRYPTO_is_AVX512IFMA_capable by @justsmth in
#1858


**Full Changelog**:
v1.35.0...v1.35.1

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
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.

5 participants