/src/openssl40/providers/implementations/keymgmt/rsa_kmgmt.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright 2019-2026 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 | | /* |
11 | | * RSA low level APIs are deprecated for public use, but still ok for |
12 | | * internal use. |
13 | | */ |
14 | | #include "internal/deprecated.h" |
15 | | |
16 | | #include <openssl/core_dispatch.h> |
17 | | #include <openssl/core_names.h> |
18 | | #include <openssl/bn.h> |
19 | | #include <openssl/err.h> |
20 | | #include <openssl/rsa.h> |
21 | | #include <openssl/evp.h> |
22 | | #include <openssl/proverr.h> |
23 | | #include "prov/implementations.h" |
24 | | #include "prov/providercommon.h" |
25 | | #include "prov/provider_ctx.h" |
26 | | #include "crypto/rsa.h" |
27 | | #include "crypto/cryptlib.h" |
28 | | #include "internal/fips.h" |
29 | | #include "internal/param_build_set.h" |
30 | | #include "fips/fipsindicator.h" |
31 | | #include "providers/implementations/keymgmt/keymgmtcommon.inc" |
32 | | |
33 | | static OSSL_FUNC_keymgmt_new_fn rsa_newdata; |
34 | | static OSSL_FUNC_keymgmt_new_ex_fn rsa_newdata_ex; |
35 | | static OSSL_FUNC_keymgmt_new_fn rsapss_newdata; |
36 | | static OSSL_FUNC_keymgmt_new_ex_fn rsapss_newdata_ex; |
37 | | static OSSL_FUNC_keymgmt_gen_init_fn rsa_gen_init; |
38 | | static OSSL_FUNC_keymgmt_gen_init_fn rsapss_gen_init; |
39 | | static OSSL_FUNC_keymgmt_gen_set_params_fn rsa_gen_set_params; |
40 | | static OSSL_FUNC_keymgmt_gen_settable_params_fn rsa_gen_settable_params; |
41 | | static OSSL_FUNC_keymgmt_gen_settable_params_fn rsapss_gen_settable_params; |
42 | | #ifdef FIPS_MODULE |
43 | | static OSSL_FUNC_keymgmt_gen_get_params_fn rsa_gen_get_params; |
44 | | #endif |
45 | | static OSSL_FUNC_keymgmt_gen_fn rsa_gen; |
46 | | static OSSL_FUNC_keymgmt_gen_cleanup_fn rsa_gen_cleanup; |
47 | | static OSSL_FUNC_keymgmt_load_fn rsa_load; |
48 | | static OSSL_FUNC_keymgmt_load_fn rsapss_load; |
49 | | static OSSL_FUNC_keymgmt_free_fn rsa_freedata; |
50 | | static OSSL_FUNC_keymgmt_get_params_fn rsa_get_params; |
51 | | static OSSL_FUNC_keymgmt_gettable_params_fn rsa_gettable_params; |
52 | | static OSSL_FUNC_keymgmt_has_fn rsa_has; |
53 | | static OSSL_FUNC_keymgmt_match_fn rsa_match; |
54 | | static OSSL_FUNC_keymgmt_validate_fn rsa_validate; |
55 | | static OSSL_FUNC_keymgmt_import_fn rsa_import; |
56 | | static OSSL_FUNC_keymgmt_import_types_fn rsa_import_types; |
57 | | static OSSL_FUNC_keymgmt_export_fn rsa_export; |
58 | | static OSSL_FUNC_keymgmt_export_types_fn rsa_export_types; |
59 | | static OSSL_FUNC_keymgmt_query_operation_name_fn rsa_query_operation_name; |
60 | | static OSSL_FUNC_keymgmt_dup_fn rsa_dup; |
61 | | |
62 | 0 | #define RSA_DEFAULT_MD "SHA256" |
63 | | #define RSA_POSSIBLE_SELECTIONS \ |
64 | 247k | (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) |
65 | | |
66 | | DEFINE_STACK_OF(BIGNUM) |
67 | | DEFINE_SPECIAL_STACK_OF_CONST(BIGNUM_const, BIGNUM) |
68 | | |
69 | | static int pss_params_fromdata(RSA_PSS_PARAMS_30 *pss_params, int *defaults_set, |
70 | | const OSSL_PARAM params[], int rsa_type, |
71 | | OSSL_LIB_CTX *libctx) |
72 | 0 | { |
73 | 0 | if (!ossl_rsa_pss_params_30_fromdata(pss_params, defaults_set, |
74 | 0 | params, libctx)) |
75 | 0 | return 0; |
76 | | |
77 | | /* If not a PSS type RSA, sending us PSS parameters is wrong */ |
78 | 0 | if (rsa_type != RSA_FLAG_TYPE_RSASSAPSS |
79 | 0 | && !ossl_rsa_pss_params_30_is_unrestricted(pss_params)) |
80 | 0 | return 0; |
81 | | |
82 | 0 | return 1; |
83 | 0 | } |
84 | | |
85 | | /* |
86 | | * If the application actually created a legacy RSA object and assigned it to |
87 | | * the EVP_PKEY, then we get hold of that object here. We return 0 if we hit |
88 | | * a fatal error or 1 otherwise. We may return 1 but with *rsa set to NULL. |
89 | | */ |
90 | | static int get_legacy_rsa_object(OSSL_LIB_CTX *libctx, RSA **rsa, const OSSL_PARAM params[]) |
91 | 16.1k | { |
92 | 16.1k | #ifndef FIPS_MODULE |
93 | 16.1k | const OSSL_PARAM *p; |
94 | | |
95 | 16.1k | if (params == NULL) |
96 | 0 | return 1; |
97 | 16.1k | p = OSSL_PARAM_locate_const(params, "legacy-object"); |
98 | 16.1k | if (p == NULL) |
99 | 0 | return 1; |
100 | | /* |
101 | | * This only works because we are in the default provider. We are not |
102 | | * normally allowed to pass complex objects across the provider boundary |
103 | | * like this. |
104 | | */ |
105 | 16.1k | if (OSSL_PARAM_get_octet_ptr(p, (const void **)rsa, NULL) && *rsa != NULL) { |
106 | 16.1k | if (ossl_lib_ctx_get_concrete(ossl_rsa_get0_libctx(*rsa)) != ossl_lib_ctx_get_concrete(libctx)) { |
107 | 0 | *rsa = NULL; |
108 | 0 | return 1; |
109 | 0 | } |
110 | 16.1k | if (!RSA_up_ref(*rsa)) |
111 | 0 | return 0; |
112 | 16.1k | } |
113 | 16.1k | #endif |
114 | | |
115 | 16.1k | return 1; |
116 | 16.1k | } |
117 | | |
118 | | static void *rsa_newdata_ex(void *provctx, const OSSL_PARAM params[]) |
119 | 16.1k | { |
120 | 16.1k | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx); |
121 | 16.1k | RSA *rsa = NULL; |
122 | | |
123 | 16.1k | if (!ossl_prov_is_running()) |
124 | 0 | return NULL; |
125 | | |
126 | 16.1k | if (!get_legacy_rsa_object(libctx, &rsa, params)) |
127 | 0 | return NULL; |
128 | | |
129 | 16.1k | if (rsa == NULL) { |
130 | 0 | rsa = ossl_rsa_new_with_ctx(libctx); |
131 | 0 | if (rsa != NULL) { |
132 | 0 | RSA_clear_flags(rsa, RSA_FLAG_TYPE_MASK); |
133 | 0 | RSA_set_flags(rsa, RSA_FLAG_TYPE_RSA); |
134 | 0 | } |
135 | 0 | } |
136 | | |
137 | 16.1k | return rsa; |
138 | 16.1k | } |
139 | | |
140 | | static void *rsa_newdata(void *provctx) |
141 | | { |
142 | | return rsa_newdata_ex(provctx, NULL); |
143 | | } |
144 | | |
145 | | static void *rsapss_newdata_ex(void *provctx, const OSSL_PARAM params[]) |
146 | 0 | { |
147 | 0 | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx); |
148 | 0 | RSA *rsa = NULL; |
149 | |
|
150 | 0 | if (!ossl_prov_is_running()) |
151 | 0 | return NULL; |
152 | | |
153 | 0 | if (!get_legacy_rsa_object(libctx, &rsa, params)) |
154 | 0 | return NULL; |
155 | | |
156 | 0 | if (rsa == NULL) { |
157 | 0 | rsa = ossl_rsa_new_with_ctx(libctx); |
158 | 0 | if (rsa != NULL) { |
159 | 0 | RSA_clear_flags(rsa, RSA_FLAG_TYPE_MASK); |
160 | 0 | RSA_set_flags(rsa, RSA_FLAG_TYPE_RSASSAPSS); |
161 | 0 | } |
162 | 0 | } |
163 | |
|
164 | 0 | return rsa; |
165 | 0 | } |
166 | | |
167 | | static void *rsapss_newdata(void *provctx) |
168 | 0 | { |
169 | 0 | return rsapss_newdata_ex(provctx, NULL); |
170 | 0 | } |
171 | | |
172 | | static void rsa_freedata(void *keydata) |
173 | 224k | { |
174 | 224k | RSA_free(keydata); |
175 | 224k | } |
176 | | |
177 | | static int rsa_has(const void *keydata, int selection) |
178 | 188k | { |
179 | 188k | const RSA *rsa = keydata; |
180 | 188k | int ok = 1; |
181 | | |
182 | 188k | if (rsa == NULL || !ossl_prov_is_running()) |
183 | 0 | return 0; |
184 | 188k | if ((selection & RSA_POSSIBLE_SELECTIONS) == 0) |
185 | 95.5k | return 1; /* the selection is not missing */ |
186 | | |
187 | | /* OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS are always available even if empty */ |
188 | 92.8k | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) |
189 | 92.8k | ok = ok && (RSA_get0_n(rsa) != NULL); |
190 | 92.8k | if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) |
191 | 69.1k | ok = ok && (RSA_get0_e(rsa) != NULL); |
192 | 92.8k | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) |
193 | 23.7k | ok = ok && (RSA_get0_d(rsa) != NULL); |
194 | 92.8k | return ok; |
195 | 188k | } |
196 | | |
197 | | static int rsa_match(const void *keydata1, const void *keydata2, int selection) |
198 | 106k | { |
199 | 106k | const RSA *rsa1 = keydata1; |
200 | 106k | const RSA *rsa2 = keydata2; |
201 | 106k | int ok = 1; |
202 | | |
203 | 106k | if (!ossl_prov_is_running()) |
204 | 0 | return 0; |
205 | | |
206 | | /* There is always an |e| */ |
207 | 106k | ok = ok && BN_cmp(RSA_get0_e(rsa1), RSA_get0_e(rsa2)) == 0; |
208 | 106k | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) { |
209 | 55.8k | int key_checked = 0; |
210 | | |
211 | 55.8k | if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) { |
212 | 55.8k | const BIGNUM *pa = RSA_get0_n(rsa1); |
213 | 55.8k | const BIGNUM *pb = RSA_get0_n(rsa2); |
214 | | |
215 | 55.8k | if (pa != NULL && pb != NULL) { |
216 | 55.8k | ok = ok && BN_cmp(pa, pb) == 0; |
217 | 55.8k | key_checked = 1; |
218 | 55.8k | } |
219 | 55.8k | } |
220 | 55.8k | if (!key_checked |
221 | 0 | && (selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) { |
222 | 0 | const BIGNUM *pa = RSA_get0_d(rsa1); |
223 | 0 | const BIGNUM *pb = RSA_get0_d(rsa2); |
224 | |
|
225 | 0 | if (pa != NULL && pb != NULL) { |
226 | 0 | ok = ok && BN_cmp(pa, pb) == 0; |
227 | 0 | key_checked = 1; |
228 | 0 | } |
229 | 0 | } |
230 | 55.8k | ok = ok && key_checked; |
231 | 55.8k | } |
232 | 106k | return ok; |
233 | 106k | } |
234 | | |
235 | | static int rsa_import(void *keydata, int selection, const OSSL_PARAM params[]) |
236 | 26.4k | { |
237 | 26.4k | RSA *rsa = keydata; |
238 | 26.4k | int rsa_type; |
239 | 26.4k | int ok = 1; |
240 | 26.4k | int pss_defaults_set = 0; |
241 | | |
242 | 26.4k | if (!ossl_prov_is_running() || rsa == NULL) |
243 | 0 | return 0; |
244 | | |
245 | 26.4k | if ((selection & RSA_POSSIBLE_SELECTIONS) == 0) |
246 | 0 | return 0; |
247 | | |
248 | 26.4k | rsa_type = RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK); |
249 | | |
250 | 26.4k | if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0) |
251 | 0 | ok = ok && pss_params_fromdata(ossl_rsa_get0_pss_params_30(rsa), &pss_defaults_set, params, rsa_type, ossl_rsa_get0_libctx(rsa)); |
252 | 26.4k | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) { |
253 | 26.4k | int include_private = selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY ? 1 : 0; |
254 | | |
255 | 26.4k | ok = ok && ossl_rsa_fromdata(rsa, params, include_private); |
256 | 26.4k | } |
257 | | |
258 | 26.4k | return ok; |
259 | 26.4k | } |
260 | | |
261 | | static int rsa_export(void *keydata, int selection, |
262 | | OSSL_CALLBACK *param_callback, void *cbarg) |
263 | 14.7k | { |
264 | 14.7k | RSA *rsa = keydata; |
265 | 14.7k | const RSA_PSS_PARAMS_30 *pss_params = ossl_rsa_get0_pss_params_30(rsa); |
266 | 14.7k | OSSL_PARAM_BLD *tmpl; |
267 | 14.7k | OSSL_PARAM *params = NULL; |
268 | 14.7k | int ok = 1; |
269 | | |
270 | 14.7k | if (!ossl_prov_is_running() || rsa == NULL) |
271 | 0 | return 0; |
272 | | |
273 | 14.7k | if ((selection & RSA_POSSIBLE_SELECTIONS) == 0) |
274 | 0 | return 0; |
275 | | |
276 | 14.7k | tmpl = OSSL_PARAM_BLD_new(); |
277 | 14.7k | if (tmpl == NULL) |
278 | 0 | return 0; |
279 | | |
280 | 14.7k | if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0) |
281 | 14.7k | ok = ok && (ossl_rsa_pss_params_30_is_unrestricted(pss_params) || ossl_rsa_pss_params_30_todata(pss_params, tmpl, NULL)); |
282 | 14.7k | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) { |
283 | 14.7k | int include_private = selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY ? 1 : 0; |
284 | | |
285 | 14.7k | ok = ok && ossl_rsa_todata(rsa, tmpl, NULL, include_private); |
286 | 14.7k | } |
287 | | |
288 | 14.7k | if (!ok || (params = OSSL_PARAM_BLD_to_param(tmpl)) == NULL) { |
289 | 0 | ok = 0; |
290 | 0 | goto err; |
291 | 0 | } |
292 | | |
293 | 14.7k | ok = param_callback(params, cbarg); |
294 | 14.7k | OSSL_PARAM_clear_free(params); |
295 | 14.7k | err: |
296 | 14.7k | OSSL_PARAM_BLD_free(tmpl); |
297 | 14.7k | return ok; |
298 | 14.7k | } |
299 | | |
300 | | #ifdef FIPS_MODULE |
301 | | /* In fips mode there are no multi-primes. */ |
302 | | #define RSA_KEY_MP_TYPES() \ |
303 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR1, NULL, 0), \ |
304 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR2, NULL, 0), \ |
305 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT1, NULL, 0), \ |
306 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT2, NULL, 0), \ |
307 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT1, NULL, 0), |
308 | | #else |
309 | | /* |
310 | | * We allow up to 10 prime factors (starting with p, q). |
311 | | * NOTE: there is only 9 OSSL_PKEY_PARAM_RSA_COEFFICIENT |
312 | | */ |
313 | | #define RSA_KEY_MP_TYPES() \ |
314 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR1, NULL, 0), \ |
315 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR2, NULL, 0), \ |
316 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR3, NULL, 0), \ |
317 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR4, NULL, 0), \ |
318 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR5, NULL, 0), \ |
319 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR6, NULL, 0), \ |
320 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR7, NULL, 0), \ |
321 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR8, NULL, 0), \ |
322 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR9, NULL, 0), \ |
323 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR10, NULL, 0), \ |
324 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT1, NULL, 0), \ |
325 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT2, NULL, 0), \ |
326 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT3, NULL, 0), \ |
327 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT4, NULL, 0), \ |
328 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT5, NULL, 0), \ |
329 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT6, NULL, 0), \ |
330 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT7, NULL, 0), \ |
331 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT8, NULL, 0), \ |
332 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT9, NULL, 0), \ |
333 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT10, NULL, 0), \ |
334 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT1, NULL, 0), \ |
335 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT2, NULL, 0), \ |
336 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT3, NULL, 0), \ |
337 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT4, NULL, 0), \ |
338 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT5, NULL, 0), \ |
339 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT6, NULL, 0), \ |
340 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT7, NULL, 0), \ |
341 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT8, NULL, 0), \ |
342 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT9, NULL, 0), |
343 | | #endif |
344 | | |
345 | | #define RSA_KEY_TYPES() \ |
346 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_N, NULL, 0), \ |
347 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_E, NULL, 0), \ |
348 | | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_D, NULL, 0), \ |
349 | | RSA_KEY_MP_TYPES() |
350 | | |
351 | | /* |
352 | | * This provider can export everything in an RSA key, so we use the exact |
353 | | * same type description for export as for import. Other providers might |
354 | | * choose to import full keys, but only export the public parts, and will |
355 | | * therefore have the importkey_types and importkey_types functions return |
356 | | * different arrays. |
357 | | */ |
358 | | static const OSSL_PARAM rsa_key_types[] = { |
359 | | RSA_KEY_TYPES() |
360 | | OSSL_PARAM_END |
361 | | }; |
362 | | /* |
363 | | * We lied about the amount of factors, exponents and coefficients, the |
364 | | * export and import functions can really deal with an infinite amount |
365 | | * of these numbers. However, RSA keys with too many primes are futile, |
366 | | * so we at least pretend to have some limits. |
367 | | */ |
368 | | |
369 | | static const OSSL_PARAM *rsa_imexport_types(int selection) |
370 | 0 | { |
371 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) |
372 | 0 | return rsa_key_types; |
373 | 0 | return NULL; |
374 | 0 | } |
375 | | |
376 | | static const OSSL_PARAM *rsa_import_types(int selection) |
377 | 0 | { |
378 | 0 | return rsa_imexport_types(selection); |
379 | 0 | } |
380 | | |
381 | | static const OSSL_PARAM *rsa_export_types(int selection) |
382 | 0 | { |
383 | 0 | return rsa_imexport_types(selection); |
384 | 0 | } |
385 | | |
386 | | static int rsa_get_params(void *key, OSSL_PARAM params[]) |
387 | 51.3k | { |
388 | 51.3k | RSA *rsa = key; |
389 | 51.3k | const RSA_PSS_PARAMS_30 *pss_params = ossl_rsa_get0_pss_params_30(rsa); |
390 | 51.3k | int rsa_type = RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK); |
391 | 51.3k | OSSL_PARAM *p; |
392 | 51.3k | int empty = RSA_get0_n(rsa) == NULL; |
393 | | |
394 | 51.3k | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL |
395 | 51.3k | && (empty || !OSSL_PARAM_set_int(p, RSA_bits(rsa)))) |
396 | 0 | return 0; |
397 | 51.3k | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL |
398 | 51.3k | && (empty || !OSSL_PARAM_set_int(p, RSA_security_bits(rsa)))) |
399 | 0 | return 0; |
400 | 51.3k | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL |
401 | 51.3k | && (empty || !OSSL_PARAM_set_int(p, RSA_size(rsa)))) |
402 | 0 | return 0; |
403 | 51.3k | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_CATEGORY)) != NULL) |
404 | 51.3k | if (!OSSL_PARAM_set_int(p, 0)) |
405 | 0 | return 0; |
406 | | |
407 | | /* |
408 | | * For restricted RSA-PSS keys, we ignore the default digest request. |
409 | | * With RSA-OAEP keys, this may need to be amended. |
410 | | */ |
411 | 51.3k | if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL |
412 | 0 | && (rsa_type != RSA_FLAG_TYPE_RSASSAPSS |
413 | 0 | || ossl_rsa_pss_params_30_is_unrestricted(pss_params))) { |
414 | 0 | if (!OSSL_PARAM_set_utf8_string(p, RSA_DEFAULT_MD)) |
415 | 0 | return 0; |
416 | 0 | } |
417 | | |
418 | | /* |
419 | | * For non-RSA-PSS keys, we ignore the mandatory digest request. |
420 | | * With RSA-OAEP keys, this may need to be amended. |
421 | | */ |
422 | 51.3k | if ((p = OSSL_PARAM_locate(params, |
423 | 51.3k | OSSL_PKEY_PARAM_MANDATORY_DIGEST)) |
424 | 51.3k | != NULL |
425 | 0 | && rsa_type == RSA_FLAG_TYPE_RSASSAPSS |
426 | 0 | && !ossl_rsa_pss_params_30_is_unrestricted(pss_params)) { |
427 | 0 | const char *mdname = ossl_rsa_oaeppss_nid2name(ossl_rsa_pss_params_30_hashalg(pss_params)); |
428 | |
|
429 | 0 | if (mdname == NULL || !OSSL_PARAM_set_utf8_string(p, mdname)) |
430 | 0 | return 0; |
431 | 0 | } |
432 | 51.3k | return (rsa_type != RSA_FLAG_TYPE_RSASSAPSS |
433 | 5.64k | || ossl_rsa_pss_params_30_todata(pss_params, NULL, params)) |
434 | 51.3k | && ossl_rsa_todata(rsa, NULL, params, 1); |
435 | 51.3k | } |
436 | | |
437 | | static const OSSL_PARAM rsa_params[] = { |
438 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL), |
439 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL), |
440 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL), |
441 | | OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_CATEGORY, NULL), |
442 | | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_DEFAULT_DIGEST, NULL, 0), |
443 | | RSA_KEY_TYPES() |
444 | | OSSL_PARAM_END |
445 | | }; |
446 | | |
447 | | static const OSSL_PARAM *rsa_gettable_params(void *provctx) |
448 | 0 | { |
449 | 0 | return rsa_params; |
450 | 0 | } |
451 | | |
452 | | static int rsa_validate(const void *keydata, int selection, int checktype) |
453 | 17.5k | { |
454 | 17.5k | const RSA *rsa = keydata; |
455 | 17.5k | int ok = 1; |
456 | | |
457 | 17.5k | if (!ossl_prov_is_running()) |
458 | 0 | return 0; |
459 | | |
460 | 17.5k | if ((selection & RSA_POSSIBLE_SELECTIONS) == 0) |
461 | 0 | return 1; /* nothing to validate */ |
462 | | |
463 | | /* If the whole key is selected, we do a pairwise validation */ |
464 | 17.5k | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) |
465 | 17.5k | == OSSL_KEYMGMT_SELECT_KEYPAIR) { |
466 | 3.96k | ok = ok && ossl_rsa_validate_pairwise(rsa); |
467 | 13.5k | } else { |
468 | 13.5k | if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0) |
469 | 3.96k | ok = ok && ossl_rsa_validate_private(rsa); |
470 | 13.5k | if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) |
471 | 4.78k | ok = ok && ossl_rsa_validate_public(rsa); |
472 | 13.5k | } |
473 | 17.5k | return ok; |
474 | 17.5k | } |
475 | | |
476 | | struct rsa_gen_ctx { |
477 | | OSSL_LIB_CTX *libctx; |
478 | | const char *propq; |
479 | | |
480 | | int rsa_type; |
481 | | |
482 | | size_t nbits; |
483 | | BIGNUM *pub_exp; |
484 | | size_t primes; |
485 | | |
486 | | /* For PSS */ |
487 | | RSA_PSS_PARAMS_30 pss_params; |
488 | | int pss_defaults_set; |
489 | | |
490 | | /* For generation callback */ |
491 | | OSSL_CALLBACK *cb; |
492 | | void *cbarg; |
493 | | |
494 | | #if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS) |
495 | | /* ACVP test parameters */ |
496 | | OSSL_PARAM *acvp_test_params; |
497 | | #endif |
498 | | uint32_t a, b; |
499 | | }; |
500 | | |
501 | | static int rsa_gencb(int p, int n, BN_GENCB *cb) |
502 | 0 | { |
503 | 0 | struct rsa_gen_ctx *gctx = BN_GENCB_get_arg(cb); |
504 | 0 | OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END }; |
505 | |
|
506 | 0 | params[0] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_POTENTIAL, &p); |
507 | 0 | params[1] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_ITERATION, &n); |
508 | 0 | return gctx->cb(params, gctx->cbarg); |
509 | 0 | } |
510 | | |
511 | | static void *gen_init(void *provctx, int selection, int rsa_type, |
512 | | const OSSL_PARAM params[]) |
513 | 0 | { |
514 | 0 | OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(provctx); |
515 | 0 | struct rsa_gen_ctx *gctx = NULL; |
516 | |
|
517 | 0 | if (!ossl_prov_is_running()) |
518 | 0 | return NULL; |
519 | | |
520 | 0 | if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0) |
521 | 0 | return NULL; |
522 | | |
523 | 0 | if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) { |
524 | 0 | gctx->libctx = libctx; |
525 | 0 | if ((gctx->pub_exp = BN_new()) == NULL |
526 | 0 | || !BN_set_word(gctx->pub_exp, RSA_F4)) { |
527 | 0 | goto err; |
528 | 0 | } |
529 | 0 | gctx->nbits = 2048; |
530 | 0 | gctx->primes = RSA_DEFAULT_PRIME_NUM; |
531 | 0 | gctx->rsa_type = rsa_type; |
532 | 0 | } else { |
533 | 0 | goto err; |
534 | 0 | } |
535 | | |
536 | 0 | if (!rsa_gen_set_params(gctx, params)) |
537 | 0 | goto err; |
538 | 0 | return gctx; |
539 | | |
540 | 0 | err: |
541 | 0 | if (gctx != NULL) |
542 | 0 | BN_free(gctx->pub_exp); |
543 | 0 | OPENSSL_free(gctx); |
544 | 0 | return NULL; |
545 | 0 | } |
546 | | |
547 | | static void *rsa_gen_init(void *provctx, int selection, |
548 | | const OSSL_PARAM params[]) |
549 | 0 | { |
550 | 0 | return gen_init(provctx, selection, RSA_FLAG_TYPE_RSA, params); |
551 | 0 | } |
552 | | |
553 | | static void *rsapss_gen_init(void *provctx, int selection, |
554 | | const OSSL_PARAM params[]) |
555 | 0 | { |
556 | 0 | return gen_init(provctx, selection, RSA_FLAG_TYPE_RSASSAPSS, params); |
557 | 0 | } |
558 | | |
559 | | /* |
560 | | * This function is common for all RSA sub-types, to detect possible |
561 | | * misuse, such as PSS parameters being passed when a plain RSA key |
562 | | * is generated. |
563 | | */ |
564 | | static int rsa_gen_set_params(void *genctx, const OSSL_PARAM params[]) |
565 | 0 | { |
566 | 0 | struct rsa_gen_ctx *gctx = genctx; |
567 | 0 | const OSSL_PARAM *p; |
568 | |
|
569 | 0 | if (ossl_param_is_empty(params)) |
570 | 0 | return 1; |
571 | | |
572 | 0 | if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_BITS)) != NULL) { |
573 | 0 | if (!OSSL_PARAM_get_size_t(p, &gctx->nbits)) |
574 | 0 | return 0; |
575 | 0 | if (gctx->nbits < RSA_MIN_MODULUS_BITS) { |
576 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SIZE_TOO_SMALL); |
577 | 0 | return 0; |
578 | 0 | } |
579 | 0 | } |
580 | 0 | if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_PRIMES)) != NULL |
581 | 0 | && !OSSL_PARAM_get_size_t(p, &gctx->primes)) |
582 | 0 | return 0; |
583 | 0 | if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E)) != NULL |
584 | 0 | && !OSSL_PARAM_get_BN(p, &gctx->pub_exp)) |
585 | 0 | return 0; |
586 | 0 | if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_A)) != NULL) { |
587 | 0 | if (!OSSL_PARAM_get_uint32(p, &gctx->a)) |
588 | 0 | return 0; |
589 | | /* a is an optional value that should be one of (0, 1, 3, 5, 7) */ |
590 | 0 | if (gctx->a != 0 && (gctx->a > 7 || (gctx->a & 1) == 0)) { |
591 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DATA); |
592 | 0 | return 0; |
593 | 0 | } |
594 | 0 | } |
595 | 0 | if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_B)) != NULL) { |
596 | 0 | if (!OSSL_PARAM_get_uint32(p, &gctx->b)) |
597 | 0 | return 0; |
598 | | /* b is an optional value that should be one of (0, 1, 3, 5, 7) */ |
599 | 0 | if (gctx->b != 0 && (gctx->b > 7 || (gctx->b & 1) == 0)) { |
600 | 0 | ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DATA); |
601 | 0 | return 0; |
602 | 0 | } |
603 | 0 | } |
604 | | |
605 | | /* Only attempt to get PSS parameters when generating an RSA-PSS key */ |
606 | 0 | if (gctx->rsa_type == RSA_FLAG_TYPE_RSASSAPSS |
607 | 0 | && !pss_params_fromdata(&gctx->pss_params, &gctx->pss_defaults_set, params, |
608 | 0 | gctx->rsa_type, gctx->libctx)) |
609 | 0 | return 0; |
610 | | #if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS) |
611 | | /* Any ACVP test related parameters are copied into a params[] */ |
612 | | if (!ossl_rsa_acvp_test_gen_params_new(&gctx->acvp_test_params, params)) |
613 | | return 0; |
614 | | #endif |
615 | 0 | return 1; |
616 | 0 | } |
617 | | |
618 | | #define rsa_gen_basic \ |
619 | 0 | OSSL_PARAM_size_t(OSSL_PKEY_PARAM_RSA_BITS, NULL), \ |
620 | 0 | OSSL_PARAM_size_t(OSSL_PKEY_PARAM_RSA_PRIMES, NULL), \ |
621 | 0 | OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_E, NULL, 0), \ |
622 | 0 | OSSL_PARAM_uint32(OSSL_PKEY_PARAM_RSA_A, NULL), \ |
623 | 0 | OSSL_PARAM_uint32(OSSL_PKEY_PARAM_RSA_B, NULL) |
624 | | /* |
625 | | * The following must be kept in sync with ossl_rsa_pss_params_30_fromdata() |
626 | | * in crypto/rsa/rsa_backend.c |
627 | | */ |
628 | | #define rsa_gen_pss \ |
629 | 0 | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_RSA_DIGEST, NULL, 0), \ |
630 | 0 | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_RSA_DIGEST_PROPS, NULL, 0), \ |
631 | 0 | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_RSA_MASKGENFUNC, NULL, 0), \ |
632 | 0 | OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_RSA_MGF1_DIGEST, NULL, 0), \ |
633 | 0 | OSSL_PARAM_int(OSSL_PKEY_PARAM_RSA_PSS_SALTLEN, NULL) |
634 | | |
635 | | static const OSSL_PARAM *rsa_gen_settable_params(ossl_unused void *genctx, |
636 | | ossl_unused void *provctx) |
637 | 0 | { |
638 | 0 | static const OSSL_PARAM settable[] = { |
639 | 0 | rsa_gen_basic, |
640 | 0 | OSSL_PARAM_END |
641 | 0 | }; |
642 | |
|
643 | 0 | return settable; |
644 | 0 | } |
645 | | |
646 | | static const OSSL_PARAM *rsapss_gen_settable_params(ossl_unused void *genctx, |
647 | | ossl_unused void *provctx) |
648 | 0 | { |
649 | 0 | static const OSSL_PARAM settable[] = { |
650 | 0 | rsa_gen_basic, |
651 | 0 | rsa_gen_pss, |
652 | 0 | OSSL_PARAM_END |
653 | 0 | }; |
654 | |
|
655 | 0 | return settable; |
656 | 0 | } |
657 | | |
658 | | #ifdef FIPS_MODULE |
659 | | static int rsa_gen_get_params(void *genctx, OSSL_PARAM params[]) |
660 | | { |
661 | | struct rsa_gen_ctx *gctx = genctx; |
662 | | struct keymgmt_fips_gen_get_params_st p; |
663 | | int approved = 1; |
664 | | |
665 | | if (gctx == NULL || !keymgmt_fips_gen_get_params_decoder(params, &p)) |
666 | | return 0; |
667 | | #ifndef OPENSSL_NO_ACVP_TESTS |
668 | | approved = gctx->acvp_test_params == NULL; |
669 | | #endif |
670 | | if (!OSSL_FIPS_IND_GET_PARAM_CONDITIONAL(p.ind, approved)) |
671 | | return 0; |
672 | | return 1; |
673 | | } |
674 | | #endif |
675 | | |
676 | | static void *rsa_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg) |
677 | 0 | { |
678 | 0 | struct rsa_gen_ctx *gctx = genctx; |
679 | 0 | RSA *rsa = NULL, *rsa_tmp = NULL; |
680 | 0 | BN_GENCB *gencb = NULL; |
681 | |
|
682 | 0 | if (!ossl_prov_is_running() || gctx == NULL) |
683 | 0 | return NULL; |
684 | | |
685 | 0 | switch (gctx->rsa_type) { |
686 | 0 | case RSA_FLAG_TYPE_RSA: |
687 | | /* For plain RSA keys, PSS parameters must not be set */ |
688 | 0 | if (!ossl_rsa_pss_params_30_is_unrestricted(&gctx->pss_params)) |
689 | 0 | goto err; |
690 | 0 | break; |
691 | 0 | case RSA_FLAG_TYPE_RSASSAPSS: |
692 | | /* |
693 | | * For plain RSA-PSS keys, PSS parameters may be set but don't have |
694 | | * to, so not check. |
695 | | */ |
696 | 0 | break; |
697 | 0 | default: |
698 | | /* Unsupported RSA key sub-type... */ |
699 | 0 | return NULL; |
700 | 0 | } |
701 | | |
702 | 0 | if ((rsa_tmp = ossl_rsa_new_with_ctx(gctx->libctx)) == NULL) |
703 | 0 | return NULL; |
704 | | |
705 | 0 | gctx->cb = osslcb; |
706 | 0 | gctx->cbarg = cbarg; |
707 | 0 | gencb = BN_GENCB_new(); |
708 | 0 | if (gencb != NULL) |
709 | 0 | BN_GENCB_set(gencb, rsa_gencb, genctx); |
710 | |
|
711 | | #if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS) |
712 | | if (gctx->acvp_test_params != NULL) { |
713 | | if (!ossl_rsa_acvp_test_set_params(rsa_tmp, gctx->acvp_test_params)) |
714 | | goto err; |
715 | | } |
716 | | #endif |
717 | |
|
718 | 0 | if (!ossl_rsa_generate_multi_prime_key(rsa_tmp, |
719 | 0 | (int)gctx->nbits, (int)gctx->primes, |
720 | 0 | gctx->pub_exp, gencb, |
721 | 0 | gctx->a, gctx->b)) |
722 | 0 | goto err; |
723 | | |
724 | 0 | if (!ossl_rsa_pss_params_30_copy(ossl_rsa_get0_pss_params_30(rsa_tmp), |
725 | 0 | &gctx->pss_params)) |
726 | 0 | goto err; |
727 | | |
728 | 0 | RSA_clear_flags(rsa_tmp, RSA_FLAG_TYPE_MASK); |
729 | 0 | RSA_set_flags(rsa_tmp, gctx->rsa_type); |
730 | |
|
731 | 0 | rsa = rsa_tmp; |
732 | 0 | rsa_tmp = NULL; |
733 | 0 | err: |
734 | 0 | BN_GENCB_free(gencb); |
735 | 0 | RSA_free(rsa_tmp); |
736 | 0 | return rsa; |
737 | 0 | } |
738 | | |
739 | | static void rsa_gen_cleanup(void *genctx) |
740 | 0 | { |
741 | 0 | struct rsa_gen_ctx *gctx = genctx; |
742 | |
|
743 | 0 | if (gctx == NULL) |
744 | 0 | return; |
745 | | #if defined(FIPS_MODULE) && !defined(OPENSSL_NO_ACVP_TESTS) |
746 | | ossl_rsa_acvp_test_gen_params_free(gctx->acvp_test_params); |
747 | | gctx->acvp_test_params = NULL; |
748 | | #endif |
749 | 0 | BN_clear_free(gctx->pub_exp); |
750 | 0 | OPENSSL_free(gctx); |
751 | 0 | } |
752 | | |
753 | | static void *common_load(const void *reference, size_t reference_sz, |
754 | | int expected_rsa_type) |
755 | 176k | { |
756 | 176k | RSA *rsa = NULL; |
757 | | |
758 | 176k | if (ossl_prov_is_running() && reference_sz == sizeof(rsa)) { |
759 | | /* The contents of the reference is the address to our object */ |
760 | 176k | rsa = *(RSA **)reference; |
761 | | |
762 | 176k | if (RSA_test_flags(rsa, RSA_FLAG_TYPE_MASK) != expected_rsa_type) |
763 | 0 | return NULL; |
764 | | |
765 | | /* We grabbed, so we detach it */ |
766 | 176k | *(RSA **)reference = NULL; |
767 | 176k | return rsa; |
768 | 176k | } |
769 | 0 | return NULL; |
770 | 176k | } |
771 | | |
772 | | static void *rsa_load(const void *reference, size_t reference_sz) |
773 | 154k | { |
774 | 154k | return common_load(reference, reference_sz, RSA_FLAG_TYPE_RSA); |
775 | 154k | } |
776 | | |
777 | | static void *rsapss_load(const void *reference, size_t reference_sz) |
778 | 21.9k | { |
779 | 21.9k | return common_load(reference, reference_sz, RSA_FLAG_TYPE_RSASSAPSS); |
780 | 21.9k | } |
781 | | |
782 | | static void *rsa_dup(const void *keydata_from, int selection) |
783 | 4.78k | { |
784 | 4.78k | if (ossl_prov_is_running() |
785 | | /* do not allow creating empty keys by duplication */ |
786 | 4.78k | && (selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0) |
787 | 4.78k | return ossl_rsa_dup(keydata_from, selection); |
788 | 0 | return NULL; |
789 | 4.78k | } |
790 | | |
791 | | /* For any RSA key, we use the "RSA" algorithms regardless of sub-type. */ |
792 | | static const char *rsa_query_operation_name(int operation_id) |
793 | 885 | { |
794 | 885 | return "RSA"; |
795 | 885 | } |
796 | | |
797 | | const OSSL_DISPATCH ossl_rsa_keymgmt_functions[] = { |
798 | | { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))rsa_newdata }, |
799 | | { OSSL_FUNC_KEYMGMT_NEW_EX, (void (*)(void))rsa_newdata_ex }, |
800 | | { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))rsa_gen_init }, |
801 | | { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, |
802 | | (void (*)(void))rsa_gen_set_params }, |
803 | | { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, |
804 | | (void (*)(void))rsa_gen_settable_params }, |
805 | | { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))rsa_gen }, |
806 | | { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))rsa_gen_cleanup }, |
807 | | { OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))rsa_load }, |
808 | | { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))rsa_freedata }, |
809 | | { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))rsa_get_params }, |
810 | | { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*)(void))rsa_gettable_params }, |
811 | | { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))rsa_has }, |
812 | | { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))rsa_match }, |
813 | | { OSSL_FUNC_KEYMGMT_VALIDATE, (void (*)(void))rsa_validate }, |
814 | | { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))rsa_import }, |
815 | | { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))rsa_import_types }, |
816 | | { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))rsa_export }, |
817 | | { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))rsa_export_types }, |
818 | | { OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))rsa_dup }, |
819 | | OSSL_KEYMGMT_FIPS_GEN_DISPATCH_END(rsa_gen_get_params) |
820 | | }; |
821 | | |
822 | | const OSSL_DISPATCH ossl_rsapss_keymgmt_functions[] = { |
823 | | { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))rsapss_newdata }, |
824 | | { OSSL_FUNC_KEYMGMT_NEW_EX, (void (*)(void))rsapss_newdata_ex }, |
825 | | { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))rsapss_gen_init }, |
826 | | { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS, (void (*)(void))rsa_gen_set_params }, |
827 | | { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS, |
828 | | (void (*)(void))rsapss_gen_settable_params }, |
829 | | { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))rsa_gen }, |
830 | | { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))rsa_gen_cleanup }, |
831 | | { OSSL_FUNC_KEYMGMT_LOAD, (void (*)(void))rsapss_load }, |
832 | | { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))rsa_freedata }, |
833 | | { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*)(void))rsa_get_params }, |
834 | | { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*)(void))rsa_gettable_params }, |
835 | | { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))rsa_has }, |
836 | | { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))rsa_match }, |
837 | | { OSSL_FUNC_KEYMGMT_VALIDATE, (void (*)(void))rsa_validate }, |
838 | | { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))rsa_import }, |
839 | | { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))rsa_import_types }, |
840 | | { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))rsa_export }, |
841 | | { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))rsa_export_types }, |
842 | | { OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME, |
843 | | (void (*)(void))rsa_query_operation_name }, |
844 | | { OSSL_FUNC_KEYMGMT_DUP, (void (*)(void))rsa_dup }, |
845 | | OSSL_KEYMGMT_FIPS_GEN_DISPATCH_END(rsa_gen_get_params) |
846 | | }; |