/* * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy * in the file LICENSE in the source distribution or at * https://www.openssl.org/source/license.html */#include<assert.h>#include<openssl/core.h>#include<openssl/core_dispatch.h>#include<openssl/core_names.h>#include<openssl/provider.h>#include<openssl/params.h>#include<openssl/opensslv.h>#include"crypto/cryptlib.h"#include"crypto/evp.h" /* evp_method_store_flush */#include"crypto/rand.h"#include"internal/nelem.h"#include"internal/thread_once.h"#include"internal/provider.h"#include"internal/refcount.h"#include"internal/bio.h"#include"provider_local.h"#ifndef FIPS_MODULE#include<openssl/self_test.h>#endifstaticOSSL_PROVIDER*provider_new(constchar*name,OSSL_provider_init_fn*init_function);/*- * Provider Object structure * ========================= */typedefstruct{char*name;char*value;}INFOPAIR;DEFINE_STACK_OF(INFOPAIR)structprovider_store_st;/* Forward declaration */structossl_provider_st{/* Flag bits */unsignedintflag_initialized:1;unsignedintflag_activated:1;unsignedintflag_fallback:1;/* Can be used as fallback *//* Getting and setting the flags require synchronization */CRYPTO_RWLOCK*flag_lock;/* OpenSSL library side data */CRYPTO_REF_COUNTrefcnt;CRYPTO_RWLOCK*refcnt_lock;/* For the ref counter */intactivatecnt;char*name;char*path;DSO*module;OSSL_provider_init_fn*init_function;STACK_OF(INFOPAIR)*parameters;OSSL_LIB_CTX*libctx;/* The library context this instance is in */structprovider_store_st*store;/* The store this instance belongs to */#ifndef FIPS_MODULE/* * In the FIPS module inner provider, this isn't needed, since the * error upcalls are always direct calls to the outer provider. */interror_lib;/* ERR library number, one for each provider */# ifndef OPENSSL_NO_ERRERR_STRING_DATA*error_strings;/* Copy of what the provider gives us */# endif#endif/* Provider side functions */OSSL_FUNC_provider_teardown_fn*teardown;OSSL_FUNC_provider_gettable_params_fn*gettable_params;OSSL_FUNC_provider_get_params_fn*get_params;OSSL_FUNC_provider_get_capabilities_fn*get_capabilities;OSSL_FUNC_provider_self_test_fn*self_test;OSSL_FUNC_provider_query_operation_fn*query_operation;OSSL_FUNC_provider_unquery_operation_fn*unquery_operation;/* * Cache of bit to indicate of query_operation() has been called on * a specific operation or not. */unsignedchar*operation_bits;size_toperation_bits_sz;CRYPTO_RWLOCK*opbits_lock;