3 #include <openssl/core.h>
4 #include <openssl/core_numbers.h>
5 #include <openssl/core_names.h>
6 #include <openssl/params.h>
10 /* Functions provided by the core */
11 static OSSL_core_gettable_params_fn *c_gettable_params = NULL;
12 static OSSL_core_get_params_fn *c_get_params = NULL;
14 /* Parameters we provide to the core */
15 static const OSSL_ITEM gost_param_types[] = {
16 { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_NAME },
17 { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_VERSION },
18 { OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_BUILDINFO },
22 static const OSSL_ITEM *gost_gettable_params(const OSSL_PROVIDER *prov)
24 return gost_param_types;
27 static int gost_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
31 p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
32 if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, GOST_PROV_NAME))
34 p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION);
35 if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, GOST_PROV_VERSION_STR))
37 p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO);
38 if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, GOST_PROV_FULL_VERSION_STR))
44 static const OSSL_ALGORITHM gost_digests[] = {
45 { "md_gost2012_256:streebog256", "gost.gost=yes", streebog256_funcs },
46 { "md_gost2012_512:streebog512", "gost.gost=yes", NULL },
51 static const OSSL_ALGORITHM *gost_query(OSSL_PROVIDER *prov,
56 switch (operation_id) {
63 /* Functions we provide to the core */
64 static const OSSL_DISPATCH gost_dispatch_table[] = {
65 { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))gost_gettable_params },
66 { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))gost_get_params },
67 { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))gost_query },
71 int OSSL_provider_init(const OSSL_PROVIDER *provider,
72 const OSSL_DISPATCH *in,
73 const OSSL_DISPATCH **out,
76 OSSL_core_get_library_context_fn *c_get_libctx = NULL;
78 for (; in->function_id != 0; in++) {
79 switch (in->function_id) {
80 case OSSL_FUNC_CORE_GETTABLE_PARAMS:
81 c_gettable_params = OSSL_get_core_gettable_params(in);
83 case OSSL_FUNC_CORE_GET_PARAMS:
84 c_get_params = OSSL_get_core_get_params(in);
86 case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT:
87 c_get_libctx = OSSL_get_core_get_library_context(in);
89 /* Just ignore anything we don't understand */
95 if (c_get_libctx == NULL)
98 *out = gost_dispatch_table;
101 * We want to make sure that all calls from this provider that requires
102 * a library context use the same context as the one used to call our
103 * functions. We do that by passing it along as the provider context.
105 *provctx = c_get_libctx(provider);