VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.7/test/prov_config_test.c@ 97673

最後變更 在這個檔案從97673是 94320,由 vboxsync 提交於 3 年 前

libs/openssl-3.0.1: Export to OSE and fix copyright headers in Makefiles, bugref:10128

檔案大小: 1.4 KB
 
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#include <openssl/evp.h>
11#include "testutil.h"
12
13static char *configfile = NULL;
14
15/*
16 * Test to make sure there are no leaks or failures from loading the config
17 * file twice.
18 */
19static int test_double_config(void)
20{
21 OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new();
22 int testresult = 0;
23 EVP_MD *sha256 = NULL;
24
25 if (!TEST_ptr(configfile))
26 return 0;
27 if (!TEST_ptr(ctx))
28 return 0;
29
30 if (!TEST_true(OSSL_LIB_CTX_load_config(ctx, configfile)))
31 return 0;
32 if (!TEST_true(OSSL_LIB_CTX_load_config(ctx, configfile)))
33 return 0;
34
35 /* Check we can actually fetch something */
36 sha256 = EVP_MD_fetch(ctx, "SHA2-256", NULL);
37 if (!TEST_ptr(sha256))
38 goto err;
39
40 testresult = 1;
41 err:
42 EVP_MD_free(sha256);
43 OSSL_LIB_CTX_free(ctx);
44 return testresult;
45}
46
47OPT_TEST_DECLARE_USAGE("configfile\n")
48
49int setup_tests(void)
50{
51 if (!test_skip_common_options()) {
52 TEST_error("Error parsing test options\n");
53 return 0;
54 }
55
56 if (!TEST_ptr(configfile = test_get_argument(0)))
57 return 0;
58
59 ADD_TEST(test_double_config);
60 return 1;
61}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette