threadstest_fips.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #if defined(_WIN32)
  10. # include <windows.h>
  11. #endif
  12. #include "testutil.h"
  13. #include "threadstest.h"
  14. static int success;
  15. static void thread_fips_rand_fetch(void)
  16. {
  17. EVP_MD *md;
  18. if (!TEST_true(md = EVP_MD_fetch(NULL, "SHA2-256", NULL)))
  19. success = 0;
  20. EVP_MD_free(md);
  21. }
  22. static int test_fips_rand_leak(void)
  23. {
  24. thread_t thread;
  25. success = 1;
  26. if (!TEST_true(run_thread(&thread, thread_fips_rand_fetch)))
  27. return 0;
  28. if (!TEST_true(wait_for_thread(thread)))
  29. return 0;
  30. return TEST_true(success);
  31. }
  32. int setup_tests(void)
  33. {
  34. /*
  35. * This test MUST be run first. Once the default library context is set
  36. * up, this test will always pass.
  37. */
  38. ADD_TEST(test_fips_rand_leak);
  39. return 1;
  40. }