Skip to content

Commit

Permalink
pr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
toidiu committed Nov 15, 2024
1 parent 5e481a9 commit 2614a58
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
4 changes: 0 additions & 4 deletions tests/features/S2N_LIBCRYPTO_SUPPORTS_ENGINE.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
*/
#include <openssl/engine.h>

#if defined(OPENSSL_NO_ENGINE)
#error "engine is not supported"
#endif

int s2n_noop_rand(unsigned char *buf, int num)
{
return 1;
Expand Down
22 changes: 20 additions & 2 deletions tests/unit/s2n_random_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,22 @@ int main(int argc, char **argv)

/* Feature probe */
{
#if defined(S2N_LIBCRYPTO_SUPPORTS_ENGINE) && defined(OPENSSL_NO_ENGINE)
FAIL_MSG("Logic error with the Engine feature probe.")
#if defined(OPENSSL_IS_AWSLC)
/* Negative test */
#if defined(S2N_LIBCRYPTO_SUPPORTS_ENGINE)
FAIL_MSG("Expected ENGINE feature probe to be disabled with AWS-LC");
#endif

#else

/* Positive test
*
* We expect ENGINE APIs to be available if `OPENSSL_NO_ENGINE` is not
* defined.
*/
#if !defined(OPENSSL_NO_ENGINE) && !defined(S2N_LIBCRYPTO_SUPPORTS_ENGINE)
FAIL_MSG("Expected ENGINE feature probe to be enabled");
#endif
#endif
};

Expand All @@ -916,6 +930,10 @@ int main(int argc, char **argv)
#if !defined(S2N_LIBCRYPTO_SUPPORTS_ENGINE)
EXPECT_FALSE(s2n_supports_custom_rand());
#endif

#if defined(OPENSSL_NO_ENGINE)
EXPECT_FALSE(s2n_supports_custom_rand());
#endif
};

/* For each test case, creates a child process that runs the test case.
Expand Down
2 changes: 2 additions & 0 deletions utils/s2n_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ bool s2n_supports_custom_rand()
{
#if !defined(S2N_LIBCRYPTO_SUPPORTS_ENGINE)
return false;
#elif defined(OPENSSL_NO_ENGINE)
return false;
#else
return !s2n_libcrypto_is_boringssl() && !s2n_libcrypto_is_libressl() && !s2n_libcrypto_is_awslc() && !s2n_is_in_fips_mode();
#endif
Expand Down

0 comments on commit 2614a58

Please sign in to comment.