Skip to content

Commit

Permalink
No urandom test w/ AWSLC_SNAPSAFE_TESTING
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jun 19, 2024
1 parent c184e5b commit e01c4ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
7 changes: 2 additions & 5 deletions crypto/fipsmodule/rand/snapsafe_detect_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static int init_sgn_file(void** addr) {
*addr = nullptr;

// This file should've been created during test initialization
const int fd_sgn = open(CRYPTO_get_sysgenid_path(), O_RDWR | O_APPEND);
const int fd_sgn = open(CRYPTO_get_sysgenid_path(), O_RDWR);
if (fd_sgn == -1) {
return 0;
}
Expand All @@ -33,12 +33,9 @@ static int init_sgn_file(void** addr) {
return 0;
}

if (0 != fsync(fd_sgn)) {
return 0;
}

void* my_addr = mmap(nullptr, sizeof(uint32_t), PROT_WRITE, MAP_SHARED, fd_sgn, 0);
if (my_addr == MAP_FAILED) {
close(fd_sgn);
return 0;
}

Expand Down
12 changes: 3 additions & 9 deletions crypto/fipsmodule/rand/urandom_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#include "snapsafe_detect.h"

#if defined(OPENSSL_X86_64) && !defined(BORINGSSL_SHARED_LIBRARY) && \
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && defined(USE_NR_getrandom)
!defined(BORINGSSL_UNSAFE_DETERMINISTIC_MODE) && \
defined(USE_NR_getrandom) && !defined(AWSLC_SNAPSAFE_TESTING)

#include <linux/types.h>

Expand Down Expand Up @@ -611,13 +612,6 @@ int main(int argc, char **argv) {
if (getenv("BORINGSSL_IGNORE_MADV_WIPEONFORK")) {
CRYPTO_fork_detect_ignore_madv_wipeonfork_for_testing();
}
#if defined(OPENSSL_LINUX) && defined(AWSLC_SNAPSAFE_TESTING)
// When snapsafe testing is enabled, the sysgenid file must be created prior
// to running the test.
if (1 != HAZMAT_init_sysgenid_file()) {
abort();
}
#endif

return RUN_ALL_TESTS();
}
Expand All @@ -630,4 +624,4 @@ int main(int argc, char **argv) {
}

#endif // X86_64 && !SHARED_LIBRARY && !UNSAFE_DETERMINISTIC_MODE &&
// USE_NR_getrandom
// USE_NR_getrandom && !AWSLC_SNAPSAFE_TESTING

0 comments on commit e01c4ab

Please sign in to comment.