From 3c01ab789093fcc27a68029642b64eaf9d114e74 Mon Sep 17 00:00:00 2001 From: Guodong Xu Date: Mon, 4 Sep 2023 09:45:05 +0800 Subject: [PATCH 32/48] uadk_provider: load default provider into Global library context Implementations in default provider are required in some cases. For example when the package size is small. In current design, we load default provider into Global library context, aka. NULL. Signed-off-by: Guodong Xu --- src/uadk_prov_init.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/uadk_prov_init.c b/src/uadk_prov_init.c index b59a4e8..57910ac 100644 --- a/src/uadk_prov_init.c +++ b/src/uadk_prov_init.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include "uadk_async.h" #include "uadk_prov.h" @@ -32,7 +34,8 @@ struct p_uadk_ctx { }; const char *engine_uadk_id = "uadk_provider"; -static const char UADK_DEFAULT_PROPERTIES[] = "provider=uadk"; +static const char UADK_DEFAULT_PROPERTIES[] = "provider=uadk_provider"; +static OSSL_PROVIDER *prov; const OSSL_ALGORITHM uadk_prov_digests[] = { { OSSL_DIGEST_NAME_MD5, UADK_DEFAULT_PROPERTIES, @@ -83,8 +86,18 @@ const OSSL_ALGORITHM uadk_prov_ciphers[] = { static const OSSL_ALGORITHM *p_prov_query(void *provctx, int operation_id, int *no_cache) { - *no_cache = 0; + static int prov_init; + + prov = OSSL_PROVIDER_load(NULL, "default"); + if (!prov_init) { + prov_init = 1; + /* uadk_provider takes the highest priority + * and overwrite the openssl.cnf property. + */ + EVP_set_default_properties(NULL, "?provider=uadk_provider"); + } + *no_cache = 0; switch (operation_id) { case OSSL_OP_DIGEST: return uadk_prov_digests; @@ -101,6 +114,7 @@ static void p_teardown(void *provctx) uadk_prov_destroy_digest(); uadk_prov_destroy_cipher(); OPENSSL_free(ctx); + OSSL_PROVIDER_unload(prov); } static const OSSL_DISPATCH p_test_table[] = { -- 2.25.1