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