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

feat: getter for TLS1.2 master secrets #4470

Merged
merged 7 commits into from
Mar 26, 2024
Merged

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Mar 25, 2024

Description of changes:

A customer needs the TLS1.2 master secret for compatibility reasons. I'm adding a getter to make it available, but limiting it to TLS1.2 where it can do less damage. After all, we already pass around the TLS1.2 master secret in session tickets, and TLS1.2 exporters would use the master secret too.

Callouts:

I'm intentionally not communicating the length of the master secret in any way except documentation. If we need to support secrets with variable lengths like TLS1.3, we can follow our usual pattern and add a s2n_connection_get_master_secret_length method. But I really don't want to support TLS1.3 master secrets, ever 😭

Testing:

New unit tests, including a self-talk to make sure the secret is actually available after the handshake.

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

@github-actions github-actions bot added the s2n-core team label Mar 25, 2024
@lrstewart lrstewart marked this pull request as ready for review March 25, 2024 08:37
@lrstewart lrstewart requested review from goatgoose and jmayclin March 25, 2024 08:37
* @returns S2N_SUCCESS on success, S2N_FAILURE otherwise. `secret_bytes`
* will be set on success.
*/
S2N_API extern int s2n_connection_get_master_secret(const struct s2n_connection *conn,
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay for less scary rust bindings 🥳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eeeeeeeeeh we still pass it a *mut pointer 🙃

I was just looking at this for our Send/Sync safety. No matter what we do with const, the bindings are still scary. You can get a *mut s2n_connection from a &Connection, because you can get a *mut s2n_connection from a &NonNull<s2n_connection>. The joys of FFI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, the * mut isn't very pretty but I'm mostly just celebrating the fact that the rust connection parameter &self is way more obviously accurate for these bindings. Little wins 😄

tls/s2n_crypto.c Show resolved Hide resolved
@lrstewart lrstewart requested a review from jmayclin March 26, 2024 06:18
/* Test: self-talk */
for (size_t i = 0; i < s2n_array_len(supported_versions); i++) {
const uint8_t version = supported_versions[i];
if (s2n_is_in_fips_mode() && version == S2N_SSLv3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It might be nice to add a comment on why this restriction is necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's unrelated to what we're testing here and probably a bug: #4476 At least, the first blocker I found was clearly a bug.

@lrstewart lrstewart enabled auto-merge (squash) March 26, 2024 21:00
@lrstewart lrstewart merged commit e1f6f01 into aws:main Mar 26, 2024
31 checks passed
@lrstewart lrstewart deleted the master_secret branch March 26, 2024 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants