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

refactor: remove legacy pkey impls #5241

Merged
merged 3 commits into from
Apr 8, 2025

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Apr 2, 2025

Release Summary:

Resolved issues:

resolves #5149

Description of changes:

After eca2a8e and ec05a02, the EVP pkey implementation has complete parity with the legacy pkey implementations. This PR therefore removes all the legacy pkey implementations and completely replaces them with the evp pkey implementation. It's mostly deletes, renames, fixing includes, and swapping s2n_pkey_evp_init in for s2n_rsa_pkey_init/s2n_ecdsa_pkey_init/s2n_rsa_pss_pkey_init.

Callouts

It's a lot of changed files, even if most of the changes are trivial (half the files are just include changes). Let me know if you don't feel confident reviewing it, and I'll figure out how to break it up into smaller chunks.

Testing:

In the previous PRs I added pkey tests for size/encrypt/decrypt/match that were implementation agnostic, and in this PR I swapped the sign/verify tests to be implementation agnostic too. We shouldn't have to write a new pkey test for every new implementation.

Previously both the encrypt/decrypt and sign/verify tests also included checks that the hard-coded known values worked with the legacy methods, so since I haven't changed the hard-coded known values we retain that guarantee even tho I've removed the legacy methods.

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 Apr 2, 2025
@lrstewart lrstewart force-pushed the openssl3fips_evp_3c_3 branch from 1ce54d2 to fbf962c Compare April 2, 2025 20:41
@lrstewart lrstewart force-pushed the openssl3fips_evp_3c_3 branch from fbf962c to 13689db Compare April 2, 2025 21:18
Comment on lines +32 to +33
#include "error/s2n_errno.h"
#include "utils/s2n_safety.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These headers were inherited from s2n_pkey.h before.

server_conn->handshake_params.client_public_key.key.rsa_key.rsa = public_key.key.rsa_key.rsa;
server_conn->handshake_params.client_public_key.pkey = public_key.pkey;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wouldn't have been working for a while, even if it compiled. The fuzz test would have always trivially failed. I'm also not sure it's not still trivially failing for another reason. I just got it compiling again.

We badly need to revisit our fuzz tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Time to look at the fuzz test coverage report?

Comment on lines +29 to +31
#ifndef EVP_PKEY_RSA_PSS
#define EVP_PKEY_RSA_PSS EVP_PKEY_NONE
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved this out of s2n_rsa_pss.h because rather alarmingly, EVP_PKEY_RSA_PSS is defined in openssl/evp.h and s2n_rsa_pss.h wasn't actually including openssl/evp.h. So EVP_PKEY_RSA_PSS only wasn't always EVP_PKEY_NONE because another included header happened to include openssl/evp.h.

This highlights the issue with #ifdefs in general, but in this particular case it's at least safer to do this in this file bc this file actually uses EVP_PKEY_RSA_PSS, so also requires other symbols from openssl/evp.h. We're less likely to just remove the openssl/evp.h include.

@lrstewart lrstewart marked this pull request as ready for review April 2, 2025 21:53
@lrstewart lrstewart requested a review from goatgoose April 4, 2025 20:07
@lrstewart lrstewart requested a review from maddeleine April 4, 2025 23:41
@lrstewart lrstewart enabled auto-merge April 7, 2025 19:42
@lrstewart lrstewart added this pull request to the merge queue Apr 7, 2025
Merged via the queue into aws:main with commit 0ece10f Apr 8, 2025
45 of 49 checks passed
@lrstewart lrstewart deleted the openssl3fips_evp_3c_3 branch April 8, 2025 00:41
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.

Completely replace legacy pkey impls with EVP impl
3 participants