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: move "s2n_libcrypto_is" methods into s2n_libcrypto.h #5117

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

lrstewart
Copy link
Contributor

Release Summary:

Description of changes:

This change should not change any code behavior.

It bothers me that we have a bunch of methods with the prefix "s2n_libcrypto", implemented in "s2n_libcrypto.c", but declared in "s2n_openssl.h". This PR moves them to s2n_libcrypto.h, where you'd expect to find them. It also renames the s2n_openssl_test to the s2n_libcrypto_test, because it was only testing the "s2n_libcrypto" methods.

As part of that move, I also tried to update our s2n_openssl.h includes. Mostly if s2n_openssl.h isn't included somewhere, you'll get an error because a symbol it declares is missing. EXCEPT for OPENSSL_VERSION_NUMBER: it redefines OPENSSL_VERSION_NUMBER for libressl

#if defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER == 0x20000000L)
#undef OPENSSL_VERSION_NUMBER
#if LIBRESSL_VERSION_NUMBER < 0x3050000fL
#define OPENSSL_VERSION_NUMBER 0x1000107fL
#else
#define OPENSSL_VERSION_NUMBER 0x1010000fL
#endif
#endif

There's probably a less error prone way to handle that, but I'm just here about the names :)

So to cleanup the includes I:

  • removed s2n_openssl.h as an include everywhere.
  • added it back to files that reference OPENSSL_VERSION_NUMBER
  • added it back to files that failed to compile due to missing symbols.
    I also added s2n_libcrypto.h as an include to files that failed to compile due to missing "s2n_libcrypto_is" symbols.

We definitely need a more comprehensive include cleanup, but I just didn't want to make the situation worse with this move.

Testing:

Existing tests pass. This should just be moving files around.

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

@lrstewart lrstewart marked this pull request as ready for review February 14, 2025 19:57
@@ -15,8 +15,6 @@

#include "s2n_pq.h"

#include "crypto/s2n_openssl.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

I manually checked that any macro defined/modified in s2n_openssl.h isn't being #ifdef'ed or #if defined() anywhere in the codebase. Therefore, it is safe to remove #include s2n_openssl.h in these locations.

@lrstewart lrstewart added this pull request to the merge queue Feb 18, 2025
Merged via the queue into aws:main with commit dcbec3e Feb 18, 2025
46 checks passed
@lrstewart lrstewart deleted the libcrypto_cleanup branch February 18, 2025 01:52
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Mar 3, 2025
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