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 |
|
---|
10 | #if defined(_WIN32)
|
---|
11 | # include <windows.h>
|
---|
12 | #endif
|
---|
13 |
|
---|
14 | #include "testutil.h"
|
---|
15 | #include "threadstest.h"
|
---|
16 |
|
---|
17 | static int success;
|
---|
18 |
|
---|
19 | static void thread_fips_rand_fetch(void)
|
---|
20 | {
|
---|
21 | EVP_MD *md;
|
---|
22 |
|
---|
23 | if (!TEST_true(md = EVP_MD_fetch(NULL, "SHA2-256", NULL)))
|
---|
24 | success = 0;
|
---|
25 | EVP_MD_free(md);
|
---|
26 | }
|
---|
27 |
|
---|
28 | static int test_fips_rand_leak(void)
|
---|
29 | {
|
---|
30 | thread_t thread;
|
---|
31 |
|
---|
32 | success = 1;
|
---|
33 |
|
---|
34 | if (!TEST_true(run_thread(&thread, thread_fips_rand_fetch)))
|
---|
35 | return 0;
|
---|
36 | if (!TEST_true(wait_for_thread(thread)))
|
---|
37 | return 0;
|
---|
38 | return TEST_true(success);
|
---|
39 | }
|
---|
40 |
|
---|
41 | int setup_tests(void)
|
---|
42 | {
|
---|
43 | /*
|
---|
44 | * This test MUST be run first. Once the default library context is set
|
---|
45 | * up, this test will always pass.
|
---|
46 | */
|
---|
47 | ADD_TEST(test_fips_rand_leak);
|
---|
48 | return 1;
|
---|
49 | }
|
---|