VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/test/provider_fallback_test.c@ 105943

最後變更 在這個檔案從105943是 104078,由 vboxsync 提交於 8 月 前

openssl-3.1.5: Applied and adjusted our OpenSSL changes to 3.1.4. bugref:10638

檔案大小: 1.4 KB
 
1/*
2 * Copyright 2020-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 <stddef.h>
11#include <openssl/provider.h>
12#include <openssl/evp.h>
13#include "testutil.h"
14
15static int test_provider(OSSL_LIB_CTX *ctx)
16{
17 EVP_KEYMGMT *rsameth = NULL;
18 const OSSL_PROVIDER *prov = NULL;
19 int ok;
20
21 ok = TEST_true(OSSL_PROVIDER_available(ctx, "default"))
22 && TEST_ptr(rsameth = EVP_KEYMGMT_fetch(ctx, "RSA", NULL))
23 && TEST_ptr(prov = EVP_KEYMGMT_get0_provider(rsameth))
24 && TEST_str_eq(OSSL_PROVIDER_get0_name(prov), "default");
25
26 EVP_KEYMGMT_free(rsameth);
27 return ok;
28}
29
30static int test_fallback_provider(void)
31{
32 return test_provider(NULL);
33}
34
35static int test_explicit_provider(void)
36{
37 OSSL_LIB_CTX *ctx = NULL;
38 OSSL_PROVIDER *prov = NULL;
39 int ok;
40
41 ok = TEST_ptr(ctx = OSSL_LIB_CTX_new())
42 && TEST_ptr(prov = OSSL_PROVIDER_load(ctx, "default"))
43 && test_provider(ctx)
44 && TEST_true(OSSL_PROVIDER_unload(prov));
45
46 OSSL_LIB_CTX_free(ctx);
47 return ok;
48}
49
50
51int setup_tests(void)
52{
53 ADD_TEST(test_fallback_provider);
54 ADD_TEST(test_explicit_provider);
55 return 1;
56}
57
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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