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