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