]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/provider_fallback_test.c
2 * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
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
11 #include <openssl/provider.h>
12 #include <openssl/evp.h>
15 static int test_provider(OSSL_LIB_CTX
*ctx
)
17 EVP_KEYMGMT
*rsameth
= NULL
;
18 const OSSL_PROVIDER
*prov
= NULL
;
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");
26 EVP_KEYMGMT_free(rsameth
);
30 static int test_fallback_provider(void)
32 return test_provider(NULL
);
35 static int test_explicit_provider(void)
37 OSSL_LIB_CTX
*ctx
= NULL
;
38 OSSL_PROVIDER
*prov
= NULL
;
41 ok
= TEST_ptr(ctx
= OSSL_LIB_CTX_new())
42 && TEST_ptr(prov
= OSSL_PROVIDER_load(ctx
, "default"))
44 && TEST_true(OSSL_PROVIDER_unload(prov
));
46 OSSL_LIB_CTX_free(ctx
);
53 ADD_TEST(test_fallback_provider
);
54 ADD_TEST(test_explicit_provider
);