]>
Commit | Line | Data |
---|---|---|
8a73348b MC |
1 | /* |
2 | * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved. | |
3 | * | |
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 | |
8 | */ | |
9 | ||
10 | #include <string.h> | |
11 | #include <stdio.h> | |
55a0a117 | 12 | #include <openssl/opensslconf.h> |
8a73348b MC |
13 | #include <openssl/core.h> |
14 | #include <openssl/core_numbers.h> | |
15 | #include <openssl/core_names.h> | |
16 | #include <openssl/params.h> | |
861b8f87 | 17 | #include "internal/provider_algs.h" |
8a73348b MC |
18 | |
19 | /* Functions provided by the core */ | |
dca97d00 | 20 | static OSSL_core_gettable_params_fn *c_gettable_params = NULL; |
8a73348b MC |
21 | static OSSL_core_get_params_fn *c_get_params = NULL; |
22 | ||
23 | /* Parameters we provide to the core */ | |
26175013 RL |
24 | static const OSSL_PARAM deflt_param_types[] = { |
25 | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_NAME, OSSL_PARAM_UTF8_PTR, NULL, 0), | |
26 | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_VERSION, OSSL_PARAM_UTF8_PTR, NULL, 0), | |
27 | OSSL_PARAM_DEFN(OSSL_PROV_PARAM_BUILDINFO, OSSL_PARAM_UTF8_PTR, NULL, 0), | |
28 | OSSL_PARAM_END | |
8a73348b MC |
29 | }; |
30 | ||
dca97d00 | 31 | static const OSSL_PARAM *deflt_gettable_params(const OSSL_PROVIDER *prov) |
8a73348b MC |
32 | { |
33 | return deflt_param_types; | |
34 | } | |
35 | ||
4e7991b4 | 36 | static int deflt_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[]) |
8a73348b | 37 | { |
4e7991b4 | 38 | OSSL_PARAM *p; |
8a73348b MC |
39 | |
40 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_NAME); | |
41 | if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, "OpenSSL Default Provider")) | |
42 | return 0; | |
43 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_VERSION); | |
44 | if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_VERSION_STR)) | |
45 | return 0; | |
46 | p = OSSL_PARAM_locate(params, OSSL_PROV_PARAM_BUILDINFO); | |
47 | if (p != NULL && !OSSL_PARAM_set_utf8_ptr(p, OPENSSL_FULL_VERSION_STR)) | |
48 | return 0; | |
49 | ||
50 | return 1; | |
51 | } | |
52 | ||
df553b79 RL |
53 | /* |
54 | * For the algorithm names, we use the following formula for our primary | |
55 | * names: | |
56 | * | |
57 | * ALGNAME[VERSION?][-SUBNAME[VERSION?]?][-SIZE?][-MODE?] | |
58 | * | |
59 | * VERSION is only present if there are multiple versions of | |
60 | * an alg (MD2, MD4, MD5). It may be omitted if there is only | |
61 | * one version (if a subsequent version is released in the future, | |
62 | * we can always change the canonical name, and add the old name | |
63 | * as an alias). | |
64 | * | |
65 | * SUBNAME may be present where we are combining multiple | |
66 | * algorithms together, e.g. MD5-SHA1. | |
67 | * | |
68 | * SIZE is only present if multiple versions of an algorithm exist | |
69 | * with different sizes (e.g. AES-128-CBC, AES-256-CBC) | |
70 | * | |
71 | * MODE is only present where applicable. | |
72 | * | |
73 | * We add diverse other names where applicable, such as the names that | |
74 | * NIST uses, or that are used for ASN.1 OBJECT IDENTIFIERs, or names | |
75 | * we have used historically. | |
76 | */ | |
de29ff17 | 77 | static const OSSL_ALGORITHM deflt_digests[] = { |
df553b79 RL |
78 | /* Our primary name:NIST name[:our older names] */ |
79 | { "SHA1:SHA-1", "default=yes", sha1_functions }, | |
80 | { "SHA2-224:SHA-224:SHA224", "default=yes", sha224_functions }, | |
81 | { "SHA2-256:SHA-256:SHA256", "default=yes", sha256_functions }, | |
82 | { "SHA2-384:SHA-384:SHA384", "default=yes", sha384_functions }, | |
83 | { "SHA2-512:SHA-512:SHA512", "default=yes", sha512_functions }, | |
84 | { "SHA2-512/224:SHA-512/224:SHA512-224", "default=yes", | |
85 | sha512_224_functions }, | |
86 | { "SHA2-512/256:SHA-512/256:SHA512-256", "default=yes", | |
87 | sha512_256_functions }, | |
d5e5e2ff | 88 | |
df553b79 | 89 | /* We agree with NIST here, so one name only */ |
d5e5e2ff SL |
90 | { "SHA3-224", "default=yes", sha3_224_functions }, |
91 | { "SHA3-256", "default=yes", sha3_256_functions }, | |
92 | { "SHA3-384", "default=yes", sha3_384_functions }, | |
93 | { "SHA3-512", "default=yes", sha3_512_functions }, | |
94 | ||
e23cda00 | 95 | /* |
bb31895d RL |
96 | * KECCAK_KMAC128 and KECCAK_KMAC256 as hashes are mostly useful for |
97 | * the KMAC128 and KMAC256. | |
e23cda00 | 98 | */ |
bb31895d RL |
99 | { "KECCAK_KMAC128", "default=yes", keccak_kmac_128_functions }, |
100 | { "KECCAK_KMAC256", "default=yes", keccak_kmac_256_functions }, | |
d5e5e2ff | 101 | |
df553b79 RL |
102 | /* Our primary name:NIST name */ |
103 | { "SHAKE-128:SHAKE128", "default=yes", shake_128_functions }, | |
104 | { "SHAKE-256:SHAKE256", "default=yes", shake_256_functions }, | |
d5e5e2ff SL |
105 | |
106 | #ifndef OPENSSL_NO_BLAKE2 | |
df553b79 RL |
107 | /* |
108 | * https://blake2.net/ doesn't specify size variants, | |
109 | * but mentions that Bouncy Castle uses the names | |
110 | * BLAKE2b-160, BLAKE2b-256, BLAKE2b-384, and BLAKE2b-512 | |
111 | * If we assume that "2b" and "2s" are versions, that pattern | |
112 | * fits with ours. We also add our historical names. | |
113 | */ | |
114 | { "BLAKE2s-256:BLAKE2s256", "default=yes", blake2s256_functions }, | |
115 | { "BLAKE2b-512:BLAKE2b512", "default=yes", blake2b512_functions }, | |
d5e5e2ff SL |
116 | #endif /* OPENSSL_NO_BLAKE2 */ |
117 | ||
118 | #ifndef OPENSSL_NO_SM3 | |
119 | { "SM3", "default=yes", sm3_functions }, | |
120 | #endif /* OPENSSL_NO_SM3 */ | |
121 | ||
122 | #ifndef OPENSSL_NO_MD5 | |
123 | { "MD5", "default=yes", md5_functions }, | |
124 | { "MD5-SHA1", "default=yes", md5_sha1_functions }, | |
125 | #endif /* OPENSSL_NO_MD5 */ | |
126 | ||
de29ff17 MC |
127 | { NULL, NULL, NULL } |
128 | }; | |
129 | ||
aab26e6f MC |
130 | static const OSSL_ALGORITHM deflt_ciphers[] = { |
131 | { "AES-256-ECB", "default=yes", aes256ecb_functions }, | |
f4a129bb MC |
132 | { "AES-192-ECB", "default=yes", aes192ecb_functions }, |
133 | { "AES-128-ECB", "default=yes", aes128ecb_functions }, | |
718b133a MC |
134 | { "AES-256-CBC", "default=yes", aes256cbc_functions }, |
135 | { "AES-192-CBC", "default=yes", aes192cbc_functions }, | |
136 | { "AES-128-CBC", "default=yes", aes128cbc_functions }, | |
ed98df51 MC |
137 | { "AES-256-OFB", "default=yes", aes256ofb_functions }, |
138 | { "AES-192-OFB", "default=yes", aes192ofb_functions }, | |
139 | { "AES-128-OFB", "default=yes", aes128ofb_functions }, | |
75dd6d64 MC |
140 | { "AES-256-CFB", "default=yes", aes256cfb_functions }, |
141 | { "AES-192-CFB", "default=yes", aes192cfb_functions }, | |
142 | { "AES-128-CFB", "default=yes", aes128cfb_functions }, | |
143 | { "AES-256-CFB1", "default=yes", aes256cfb1_functions }, | |
144 | { "AES-192-CFB1", "default=yes", aes192cfb1_functions }, | |
145 | { "AES-128-CFB1", "default=yes", aes128cfb1_functions }, | |
146 | { "AES-256-CFB8", "default=yes", aes256cfb8_functions }, | |
147 | { "AES-192-CFB8", "default=yes", aes192cfb8_functions }, | |
148 | { "AES-128-CFB8", "default=yes", aes128cfb8_functions }, | |
819a7ae9 MC |
149 | { "AES-256-CTR", "default=yes", aes256ctr_functions }, |
150 | { "AES-192-CTR", "default=yes", aes192ctr_functions }, | |
151 | { "AES-128-CTR", "default=yes", aes128ctr_functions }, | |
3a9f26f3 SL |
152 | { "AES-256-XTS", "default=yes", aes256xts_functions }, |
153 | { "AES-128-XTS", "default=yes", aes128xts_functions }, | |
3837c202 SL |
154 | #ifndef OPENSSL_NO_OCB |
155 | { "AES-256-OCB", "default=yes", aes256ocb_functions }, | |
156 | { "AES-192-OCB", "default=yes", aes192ocb_functions }, | |
157 | { "AES-128-OCB", "default=yes", aes128ocb_functions }, | |
158 | #endif /* OPENSSL_NO_OCB */ | |
df553b79 RL |
159 | { "AES-256-GCM:id-aes256-GCM", "default=yes", aes256gcm_functions }, |
160 | { "AES-192-GCM:id-aes192-GCM", "default=yes", aes192gcm_functions }, | |
161 | { "AES-128-GCM:id-aes128-GCM", "default=yes", aes128gcm_functions }, | |
162 | { "AES-256-CCM:id-aes256-CCM", "default=yes", aes256ccm_functions }, | |
163 | { "AES-192-CCM:id-aes192-CCM", "default=yes", aes192ccm_functions }, | |
164 | { "AES-128-CCM:id-aes128-CCM", "default=yes", aes128ccm_functions }, | |
165 | { "AES-256-WRAP:id-aes256-wrap:AES256-WRAP", "default=yes", | |
166 | aes256wrap_functions }, | |
167 | { "AES-192-WRAP:id-aes192-wrap:AES192-WRAP", "default=yes", | |
168 | aes192wrap_functions }, | |
169 | { "AES-128-WRAP:id-aes128-wrap:AES128-WRAP", "default=yes", | |
170 | aes128wrap_functions }, | |
171 | { "AES-256-WRAP-PAD:id-aes256-wrap-pad:AES256-WRAP-PAD", "default=yes", | |
172 | aes256wrappad_functions }, | |
173 | { "AES-192-WRAP-PAD:id-aes192-wrap-pad:AES192-WRAP-PAD", "default=yes", | |
174 | aes192wrappad_functions }, | |
175 | { "AES-128-WRAP-PAD:id-aes128-wrap-pad:AES128-WRAP-PAD", "default=yes", | |
176 | aes128wrappad_functions }, | |
a672a02a SL |
177 | #ifndef OPENSSL_NO_ARIA |
178 | { "ARIA-256-GCM", "default=yes", aria256gcm_functions }, | |
179 | { "ARIA-192-GCM", "default=yes", aria192gcm_functions }, | |
180 | { "ARIA-128-GCM", "default=yes", aria128gcm_functions }, | |
3bfe9005 SL |
181 | { "ARIA-256-CCM", "default=yes", aria256ccm_functions }, |
182 | { "ARIA-192-CCM", "default=yes", aria192ccm_functions }, | |
183 | { "ARIA-128-CCM", "default=yes", aria128ccm_functions }, | |
e1178600 SL |
184 | { "ARIA-256-ECB", "default=yes", aria256ecb_functions }, |
185 | { "ARIA-192-ECB", "default=yes", aria192ecb_functions }, | |
186 | { "ARIA-128-ECB", "default=yes", aria128ecb_functions }, | |
df553b79 RL |
187 | { "ARIA-256-CBC:ARIA256", "default=yes", aria256cbc_functions }, |
188 | { "ARIA-192-CBC:ARIA192", "default=yes", aria192cbc_functions }, | |
189 | { "ARIA-128-CBC:ARIA128", "default=yes", aria128cbc_functions }, | |
e1178600 SL |
190 | { "ARIA-256-OFB", "default=yes", aria256ofb_functions }, |
191 | { "ARIA-192-OFB", "default=yes", aria192ofb_functions }, | |
192 | { "ARIA-128-OFB", "default=yes", aria128ofb_functions }, | |
193 | { "ARIA-256-CFB", "default=yes", aria256cfb_functions }, | |
194 | { "ARIA-192-CFB", "default=yes", aria192cfb_functions }, | |
195 | { "ARIA-128-CFB", "default=yes", aria128cfb_functions }, | |
196 | { "ARIA-256-CFB1", "default=yes", aria256cfb1_functions }, | |
197 | { "ARIA-192-CFB1", "default=yes", aria192cfb1_functions }, | |
198 | { "ARIA-128-CFB1", "default=yes", aria128cfb1_functions }, | |
199 | { "ARIA-256-CFB8", "default=yes", aria256cfb8_functions }, | |
200 | { "ARIA-192-CFB8", "default=yes", aria192cfb8_functions }, | |
201 | { "ARIA-128-CFB8", "default=yes", aria128cfb8_functions }, | |
202 | { "ARIA-256-CTR", "default=yes", aria256ctr_functions }, | |
203 | { "ARIA-192-CTR", "default=yes", aria192ctr_functions }, | |
204 | { "ARIA-128-CTR", "default=yes", aria128ctr_functions }, | |
a672a02a | 205 | #endif /* OPENSSL_NO_ARIA */ |
e1178600 SL |
206 | #ifndef OPENSSL_NO_CAMELLIA |
207 | { "CAMELLIA-256-ECB", "default=yes", camellia256ecb_functions }, | |
208 | { "CAMELLIA-192-ECB", "default=yes", camellia192ecb_functions }, | |
209 | { "CAMELLIA-128-ECB", "default=yes", camellia128ecb_functions }, | |
df553b79 RL |
210 | { "CAMELLIA-256-CBC:CAMELLIA256", "default=yes", camellia256cbc_functions }, |
211 | { "CAMELLIA-192-CBC:CAMELLIA192", "default=yes", camellia192cbc_functions }, | |
212 | { "CAMELLIA-128-CBC:CAMELLIA128", "default=yes", camellia128cbc_functions }, | |
e1178600 SL |
213 | { "CAMELLIA-256-OFB", "default=yes", camellia256ofb_functions }, |
214 | { "CAMELLIA-192-OFB", "default=yes", camellia192ofb_functions }, | |
215 | { "CAMELLIA-128-OFB", "default=yes", camellia128ofb_functions }, | |
216 | { "CAMELLIA-256-CFB", "default=yes", camellia256cfb_functions }, | |
217 | { "CAMELLIA-192-CFB", "default=yes", camellia192cfb_functions }, | |
218 | { "CAMELLIA-128-CFB", "default=yes", camellia128cfb_functions }, | |
219 | { "CAMELLIA-256-CFB1", "default=yes", camellia256cfb1_functions }, | |
220 | { "CAMELLIA-192-CFB1", "default=yes", camellia192cfb1_functions }, | |
221 | { "CAMELLIA-128-CFB1", "default=yes", camellia128cfb1_functions }, | |
222 | { "CAMELLIA-256-CFB8", "default=yes", camellia256cfb8_functions }, | |
223 | { "CAMELLIA-192-CFB8", "default=yes", camellia192cfb8_functions }, | |
224 | { "CAMELLIA-128-CFB8", "default=yes", camellia128cfb8_functions }, | |
225 | { "CAMELLIA-256-CTR", "default=yes", camellia256ctr_functions }, | |
226 | { "CAMELLIA-192-CTR", "default=yes", camellia192ctr_functions }, | |
227 | { "CAMELLIA-128-CTR", "default=yes", camellia128ctr_functions }, | |
228 | #endif /* OPENSSL_NO_CAMELLIA */ | |
cb1548bc | 229 | #ifndef OPENSSL_NO_DES |
df553b79 RL |
230 | { "DES-EDE3-ECB:DES-EDE3", "default=yes", tdes_ede3_ecb_functions }, |
231 | { "DES-EDE3-CBC:DES3", "default=yes", tdes_ede3_cbc_functions }, | |
4a42e264 SL |
232 | { "DES-EDE3-OFB", "default=yes", tdes_ede3_ofb_functions }, |
233 | { "DES-EDE3-CFB", "default=yes", tdes_ede3_cfb_functions }, | |
234 | { "DES-EDE3-CFB8", "default=yes", tdes_ede3_cfb8_functions }, | |
235 | { "DES-EDE3-CFB1", "default=yes", tdes_ede3_cfb1_functions }, | |
df553b79 | 236 | { "DES-EDE-ECB:DES-EDE", "default=yes", tdes_ede2_ecb_functions }, |
4a42e264 SL |
237 | { "DES-EDE-CBC", "default=yes", tdes_ede2_cbc_functions }, |
238 | { "DES-EDE-OFB", "default=yes", tdes_ede2_ofb_functions }, | |
239 | { "DES-EDE-CFB", "default=yes", tdes_ede2_cfb_functions }, | |
df553b79 RL |
240 | { "DESX-CBC:DESX", "default=yes", tdes_desx_cbc_functions }, |
241 | { "DES3-WRAP:id-smime-alg-CMS3DESwrap", "default=yes", tdes_wrap_cbc_functions }, | |
e3f3ee44 | 242 | { "DES-ECB", "default=yes", des_ecb_functions }, |
df553b79 | 243 | { "DES-CBC:DES", "default=yes", des_cbc_functions }, |
e3f3ee44 SL |
244 | { "DES-OFB", "default=yes", des_ofb64_functions }, |
245 | { "DES-CFB", "default=yes", des_cfb64_functions }, | |
246 | { "DES-CFB1", "default=yes", des_cfb1_functions }, | |
247 | { "DES-CFB8", "default=yes", des_cfb8_functions }, | |
cb1548bc | 248 | #endif /* OPENSSL_NO_DES */ |
55c7dc79 SL |
249 | #ifndef OPENSSL_NO_BF |
250 | { "BF-ECB", "default=yes", blowfish128ecb_functions }, | |
df553b79 | 251 | { "BF-CBC:BF:BLOWFISH", "default=yes", blowfish128cbc_functions }, |
55c7dc79 SL |
252 | { "BF-OFB", "default=yes", blowfish64ofb64_functions }, |
253 | { "BF-CFB", "default=yes", blowfish64cfb64_functions }, | |
254 | #endif /* OPENSSL_NO_BF */ | |
f22431f2 SL |
255 | #ifndef OPENSSL_NO_IDEA |
256 | { "IDEA-ECB", "default=yes", idea128ecb_functions }, | |
df553b79 RL |
257 | { "IDEA-CBC:IDEA", "default=yes", idea128cbc_functions }, |
258 | { "IDEA-OFB:IDEA-OFB64", "default=yes", idea128ofb64_functions }, | |
259 | { "IDEA-CFB:IDEA-CFB64", "default=yes", idea128cfb64_functions }, | |
f22431f2 | 260 | #endif /* OPENSSL_NO_IDEA */ |
18b00427 SL |
261 | #ifndef OPENSSL_NO_CAST |
262 | { "CAST5-ECB", "default=yes", cast5128ecb_functions }, | |
df553b79 | 263 | { "CAST5-CBC:CAST-CBC:CAST", "default=yes", cast5128cbc_functions }, |
18b00427 SL |
264 | { "CAST5-OFB", "default=yes", cast564ofb64_functions }, |
265 | { "CAST5-CFB", "default=yes", cast564cfb64_functions }, | |
266 | #endif /* OPENSSL_NO_CAST */ | |
70adc646 SL |
267 | #ifndef OPENSSL_NO_SEED |
268 | { "SEED-ECB", "default=yes", seed128ecb_functions }, | |
df553b79 RL |
269 | { "SEED-CBC:SEED", "default=yes", seed128cbc_functions }, |
270 | { "SEED-OFB:SEED-OFB128", "default=yes", seed128ofb128_functions }, | |
271 | { "SEED-CFB:SEED-CFB128", "default=yes", seed128cfb128_functions }, | |
70adc646 | 272 | #endif /* OPENSSL_NO_SEED */ |
105dde25 SL |
273 | #ifndef OPENSSL_NO_SM4 |
274 | { "SM4-ECB", "default=yes", sm4128ecb_functions }, | |
df553b79 | 275 | { "SM4-CBC:SM4", "default=yes", sm4128cbc_functions }, |
105dde25 | 276 | { "SM4-CTR", "default=yes", sm4128ctr_functions }, |
df553b79 RL |
277 | { "SM4-OFB:SM4-OFB128", "default=yes", sm4128ofb128_functions }, |
278 | { "SM4-CFB:SM4-CFB128", "default=yes", sm4128cfb128_functions }, | |
105dde25 | 279 | #endif /* OPENSSL_NO_SM4 */ |
bafde183 SL |
280 | #ifndef OPENSSL_NO_RC4 |
281 | { "RC4", "default=yes", rc4128_functions }, | |
282 | { "RC4-40", "default=yes", rc440_functions }, | |
283 | #endif /* OPENSSL_NO_RC4 */ | |
6a41156c SL |
284 | #ifndef OPENSSL_NO_RC5 |
285 | { "RC5-ECB", "default=yes", rc5128ecb_functions }, | |
286 | { "RC5-CBC", "default=yes", rc5128cbc_functions }, | |
287 | { "RC5-OFB", "default=yes", rc5128ofb64_functions }, | |
288 | { "RC5-CFB", "default=yes", rc5128cfb64_functions }, | |
289 | #endif /* OPENSSL_NO_RC5 */ | |
aab26e6f MC |
290 | { NULL, NULL, NULL } |
291 | }; | |
292 | ||
55a0a117 RL |
293 | static const OSSL_ALGORITHM deflt_macs[] = { |
294 | #ifndef OPENSSL_NO_BLAKE2 | |
df553b79 RL |
295 | { "BLAKE2bMAC", "default=yes", blake2bmac_functions }, |
296 | { "BLAKE2sMAC", "default=yes", blake2smac_functions }, | |
2e5db6ad RL |
297 | #endif |
298 | #ifndef OPENSSL_NO_CMAC | |
299 | { "CMAC", "default=yes", cmac_functions }, | |
55a0a117 | 300 | #endif |
d33313be | 301 | { "GMAC", "default=yes", gmac_functions }, |
5183ebdc | 302 | { "HMAC", "default=yes", hmac_functions }, |
e23cda00 RL |
303 | { "KMAC128", "default=yes", kmac128_functions }, |
304 | { "KMAC256", "default=yes", kmac256_functions }, | |
4657693d RL |
305 | #ifndef OPENSSL_NO_SIPHASH |
306 | { "SipHash", "default=yes", siphash_functions }, | |
ae0b6b92 RL |
307 | #endif |
308 | #ifndef OPENSSL_NO_POLY1305 | |
309 | { "Poly1305", "default=yes", poly1305_functions }, | |
4657693d | 310 | #endif |
55a0a117 RL |
311 | { NULL, NULL, NULL } |
312 | }; | |
313 | ||
e3405a4a | 314 | static const OSSL_ALGORITHM deflt_kdfs[] = { |
69333af4 P |
315 | { OSSL_KDF_NAME_HKDF, "default=yes", kdf_hkdf_functions }, |
316 | { OSSL_KDF_NAME_SSKDF, "default=yes", kdf_sskdf_functions }, | |
317 | { OSSL_KDF_NAME_PBKDF2, "default=yes", kdf_pbkdf2_functions }, | |
318 | { OSSL_KDF_NAME_SSHKDF, "default=yes", kdf_sshkdf_functions }, | |
319 | { OSSL_KDF_NAME_X963KDF, "default=yes", kdf_x963_kdf_functions }, | |
320 | { OSSL_KDF_NAME_TLS1_PRF, "default=yes", kdf_tls1_prf_functions }, | |
a39bc440 | 321 | { OSSL_KDF_NAME_KBKDF, "default=yes", kdf_kbkdf_functions }, |
e3405a4a | 322 | #ifndef OPENSSL_NO_CMS |
69333af4 | 323 | { OSSL_KDF_NAME_X942KDF, "default=yes", kdf_x942_kdf_functions }, |
e3405a4a P |
324 | #endif |
325 | #ifndef OPENSSL_NO_SCRYPT | |
df553b79 | 326 | { "SCRYPT:id-scrypt", "default=yes", kdf_scrypt_functions }, |
e3405a4a P |
327 | #endif |
328 | { NULL, NULL, NULL } | |
329 | }; | |
330 | ||
89e29174 | 331 | static const OSSL_ALGORITHM deflt_keyexch[] = { |
76ca35e7 | 332 | #ifndef OPENSSL_NO_DH |
df553b79 | 333 | { "DH:dhKeyAgreement", "default=yes", dh_keyexch_functions }, |
8b84b075 RL |
334 | #endif |
335 | { NULL, NULL, NULL } | |
336 | }; | |
337 | ||
4889dadc MC |
338 | static const OSSL_ALGORITHM deflt_signature[] = { |
339 | #ifndef OPENSSL_NO_DSA | |
df553b79 | 340 | { "DSA:dsaEncryption", "default=yes", dsa_signature_functions }, |
4889dadc MC |
341 | #endif |
342 | { NULL, NULL, NULL } | |
343 | }; | |
344 | ||
345 | ||
8b84b075 RL |
346 | static const OSSL_ALGORITHM deflt_keymgmt[] = { |
347 | #ifndef OPENSSL_NO_DH | |
df553b79 | 348 | { "DH", "default=yes", dh_keymgmt_functions }, |
4889dadc MC |
349 | #endif |
350 | #ifndef OPENSSL_NO_DSA | |
351 | { "DSA", "default=yes", dsa_keymgmt_functions }, | |
76ca35e7 | 352 | #endif |
89e29174 MC |
353 | { NULL, NULL, NULL } |
354 | }; | |
355 | ||
de29ff17 MC |
356 | static const OSSL_ALGORITHM *deflt_query(OSSL_PROVIDER *prov, |
357 | int operation_id, | |
358 | int *no_cache) | |
359 | { | |
360 | *no_cache = 0; | |
361 | switch (operation_id) { | |
362 | case OSSL_OP_DIGEST: | |
363 | return deflt_digests; | |
aab26e6f MC |
364 | case OSSL_OP_CIPHER: |
365 | return deflt_ciphers; | |
55a0a117 RL |
366 | case OSSL_OP_MAC: |
367 | return deflt_macs; | |
e3405a4a P |
368 | case OSSL_OP_KDF: |
369 | return deflt_kdfs; | |
8b84b075 RL |
370 | case OSSL_OP_KEYMGMT: |
371 | return deflt_keymgmt; | |
89e29174 MC |
372 | case OSSL_OP_KEYEXCH: |
373 | return deflt_keyexch; | |
4889dadc MC |
374 | case OSSL_OP_SIGNATURE: |
375 | return deflt_signature; | |
de29ff17 MC |
376 | } |
377 | return NULL; | |
378 | } | |
379 | ||
8a73348b MC |
380 | /* Functions we provide to the core */ |
381 | static const OSSL_DISPATCH deflt_dispatch_table[] = { | |
dca97d00 | 382 | { OSSL_FUNC_PROVIDER_GETTABLE_PARAMS, (void (*)(void))deflt_gettable_params }, |
8a73348b | 383 | { OSSL_FUNC_PROVIDER_GET_PARAMS, (void (*)(void))deflt_get_params }, |
de29ff17 | 384 | { OSSL_FUNC_PROVIDER_QUERY_OPERATION, (void (*)(void))deflt_query }, |
8a73348b MC |
385 | { 0, NULL } |
386 | }; | |
387 | ||
388 | OSSL_provider_init_fn ossl_default_provider_init; | |
389 | ||
390 | int ossl_default_provider_init(const OSSL_PROVIDER *provider, | |
391 | const OSSL_DISPATCH *in, | |
a39eb840 RL |
392 | const OSSL_DISPATCH **out, |
393 | void **provctx) | |
8a73348b | 394 | { |
8013a933 RL |
395 | OSSL_core_get_library_context_fn *c_get_libctx = NULL; |
396 | ||
8a73348b MC |
397 | for (; in->function_id != 0; in++) { |
398 | switch (in->function_id) { | |
dca97d00 RL |
399 | case OSSL_FUNC_CORE_GETTABLE_PARAMS: |
400 | c_gettable_params = OSSL_get_core_gettable_params(in); | |
8a73348b MC |
401 | break; |
402 | case OSSL_FUNC_CORE_GET_PARAMS: | |
403 | c_get_params = OSSL_get_core_get_params(in); | |
404 | break; | |
8013a933 RL |
405 | case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT: |
406 | c_get_libctx = OSSL_get_core_get_library_context(in); | |
407 | break; | |
8a73348b MC |
408 | default: |
409 | /* Just ignore anything we don't understand */ | |
410 | break; | |
411 | } | |
412 | } | |
413 | ||
8013a933 RL |
414 | if (c_get_libctx == NULL) |
415 | return 0; | |
416 | ||
8a73348b | 417 | *out = deflt_dispatch_table; |
8013a933 RL |
418 | |
419 | /* | |
420 | * We want to make sure that all calls from this provider that requires | |
421 | * a library context use the same context as the one used to call our | |
422 | * functions. We do that by passing it along as the provider context. | |
423 | */ | |
424 | *provctx = c_get_libctx(provider); | |
8a73348b MC |
425 | return 1; |
426 | } |