xref: /freebsd/crypto/openssl/providers/defltprov.c (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery /*
2*b077aed3SPierre Pronchery  * Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
3*b077aed3SPierre Pronchery  *
4*b077aed3SPierre Pronchery  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*b077aed3SPierre Pronchery  * this file except in compliance with the License.  You can obtain a copy
6*b077aed3SPierre Pronchery  * in the file LICENSE in the source distribution or at
7*b077aed3SPierre Pronchery  * https://www.openssl.org/source/license.html
8*b077aed3SPierre Pronchery  */
9*b077aed3SPierre Pronchery 
10*b077aed3SPierre Pronchery #include <string.h>
11*b077aed3SPierre Pronchery #include <stdio.h>
12*b077aed3SPierre Pronchery #include <openssl/opensslconf.h>
13*b077aed3SPierre Pronchery #include <openssl/core.h>
14*b077aed3SPierre Pronchery #include <openssl/core_dispatch.h>
15*b077aed3SPierre Pronchery #include <openssl/core_names.h>
16*b077aed3SPierre Pronchery #include <openssl/params.h>
17*b077aed3SPierre Pronchery #include "prov/bio.h"
18*b077aed3SPierre Pronchery #include "prov/provider_ctx.h"
19*b077aed3SPierre Pronchery #include "prov/providercommon.h"
20*b077aed3SPierre Pronchery #include "prov/implementations.h"
21*b077aed3SPierre Pronchery #include "prov/names.h"
22*b077aed3SPierre Pronchery #include "prov/provider_util.h"
23*b077aed3SPierre Pronchery #include "prov/seeding.h"
24*b077aed3SPierre Pronchery #include "internal/nelem.h"
25*b077aed3SPierre Pronchery 
26*b077aed3SPierre Pronchery /*
27*b077aed3SPierre Pronchery  * Forward declarations to ensure that interface functions are correctly
28*b077aed3SPierre Pronchery  * defined.
29*b077aed3SPierre Pronchery  */
30*b077aed3SPierre Pronchery static OSSL_FUNC_provider_gettable_params_fn deflt_gettable_params;
31*b077aed3SPierre Pronchery static OSSL_FUNC_provider_get_params_fn deflt_get_params;
32*b077aed3SPierre Pronchery static OSSL_FUNC_provider_query_operation_fn deflt_query;
33*b077aed3SPierre Pronchery 
34*b077aed3SPierre Pronchery #define ALGC(NAMES, FUNC, CHECK) { { NAMES, "provider=default", FUNC }, CHECK }
35*b077aed3SPierre Pronchery #define ALG(NAMES, FUNC) ALGC(NAMES, FUNC, NULL)
36*b077aed3SPierre Pronchery 
37*b077aed3SPierre Pronchery /* Functions provided by the core */
38*b077aed3SPierre Pronchery static OSSL_FUNC_core_gettable_params_fn *c_gettable_params = NULL;
39*b077aed3SPierre Pronchery static OSSL_FUNC_core_get_params_fn *c_get_params = NULL;
40*b077aed3SPierre Pronchery 
41*b077aed3SPierre Pronchery /* Parameters we provide to the core */
42*b077aed3SPierre Pronchery static const OSSL_PARAM deflt_param_types[] = {
43*b077aed3SPierre Pronchery     OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0),
44*b077aed3SPierre Pronchery     OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0),
45*b077aed3SPierre Pronchery     OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0),
46*b077aed3SPierre Pronchery     OSSL_PARAM_DEFN(OSSL_PROV_PARAM_STATUS, OSSL_PARAM_INTEGER, NULL, 0),
47*b077aed3SPierre Pronchery     OSSL_PARAM_END
48*b077aed3SPierre Pronchery };
49*b077aed3SPierre Pronchery 
deflt_gettable_params(void * provctx)50*b077aed3SPierre Pronchery static const OSSL_PARAM *deflt_gettable_params(void *provctx)
51*b077aed3SPierre Pronchery {
52*b077aed3SPierre Pronchery     return deflt_param_types;
53*b077aed3SPierre Pronchery }
54*b077aed3SPierre Pronchery 
deflt_get_params(void * provctx,OSSL_PARAM params[])55*b077aed3SPierre Pronchery static int deflt_get_params(void *provctx, OSSL_PARAM params[])
56*b077aed3SPierre Pronchery {
57*b077aed3SPierre Pronchery     OSSL_PARAM *p;
58*b077aed3SPierre Pronchery 
59*b077aed3SPierre Pronchery     p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME);
60*b077aed3SPierre Pronchery     if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Default Provider"))
61*b077aed3SPierre Pronchery         return 0;
62*b077aed3SPierre Pronchery     p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION);
63*b077aed3SPierre Pronchery     if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR))
64*b077aed3SPierre Pronchery         return 0;
65*b077aed3SPierre Pronchery     p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO);
66*b077aed3SPierre Pronchery     if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_FULL_VERSION_STR))
67*b077aed3SPierre Pronchery         return 0;
68*b077aed3SPierre Pronchery     p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_STATUS);
69*b077aed3SPierre Pronchery     if (p != NULL && !OSSL_PARAM_set_int(p, ossl_prov_is_running()))
70*b077aed3SPierre Pronchery         return 0;
71*b077aed3SPierre Pronchery     return 1;
72*b077aed3SPierre Pronchery }
73*b077aed3SPierre Pronchery 
74*b077aed3SPierre Pronchery /*
75*b077aed3SPierre Pronchery  * For the algorithm names, we use the following formula for our primary
76*b077aed3SPierre Pronchery  * names:
77*b077aed3SPierre Pronchery  *
78*b077aed3SPierre Pronchery  *     ALGNAME[VERSION?][-SUBNAME[VERSION?]?][-SIZE?][-MODE?]
79*b077aed3SPierre Pronchery  *
80*b077aed3SPierre Pronchery  *     VERSION is only present if there are multiple versions of
81*b077aed3SPierre Pronchery  *     an alg (MD2, MD4, MD5).  It may be omitted if there is only
82*b077aed3SPierre Pronchery  *     one version (if a subsequent version is released in the future,
83*b077aed3SPierre Pronchery  *     we can always change the canonical name, and add the old name
84*b077aed3SPierre Pronchery  *     as an alias).
85*b077aed3SPierre Pronchery  *
86*b077aed3SPierre Pronchery  *     SUBNAME may be present where we are combining multiple
87*b077aed3SPierre Pronchery  *     algorithms together, e.g. MD5-SHA1.
88*b077aed3SPierre Pronchery  *
89*b077aed3SPierre Pronchery  *     SIZE is only present if multiple versions of an algorithm exist
90*b077aed3SPierre Pronchery  *     with different sizes (e.g. AES-128-CBC, AES-256-CBC)
91*b077aed3SPierre Pronchery  *
92*b077aed3SPierre Pronchery  *     MODE is only present where applicable.
93*b077aed3SPierre Pronchery  *
94*b077aed3SPierre Pronchery  * We add diverse other names where applicable, such as the names that
95*b077aed3SPierre Pronchery  * NIST uses, or that are used for ASN.1 OBJECT IDENTIFIERs, or names
96*b077aed3SPierre Pronchery  * we have used historically.
97*b077aed3SPierre Pronchery  *
98*b077aed3SPierre Pronchery  * Algorithm names are case insensitive, but we use all caps in our "canonical"
99*b077aed3SPierre Pronchery  * names for consistency.
100*b077aed3SPierre Pronchery  */
101*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_digests[] = {
102*b077aed3SPierre Pronchery     /* Our primary name:NIST name[:our older names] */
103*b077aed3SPierre Pronchery     { PROV_NAMES_SHA1, "provider=default", ossl_sha1_functions },
104*b077aed3SPierre Pronchery     { PROV_NAMES_SHA2_224, "provider=default", ossl_sha224_functions },
105*b077aed3SPierre Pronchery     { PROV_NAMES_SHA2_256, "provider=default", ossl_sha256_functions },
106*b077aed3SPierre Pronchery     { PROV_NAMES_SHA2_384, "provider=default", ossl_sha384_functions },
107*b077aed3SPierre Pronchery     { PROV_NAMES_SHA2_512, "provider=default", ossl_sha512_functions },
108*b077aed3SPierre Pronchery     { PROV_NAMES_SHA2_512_224, "provider=default", ossl_sha512_224_functions },
109*b077aed3SPierre Pronchery     { PROV_NAMES_SHA2_512_256, "provider=default", ossl_sha512_256_functions },
110*b077aed3SPierre Pronchery 
111*b077aed3SPierre Pronchery     /* We agree with NIST here, so one name only */
112*b077aed3SPierre Pronchery     { PROV_NAMES_SHA3_224, "provider=default", ossl_sha3_224_functions },
113*b077aed3SPierre Pronchery     { PROV_NAMES_SHA3_256, "provider=default", ossl_sha3_256_functions },
114*b077aed3SPierre Pronchery     { PROV_NAMES_SHA3_384, "provider=default", ossl_sha3_384_functions },
115*b077aed3SPierre Pronchery     { PROV_NAMES_SHA3_512, "provider=default", ossl_sha3_512_functions },
116*b077aed3SPierre Pronchery 
117*b077aed3SPierre Pronchery     /*
118*b077aed3SPierre Pronchery      * KECCAK-KMAC-128 and KECCAK-KMAC-256 as hashes are mostly useful for
119*b077aed3SPierre Pronchery      * the KMAC-128 and KMAC-256.
120*b077aed3SPierre Pronchery      */
121*b077aed3SPierre Pronchery     { PROV_NAMES_KECCAK_KMAC_128, "provider=default",
122*b077aed3SPierre Pronchery       ossl_keccak_kmac_128_functions },
123*b077aed3SPierre Pronchery     { PROV_NAMES_KECCAK_KMAC_256, "provider=default",
124*b077aed3SPierre Pronchery       ossl_keccak_kmac_256_functions },
125*b077aed3SPierre Pronchery 
126*b077aed3SPierre Pronchery     /* Our primary name:NIST name */
127*b077aed3SPierre Pronchery     { PROV_NAMES_SHAKE_128, "provider=default", ossl_shake_128_functions },
128*b077aed3SPierre Pronchery     { PROV_NAMES_SHAKE_256, "provider=default", ossl_shake_256_functions },
129*b077aed3SPierre Pronchery 
130*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_BLAKE2
131*b077aed3SPierre Pronchery     /*
132*b077aed3SPierre Pronchery      * https://blake2.net/ doesn't specify size variants,
133*b077aed3SPierre Pronchery      * but mentions that Bouncy Castle uses the names
134*b077aed3SPierre Pronchery      * BLAKE2b-160, BLAKE2b-256, BLAKE2b-384, and BLAKE2b-512
135*b077aed3SPierre Pronchery      * If we assume that "2b" and "2s" are versions, that pattern
136*b077aed3SPierre Pronchery      * fits with ours.  We also add our historical names.
137*b077aed3SPierre Pronchery      */
138*b077aed3SPierre Pronchery     { PROV_NAMES_BLAKE2S_256, "provider=default", ossl_blake2s256_functions },
139*b077aed3SPierre Pronchery     { PROV_NAMES_BLAKE2B_512, "provider=default", ossl_blake2b512_functions },
140*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_BLAKE2 */
141*b077aed3SPierre Pronchery 
142*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SM3
143*b077aed3SPierre Pronchery     { PROV_NAMES_SM3, "provider=default", ossl_sm3_functions },
144*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_SM3 */
145*b077aed3SPierre Pronchery 
146*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_MD5
147*b077aed3SPierre Pronchery     { PROV_NAMES_MD5, "provider=default", ossl_md5_functions },
148*b077aed3SPierre Pronchery     { PROV_NAMES_MD5_SHA1, "provider=default", ossl_md5_sha1_functions },
149*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_MD5 */
150*b077aed3SPierre Pronchery 
151*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_RMD160
152*b077aed3SPierre Pronchery     { PROV_NAMES_RIPEMD_160, "provider=default", ossl_ripemd160_functions },
153*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_RMD160 */
154*b077aed3SPierre Pronchery 
155*b077aed3SPierre Pronchery     { PROV_NAMES_NULL, "provider=default", ossl_nullmd_functions },
156*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
157*b077aed3SPierre Pronchery };
158*b077aed3SPierre Pronchery 
159*b077aed3SPierre Pronchery static const OSSL_ALGORITHM_CAPABLE deflt_ciphers[] = {
160*b077aed3SPierre Pronchery     ALG(PROV_NAMES_NULL, ossl_null_functions),
161*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_ECB, ossl_aes256ecb_functions),
162*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_ECB, ossl_aes192ecb_functions),
163*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_ECB, ossl_aes128ecb_functions),
164*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CBC, ossl_aes256cbc_functions),
165*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CBC, ossl_aes192cbc_functions),
166*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CBC, ossl_aes128cbc_functions),
167*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CBC_CTS, ossl_aes128cbc_cts_functions),
168*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CBC_CTS, ossl_aes192cbc_cts_functions),
169*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CBC_CTS, ossl_aes256cbc_cts_functions),
170*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_OFB, ossl_aes256ofb_functions),
171*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_OFB, ossl_aes192ofb_functions),
172*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_OFB, ossl_aes128ofb_functions),
173*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CFB, ossl_aes256cfb_functions),
174*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CFB, ossl_aes192cfb_functions),
175*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CFB, ossl_aes128cfb_functions),
176*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CFB1, ossl_aes256cfb1_functions),
177*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CFB1, ossl_aes192cfb1_functions),
178*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CFB1, ossl_aes128cfb1_functions),
179*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CFB8, ossl_aes256cfb8_functions),
180*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CFB8, ossl_aes192cfb8_functions),
181*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CFB8, ossl_aes128cfb8_functions),
182*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CTR, ossl_aes256ctr_functions),
183*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CTR, ossl_aes192ctr_functions),
184*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CTR, ossl_aes128ctr_functions),
185*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_XTS, ossl_aes256xts_functions),
186*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_XTS, ossl_aes128xts_functions),
187*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_OCB
188*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_OCB, ossl_aes256ocb_functions),
189*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_OCB, ossl_aes192ocb_functions),
190*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_OCB, ossl_aes128ocb_functions),
191*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_OCB */
192*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SIV
193*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_SIV, ossl_aes128siv_functions),
194*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_SIV, ossl_aes192siv_functions),
195*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_SIV, ossl_aes256siv_functions),
196*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_SIV */
197*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_GCM, ossl_aes256gcm_functions),
198*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_GCM, ossl_aes192gcm_functions),
199*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_GCM, ossl_aes128gcm_functions),
200*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_CCM, ossl_aes256ccm_functions),
201*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_CCM, ossl_aes192ccm_functions),
202*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_CCM, ossl_aes128ccm_functions),
203*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_WRAP, ossl_aes256wrap_functions),
204*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_WRAP, ossl_aes192wrap_functions),
205*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_WRAP, ossl_aes128wrap_functions),
206*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_WRAP_PAD, ossl_aes256wrappad_functions),
207*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_WRAP_PAD, ossl_aes192wrappad_functions),
208*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_WRAP_PAD, ossl_aes128wrappad_functions),
209*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_WRAP_INV, ossl_aes256wrapinv_functions),
210*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_WRAP_INV, ossl_aes192wrapinv_functions),
211*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_WRAP_INV, ossl_aes128wrapinv_functions),
212*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_256_WRAP_PAD_INV, ossl_aes256wrappadinv_functions),
213*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_192_WRAP_PAD_INV, ossl_aes192wrappadinv_functions),
214*b077aed3SPierre Pronchery     ALG(PROV_NAMES_AES_128_WRAP_PAD_INV, ossl_aes128wrappadinv_functions),
215*b077aed3SPierre Pronchery     ALGC(PROV_NAMES_AES_128_CBC_HMAC_SHA1, ossl_aes128cbc_hmac_sha1_functions,
216*b077aed3SPierre Pronchery          ossl_cipher_capable_aes_cbc_hmac_sha1),
217*b077aed3SPierre Pronchery     ALGC(PROV_NAMES_AES_256_CBC_HMAC_SHA1, ossl_aes256cbc_hmac_sha1_functions,
218*b077aed3SPierre Pronchery          ossl_cipher_capable_aes_cbc_hmac_sha1),
219*b077aed3SPierre Pronchery     ALGC(PROV_NAMES_AES_128_CBC_HMAC_SHA256, ossl_aes128cbc_hmac_sha256_functions,
220*b077aed3SPierre Pronchery         ossl_cipher_capable_aes_cbc_hmac_sha256),
221*b077aed3SPierre Pronchery     ALGC(PROV_NAMES_AES_256_CBC_HMAC_SHA256, ossl_aes256cbc_hmac_sha256_functions,
222*b077aed3SPierre Pronchery          ossl_cipher_capable_aes_cbc_hmac_sha256),
223*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_ARIA
224*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_GCM, ossl_aria256gcm_functions),
225*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_GCM, ossl_aria192gcm_functions),
226*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_GCM, ossl_aria128gcm_functions),
227*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_CCM, ossl_aria256ccm_functions),
228*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_CCM, ossl_aria192ccm_functions),
229*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_CCM, ossl_aria128ccm_functions),
230*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_ECB, ossl_aria256ecb_functions),
231*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_ECB, ossl_aria192ecb_functions),
232*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_ECB, ossl_aria128ecb_functions),
233*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_CBC, ossl_aria256cbc_functions),
234*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_CBC, ossl_aria192cbc_functions),
235*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_CBC, ossl_aria128cbc_functions),
236*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_OFB, ossl_aria256ofb_functions),
237*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_OFB, ossl_aria192ofb_functions),
238*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_OFB, ossl_aria128ofb_functions),
239*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_CFB, ossl_aria256cfb_functions),
240*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_CFB, ossl_aria192cfb_functions),
241*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_CFB, ossl_aria128cfb_functions),
242*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_CFB1, ossl_aria256cfb1_functions),
243*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_CFB1, ossl_aria192cfb1_functions),
244*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_CFB1, ossl_aria128cfb1_functions),
245*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_CFB8, ossl_aria256cfb8_functions),
246*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_CFB8, ossl_aria192cfb8_functions),
247*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_CFB8, ossl_aria128cfb8_functions),
248*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_256_CTR, ossl_aria256ctr_functions),
249*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_192_CTR, ossl_aria192ctr_functions),
250*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ARIA_128_CTR, ossl_aria128ctr_functions),
251*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_ARIA */
252*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_CAMELLIA
253*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_ECB, ossl_camellia256ecb_functions),
254*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_ECB, ossl_camellia192ecb_functions),
255*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_ECB, ossl_camellia128ecb_functions),
256*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_CBC, ossl_camellia256cbc_functions),
257*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_CBC, ossl_camellia192cbc_functions),
258*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_CBC, ossl_camellia128cbc_functions),
259*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_CBC_CTS, ossl_camellia128cbc_cts_functions),
260*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_CBC_CTS, ossl_camellia192cbc_cts_functions),
261*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_CBC_CTS, ossl_camellia256cbc_cts_functions),
262*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_OFB, ossl_camellia256ofb_functions),
263*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_OFB, ossl_camellia192ofb_functions),
264*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_OFB, ossl_camellia128ofb_functions),
265*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_CFB, ossl_camellia256cfb_functions),
266*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_CFB, ossl_camellia192cfb_functions),
267*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_CFB, ossl_camellia128cfb_functions),
268*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_CFB1, ossl_camellia256cfb1_functions),
269*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_CFB1, ossl_camellia192cfb1_functions),
270*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_CFB1, ossl_camellia128cfb1_functions),
271*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_CFB8, ossl_camellia256cfb8_functions),
272*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_CFB8, ossl_camellia192cfb8_functions),
273*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_CFB8, ossl_camellia128cfb8_functions),
274*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_256_CTR, ossl_camellia256ctr_functions),
275*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_192_CTR, ossl_camellia192ctr_functions),
276*b077aed3SPierre Pronchery     ALG(PROV_NAMES_CAMELLIA_128_CTR, ossl_camellia128ctr_functions),
277*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_CAMELLIA */
278*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_DES
279*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE3_ECB, ossl_tdes_ede3_ecb_functions),
280*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE3_CBC, ossl_tdes_ede3_cbc_functions),
281*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE3_OFB, ossl_tdes_ede3_ofb_functions),
282*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE3_CFB, ossl_tdes_ede3_cfb_functions),
283*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE3_CFB8, ossl_tdes_ede3_cfb8_functions),
284*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE3_CFB1, ossl_tdes_ede3_cfb1_functions),
285*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES3_WRAP, ossl_tdes_wrap_cbc_functions),
286*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE_ECB, ossl_tdes_ede2_ecb_functions),
287*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE_CBC, ossl_tdes_ede2_cbc_functions),
288*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE_OFB, ossl_tdes_ede2_ofb_functions),
289*b077aed3SPierre Pronchery     ALG(PROV_NAMES_DES_EDE_CFB, ossl_tdes_ede2_cfb_functions),
290*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_DES */
291*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SM4
292*b077aed3SPierre Pronchery     ALG(PROV_NAMES_SM4_ECB, ossl_sm4128ecb_functions),
293*b077aed3SPierre Pronchery     ALG(PROV_NAMES_SM4_CBC, ossl_sm4128cbc_functions),
294*b077aed3SPierre Pronchery     ALG(PROV_NAMES_SM4_CTR, ossl_sm4128ctr_functions),
295*b077aed3SPierre Pronchery     ALG(PROV_NAMES_SM4_OFB, ossl_sm4128ofb128_functions),
296*b077aed3SPierre Pronchery     ALG(PROV_NAMES_SM4_CFB, ossl_sm4128cfb128_functions),
297*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_SM4 */
298*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_CHACHA
299*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ChaCha20, ossl_chacha20_functions),
300*b077aed3SPierre Pronchery # ifndef OPENSSL_NO_POLY1305
301*b077aed3SPierre Pronchery     ALG(PROV_NAMES_ChaCha20_Poly1305, ossl_chacha20_ossl_poly1305_functions),
302*b077aed3SPierre Pronchery # endif /* OPENSSL_NO_POLY1305 */
303*b077aed3SPierre Pronchery #endif /* OPENSSL_NO_CHACHA */
304*b077aed3SPierre Pronchery     { { NULL, NULL, NULL }, NULL }
305*b077aed3SPierre Pronchery };
306*b077aed3SPierre Pronchery static OSSL_ALGORITHM exported_ciphers[OSSL_NELEM(deflt_ciphers)];
307*b077aed3SPierre Pronchery 
308*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_macs[] = {
309*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_BLAKE2
310*b077aed3SPierre Pronchery     { PROV_NAMES_BLAKE2BMAC, "provider=default", ossl_blake2bmac_functions },
311*b077aed3SPierre Pronchery     { PROV_NAMES_BLAKE2SMAC, "provider=default", ossl_blake2smac_functions },
312*b077aed3SPierre Pronchery #endif
313*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_CMAC
314*b077aed3SPierre Pronchery     { PROV_NAMES_CMAC, "provider=default", ossl_cmac_functions },
315*b077aed3SPierre Pronchery #endif
316*b077aed3SPierre Pronchery     { PROV_NAMES_GMAC, "provider=default", ossl_gmac_functions },
317*b077aed3SPierre Pronchery     { PROV_NAMES_HMAC, "provider=default", ossl_hmac_functions },
318*b077aed3SPierre Pronchery     { PROV_NAMES_KMAC_128, "provider=default", ossl_kmac128_functions },
319*b077aed3SPierre Pronchery     { PROV_NAMES_KMAC_256, "provider=default", ossl_kmac256_functions },
320*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SIPHASH
321*b077aed3SPierre Pronchery     { PROV_NAMES_SIPHASH, "provider=default", ossl_siphash_functions },
322*b077aed3SPierre Pronchery #endif
323*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_POLY1305
324*b077aed3SPierre Pronchery     { PROV_NAMES_POLY1305, "provider=default", ossl_poly1305_functions },
325*b077aed3SPierre Pronchery #endif
326*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
327*b077aed3SPierre Pronchery };
328*b077aed3SPierre Pronchery 
329*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_kdfs[] = {
330*b077aed3SPierre Pronchery     { PROV_NAMES_HKDF, "provider=default", ossl_kdf_hkdf_functions },
331*b077aed3SPierre Pronchery     { PROV_NAMES_TLS1_3_KDF, "provider=default",
332*b077aed3SPierre Pronchery       ossl_kdf_tls1_3_kdf_functions },
333*b077aed3SPierre Pronchery     { PROV_NAMES_SSKDF, "provider=default", ossl_kdf_sskdf_functions },
334*b077aed3SPierre Pronchery     { PROV_NAMES_PBKDF2, "provider=default", ossl_kdf_pbkdf2_functions },
335*b077aed3SPierre Pronchery     { PROV_NAMES_PKCS12KDF, "provider=default", ossl_kdf_pkcs12_functions },
336*b077aed3SPierre Pronchery     { PROV_NAMES_SSHKDF, "provider=default", ossl_kdf_sshkdf_functions },
337*b077aed3SPierre Pronchery     { PROV_NAMES_X963KDF, "provider=default", ossl_kdf_x963_kdf_functions },
338*b077aed3SPierre Pronchery     { PROV_NAMES_TLS1_PRF, "provider=default", ossl_kdf_tls1_prf_functions },
339*b077aed3SPierre Pronchery     { PROV_NAMES_KBKDF, "provider=default", ossl_kdf_kbkdf_functions },
340*b077aed3SPierre Pronchery     { PROV_NAMES_X942KDF_ASN1, "provider=default", ossl_kdf_x942_kdf_functions },
341*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SCRYPT
342*b077aed3SPierre Pronchery     { PROV_NAMES_SCRYPT, "provider=default", ossl_kdf_scrypt_functions },
343*b077aed3SPierre Pronchery #endif
344*b077aed3SPierre Pronchery     { PROV_NAMES_KRB5KDF, "provider=default", ossl_kdf_krb5kdf_functions },
345*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
346*b077aed3SPierre Pronchery };
347*b077aed3SPierre Pronchery 
348*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_keyexch[] = {
349*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_DH
350*b077aed3SPierre Pronchery     { PROV_NAMES_DH, "provider=default", ossl_dh_keyexch_functions },
351*b077aed3SPierre Pronchery #endif
352*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_EC
353*b077aed3SPierre Pronchery     { PROV_NAMES_ECDH, "provider=default", ossl_ecdh_keyexch_functions },
354*b077aed3SPierre Pronchery     { PROV_NAMES_X25519, "provider=default", ossl_x25519_keyexch_functions },
355*b077aed3SPierre Pronchery     { PROV_NAMES_X448, "provider=default", ossl_x448_keyexch_functions },
356*b077aed3SPierre Pronchery #endif
357*b077aed3SPierre Pronchery     { PROV_NAMES_TLS1_PRF, "provider=default", ossl_kdf_tls1_prf_keyexch_functions },
358*b077aed3SPierre Pronchery     { PROV_NAMES_HKDF, "provider=default", ossl_kdf_hkdf_keyexch_functions },
359*b077aed3SPierre Pronchery     { PROV_NAMES_SCRYPT, "provider=default",
360*b077aed3SPierre Pronchery       ossl_kdf_scrypt_keyexch_functions },
361*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
362*b077aed3SPierre Pronchery };
363*b077aed3SPierre Pronchery 
364*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_rands[] = {
365*b077aed3SPierre Pronchery     { PROV_NAMES_CTR_DRBG, "provider=default", ossl_drbg_ctr_functions },
366*b077aed3SPierre Pronchery     { PROV_NAMES_HASH_DRBG, "provider=default", ossl_drbg_hash_functions },
367*b077aed3SPierre Pronchery     { PROV_NAMES_HMAC_DRBG, "provider=default", ossl_drbg_ossl_hmac_functions },
368*b077aed3SPierre Pronchery     { PROV_NAMES_SEED_SRC, "provider=default", ossl_seed_src_functions },
369*b077aed3SPierre Pronchery     { PROV_NAMES_TEST_RAND, "provider=default", ossl_test_rng_functions },
370*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
371*b077aed3SPierre Pronchery };
372*b077aed3SPierre Pronchery 
373*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_signature[] = {
374*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_DSA
375*b077aed3SPierre Pronchery     { PROV_NAMES_DSA, "provider=default", ossl_dsa_signature_functions },
376*b077aed3SPierre Pronchery #endif
377*b077aed3SPierre Pronchery     { PROV_NAMES_RSA, "provider=default", ossl_rsa_signature_functions },
378*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_EC
379*b077aed3SPierre Pronchery     { PROV_NAMES_ED25519, "provider=default", ossl_ed25519_signature_functions },
380*b077aed3SPierre Pronchery     { PROV_NAMES_ED448, "provider=default", ossl_ed448_signature_functions },
381*b077aed3SPierre Pronchery     { PROV_NAMES_ECDSA, "provider=default", ossl_ecdsa_signature_functions },
382*b077aed3SPierre Pronchery # ifndef OPENSSL_NO_SM2
383*b077aed3SPierre Pronchery     { PROV_NAMES_SM2, "provider=default", ossl_sm2_signature_functions },
384*b077aed3SPierre Pronchery # endif
385*b077aed3SPierre Pronchery #endif
386*b077aed3SPierre Pronchery     { PROV_NAMES_HMAC, "provider=default", ossl_mac_legacy_hmac_signature_functions },
387*b077aed3SPierre Pronchery     { PROV_NAMES_SIPHASH, "provider=default",
388*b077aed3SPierre Pronchery       ossl_mac_legacy_siphash_signature_functions },
389*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_POLY1305
390*b077aed3SPierre Pronchery     { PROV_NAMES_POLY1305, "provider=default",
391*b077aed3SPierre Pronchery       ossl_mac_legacy_poly1305_signature_functions },
392*b077aed3SPierre Pronchery #endif
393*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_CMAC
394*b077aed3SPierre Pronchery     { PROV_NAMES_CMAC, "provider=default", ossl_mac_legacy_cmac_signature_functions },
395*b077aed3SPierre Pronchery #endif
396*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
397*b077aed3SPierre Pronchery };
398*b077aed3SPierre Pronchery 
399*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_asym_cipher[] = {
400*b077aed3SPierre Pronchery     { PROV_NAMES_RSA, "provider=default", ossl_rsa_asym_cipher_functions },
401*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SM2
402*b077aed3SPierre Pronchery     { PROV_NAMES_SM2, "provider=default", ossl_sm2_asym_cipher_functions },
403*b077aed3SPierre Pronchery #endif
404*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
405*b077aed3SPierre Pronchery };
406*b077aed3SPierre Pronchery 
407*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_asym_kem[] = {
408*b077aed3SPierre Pronchery     { PROV_NAMES_RSA, "provider=default", ossl_rsa_asym_kem_functions },
409*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
410*b077aed3SPierre Pronchery };
411*b077aed3SPierre Pronchery 
412*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_keymgmt[] = {
413*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_DH
414*b077aed3SPierre Pronchery     { PROV_NAMES_DH, "provider=default", ossl_dh_keymgmt_functions,
415*b077aed3SPierre Pronchery       PROV_DESCS_DH },
416*b077aed3SPierre Pronchery     { PROV_NAMES_DHX, "provider=default", ossl_dhx_keymgmt_functions,
417*b077aed3SPierre Pronchery       PROV_DESCS_DHX },
418*b077aed3SPierre Pronchery #endif
419*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_DSA
420*b077aed3SPierre Pronchery     { PROV_NAMES_DSA, "provider=default", ossl_dsa_keymgmt_functions,
421*b077aed3SPierre Pronchery       PROV_DESCS_DSA},
422*b077aed3SPierre Pronchery #endif
423*b077aed3SPierre Pronchery     { PROV_NAMES_RSA, "provider=default", ossl_rsa_keymgmt_functions,
424*b077aed3SPierre Pronchery       PROV_DESCS_RSA },
425*b077aed3SPierre Pronchery     { PROV_NAMES_RSA_PSS, "provider=default", ossl_rsapss_keymgmt_functions,
426*b077aed3SPierre Pronchery       PROV_DESCS_RSA_PSS },
427*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_EC
428*b077aed3SPierre Pronchery     { PROV_NAMES_EC, "provider=default", ossl_ec_keymgmt_functions,
429*b077aed3SPierre Pronchery       PROV_DESCS_EC },
430*b077aed3SPierre Pronchery     { PROV_NAMES_X25519, "provider=default", ossl_x25519_keymgmt_functions,
431*b077aed3SPierre Pronchery       PROV_DESCS_X25519 },
432*b077aed3SPierre Pronchery     { PROV_NAMES_X448, "provider=default", ossl_x448_keymgmt_functions,
433*b077aed3SPierre Pronchery       PROV_DESCS_X448 },
434*b077aed3SPierre Pronchery     { PROV_NAMES_ED25519, "provider=default", ossl_ed25519_keymgmt_functions,
435*b077aed3SPierre Pronchery       PROV_DESCS_ED25519 },
436*b077aed3SPierre Pronchery     { PROV_NAMES_ED448, "provider=default", ossl_ed448_keymgmt_functions,
437*b077aed3SPierre Pronchery       PROV_DESCS_ED448 },
438*b077aed3SPierre Pronchery #endif
439*b077aed3SPierre Pronchery     { PROV_NAMES_TLS1_PRF, "provider=default", ossl_kdf_keymgmt_functions,
440*b077aed3SPierre Pronchery       PROV_DESCS_TLS1_PRF_SIGN },
441*b077aed3SPierre Pronchery     { PROV_NAMES_HKDF, "provider=default", ossl_kdf_keymgmt_functions,
442*b077aed3SPierre Pronchery       PROV_DESCS_HKDF_SIGN },
443*b077aed3SPierre Pronchery     { PROV_NAMES_SCRYPT, "provider=default", ossl_kdf_keymgmt_functions,
444*b077aed3SPierre Pronchery       PROV_DESCS_SCRYPT_SIGN },
445*b077aed3SPierre Pronchery     { PROV_NAMES_HMAC, "provider=default", ossl_mac_legacy_keymgmt_functions,
446*b077aed3SPierre Pronchery       PROV_DESCS_HMAC_SIGN },
447*b077aed3SPierre Pronchery     { PROV_NAMES_SIPHASH, "provider=default", ossl_mac_legacy_keymgmt_functions,
448*b077aed3SPierre Pronchery       PROV_DESCS_SIPHASH_SIGN },
449*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_POLY1305
450*b077aed3SPierre Pronchery     { PROV_NAMES_POLY1305, "provider=default", ossl_mac_legacy_keymgmt_functions,
451*b077aed3SPierre Pronchery       PROV_DESCS_POLY1305_SIGN },
452*b077aed3SPierre Pronchery #endif
453*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_CMAC
454*b077aed3SPierre Pronchery     { PROV_NAMES_CMAC, "provider=default", ossl_cmac_legacy_keymgmt_functions,
455*b077aed3SPierre Pronchery       PROV_DESCS_CMAC_SIGN },
456*b077aed3SPierre Pronchery #endif
457*b077aed3SPierre Pronchery #ifndef OPENSSL_NO_SM2
458*b077aed3SPierre Pronchery     { PROV_NAMES_SM2, "provider=default", ossl_sm2_keymgmt_functions,
459*b077aed3SPierre Pronchery       PROV_DESCS_SM2 },
460*b077aed3SPierre Pronchery #endif
461*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
462*b077aed3SPierre Pronchery };
463*b077aed3SPierre Pronchery 
464*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_encoder[] = {
465*b077aed3SPierre Pronchery #define ENCODER_PROVIDER "default"
466*b077aed3SPierre Pronchery #include "encoders.inc"
467*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
468*b077aed3SPierre Pronchery #undef ENCODER_PROVIDER
469*b077aed3SPierre Pronchery };
470*b077aed3SPierre Pronchery 
471*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_decoder[] = {
472*b077aed3SPierre Pronchery #define DECODER_PROVIDER "default"
473*b077aed3SPierre Pronchery #include "decoders.inc"
474*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
475*b077aed3SPierre Pronchery #undef DECODER_PROVIDER
476*b077aed3SPierre Pronchery };
477*b077aed3SPierre Pronchery 
478*b077aed3SPierre Pronchery static const OSSL_ALGORITHM deflt_store[] = {
479*b077aed3SPierre Pronchery #define STORE(name, _fips, func_table)                           \
480*b077aed3SPierre Pronchery     { name, "provider=default,fips=" _fips, (func_table) },
481*b077aed3SPierre Pronchery 
482*b077aed3SPierre Pronchery #include "stores.inc"
483*b077aed3SPierre Pronchery     { NULL, NULL, NULL }
484*b077aed3SPierre Pronchery #undef STORE
485*b077aed3SPierre Pronchery };
486*b077aed3SPierre Pronchery 
deflt_query(void * provctx,int operation_id,int * no_cache)487*b077aed3SPierre Pronchery static const OSSL_ALGORITHM *deflt_query(void *provctx, int operation_id,
488*b077aed3SPierre Pronchery                                          int *no_cache)
489*b077aed3SPierre Pronchery {
490*b077aed3SPierre Pronchery     *no_cache = 0;
491*b077aed3SPierre Pronchery     switch (operation_id) {
492*b077aed3SPierre Pronchery     case OSSL_OP_DIGEST:
493*b077aed3SPierre Pronchery         return deflt_digests;
494*b077aed3SPierre Pronchery     case OSSL_OP_CIPHER:
495*b077aed3SPierre Pronchery         return exported_ciphers;
496*b077aed3SPierre Pronchery     case OSSL_OP_MAC:
497*b077aed3SPierre Pronchery         return deflt_macs;
498*b077aed3SPierre Pronchery     case OSSL_OP_KDF:
499*b077aed3SPierre Pronchery         return deflt_kdfs;
500*b077aed3SPierre Pronchery     case OSSL_OP_RAND:
501*b077aed3SPierre Pronchery         return deflt_rands;
502*b077aed3SPierre Pronchery     case OSSL_OP_KEYMGMT:
503*b077aed3SPierre Pronchery         return deflt_keymgmt;
504*b077aed3SPierre Pronchery     case OSSL_OP_KEYEXCH:
505*b077aed3SPierre Pronchery         return deflt_keyexch;
506*b077aed3SPierre Pronchery     case OSSL_OP_SIGNATURE:
507*b077aed3SPierre Pronchery         return deflt_signature;
508*b077aed3SPierre Pronchery     case OSSL_OP_ASYM_CIPHER:
509*b077aed3SPierre Pronchery         return deflt_asym_cipher;
510*b077aed3SPierre Pronchery     case OSSL_OP_KEM:
511*b077aed3SPierre Pronchery         return deflt_asym_kem;
512*b077aed3SPierre Pronchery     case OSSL_OP_ENCODER:
513*b077aed3SPierre Pronchery         return deflt_encoder;
514*b077aed3SPierre Pronchery     case OSSL_OP_DECODER:
515*b077aed3SPierre Pronchery         return deflt_decoder;
516*b077aed3SPierre Pronchery     case OSSL_OP_STORE:
517*b077aed3SPierre Pronchery         return deflt_store;
518*b077aed3SPierre Pronchery     }
519*b077aed3SPierre Pronchery     return NULL;
520*b077aed3SPierre Pronchery }
521*b077aed3SPierre Pronchery 
522*b077aed3SPierre Pronchery 
deflt_teardown(void * provctx)523*b077aed3SPierre Pronchery static void deflt_teardown(void *provctx)
524*b077aed3SPierre Pronchery {
525*b077aed3SPierre Pronchery     BIO_meth_free(ossl_prov_ctx_get0_core_bio_method(provctx));
526*b077aed3SPierre Pronchery     ossl_prov_ctx_free(provctx);
527*b077aed3SPierre Pronchery }
528*b077aed3SPierre Pronchery 
529*b077aed3SPierre Pronchery /* Functions we provide to the core */
530*b077aed3SPierre Pronchery static const OSSL_DISPATCH deflt_dispatch_table[] = {
531*b077aed3SPierre Pronchery     { OSSL_FUNC_PROVIDER_TEARDOWN, (void (*)(void))deflt_teardown },
532*b077aed3SPierre Pronchery     { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))deflt_gettable_params },
533*b077aed3SPierre Pronchery     { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))deflt_get_params },
534*b077aed3SPierre Pronchery     { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))deflt_query },
535*b077aed3SPierre Pronchery     { OSSL_FUNC_PROVIDER_GET_CAPABILITIES,
536*b077aed3SPierre Pronchery       (void (*)(void))ossl_prov_get_capabilities },
537*b077aed3SPierre Pronchery     { 0, NULL }
538*b077aed3SPierre Pronchery };
539*b077aed3SPierre Pronchery 
540*b077aed3SPierre Pronchery OSSL_provider_init_fn ossl_default_provider_init;
541*b077aed3SPierre Pronchery 
ossl_default_provider_init(const OSSL_CORE_HANDLE * handle,const OSSL_DISPATCH * in,const OSSL_DISPATCH ** out,void ** provctx)542*b077aed3SPierre Pronchery int ossl_default_provider_init(const OSSL_CORE_HANDLE *handle,
543*b077aed3SPierre Pronchery                                const OSSL_DISPATCH *in,
544*b077aed3SPierre Pronchery                                const OSSL_DISPATCH **out,
545*b077aed3SPierre Pronchery                                void **provctx)
546*b077aed3SPierre Pronchery {
547*b077aed3SPierre Pronchery     OSSL_FUNC_core_get_libctx_fn *c_get_libctx = NULL;
548*b077aed3SPierre Pronchery     BIO_METHOD *corebiometh;
549*b077aed3SPierre Pronchery 
550*b077aed3SPierre Pronchery     if (!ossl_prov_bio_from_dispatch(in)
551*b077aed3SPierre Pronchery             || !ossl_prov_seeding_from_dispatch(in))
552*b077aed3SPierre Pronchery         return 0;
553*b077aed3SPierre Pronchery     for (; in->function_id != 0; in++) {
554*b077aed3SPierre Pronchery         switch (in->function_id) {
555*b077aed3SPierre Pronchery         case OSSL_FUNC_CORE_GETTABLE_PARAMS:
556*b077aed3SPierre Pronchery             c_gettable_params = OSSL_FUNC_core_gettable_params(in);
557*b077aed3SPierre Pronchery             break;
558*b077aed3SPierre Pronchery         case OSSL_FUNC_CORE_GET_PARAMS:
559*b077aed3SPierre Pronchery             c_get_params = OSSL_FUNC_core_get_params(in);
560*b077aed3SPierre Pronchery             break;
561*b077aed3SPierre Pronchery         case OSSL_FUNC_CORE_GET_LIBCTX:
562*b077aed3SPierre Pronchery             c_get_libctx = OSSL_FUNC_core_get_libctx(in);
563*b077aed3SPierre Pronchery             break;
564*b077aed3SPierre Pronchery         default:
565*b077aed3SPierre Pronchery             /* Just ignore anything we don't understand */
566*b077aed3SPierre Pronchery             break;
567*b077aed3SPierre Pronchery         }
568*b077aed3SPierre Pronchery     }
569*b077aed3SPierre Pronchery 
570*b077aed3SPierre Pronchery     if (c_get_libctx == NULL)
571*b077aed3SPierre Pronchery         return 0;
572*b077aed3SPierre Pronchery 
573*b077aed3SPierre Pronchery     /*
574*b077aed3SPierre Pronchery      * We want to make sure that all calls from this provider that requires
575*b077aed3SPierre Pronchery      * a library context use the same context as the one used to call our
576*b077aed3SPierre Pronchery      * functions.  We do that by passing it along in the provider context.
577*b077aed3SPierre Pronchery      *
578*b077aed3SPierre Pronchery      * This only works for built-in providers.  Most providers should
579*b077aed3SPierre Pronchery      * create their own library context.
580*b077aed3SPierre Pronchery      */
581*b077aed3SPierre Pronchery     if ((*provctx = ossl_prov_ctx_new()) == NULL
582*b077aed3SPierre Pronchery             || (corebiometh = ossl_bio_prov_init_bio_method()) == NULL) {
583*b077aed3SPierre Pronchery         ossl_prov_ctx_free(*provctx);
584*b077aed3SPierre Pronchery         *provctx = NULL;
585*b077aed3SPierre Pronchery         return 0;
586*b077aed3SPierre Pronchery     }
587*b077aed3SPierre Pronchery     ossl_prov_ctx_set0_libctx(*provctx,
588*b077aed3SPierre Pronchery                                        (OSSL_LIB_CTX *)c_get_libctx(handle));
589*b077aed3SPierre Pronchery     ossl_prov_ctx_set0_handle(*provctx, handle);
590*b077aed3SPierre Pronchery     ossl_prov_ctx_set0_core_bio_method(*provctx, corebiometh);
591*b077aed3SPierre Pronchery 
592*b077aed3SPierre Pronchery     *out = deflt_dispatch_table;
593*b077aed3SPierre Pronchery     ossl_prov_cache_exported_algorithms(deflt_ciphers, exported_ciphers);
594*b077aed3SPierre Pronchery 
595*b077aed3SPierre Pronchery     return 1;
596*b077aed3SPierre Pronchery }
597