Skip to content

Commit

Permalink
remove unnecessary ifdef
Browse files Browse the repository at this point in the history
  • Loading branch information
toidiu committed Nov 13, 2024
1 parent b5df39f commit 9489df5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
21 changes: 6 additions & 15 deletions tests/unit/s2n_override_openssl_random_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
*/

#include <openssl/dh.h>
#if S2N_LIBCRYPTO_SUPPORTS_ENGINE
#include <openssl/engine.h>
#endif

#include "api/s2n.h"
#include "crypto/s2n_dhe.h"
Expand All @@ -28,7 +25,6 @@
#include "utils/s2n_random.h"
#include "utils/s2n_safety.h"

#if S2N_LIBCRYPTO_SUPPORTS_ENGINE
const char reference_entropy_hex[] = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
Expand Down Expand Up @@ -72,6 +68,12 @@ int main(int argc, char **argv)
uint64_t bytes_used = 0;

BEGIN_TEST();

if (!s2n_supports_custom_rand()) {
/* Skip when custom rand is not supported */
END_TEST();
}

EXPECT_SUCCESS(s2n_disable_tls13_in_test());

EXPECT_NOT_NULL(dhparams_pem = malloc(S2N_MAX_TEST_PEM_SIZE));
Expand Down Expand Up @@ -139,14 +141,3 @@ int main(int argc, char **argv)

END_TEST();
}

#else

int main(int argc, char **argv)
{
BEGIN_TEST();

END_TEST();
}

#endif
2 changes: 0 additions & 2 deletions tests/unit/s2n_random_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,6 @@ static int s2n_random_rand_bytes_after_cleanup_cb(struct random_test_case *test_

static int s2n_random_rand_bytes_before_init(struct random_test_case *test_case)
{
#if S2N_LIBCRYPTO_SUPPORTS_ENGINE
if (s2n_supports_custom_rand()) {
/* Calling RAND_bytes will set a global random method */
unsigned char rndbytes[16] = { 0 };
Expand All @@ -812,7 +811,6 @@ static int s2n_random_rand_bytes_before_init(struct random_test_case *test_case)
/* RAND_bytes is still successful */
EXPECT_EQUAL(RAND_bytes(rndbytes, sizeof(rndbytes)), 1);
}
#endif
return S2N_SUCCESS;
}

Expand Down
4 changes: 4 additions & 0 deletions utils/s2n_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,10 @@ static int s2n_rand_init_cb_impl(void)

bool s2n_supports_custom_rand()
{
#if !defined(S2N_LIBCRYPTO_SUPPORTS_ENGINE)
return false;
#endif

return !s2n_libcrypto_is_boringssl() && !s2n_libcrypto_is_libressl() && !s2n_libcrypto_is_awslc() && !s2n_libcrypto_is_fips();
}

Expand Down

0 comments on commit 9489df5

Please sign in to comment.