PROV: Add RSA functionality for key generation
[openssl.git] / providers / implementations / keymgmt / rsa_kmgmt.c
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 /*
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_numbers.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/params.h>
23 #include <openssl/types.h>
24 #include "internal/param_build.h"
25 #include "prov/implementations.h"
26 #include "prov/providercommon.h"
27 #include "prov/provider_ctx.h"
28 #include "crypto/rsa.h"
29
30 static OSSL_OP_keymgmt_new_fn rsa_newdata;
31 static OSSL_OP_keymgmt_gen_init_fn rsa_gen_init;
32 static OSSL_OP_keymgmt_gen_set_params_fn rsa_gen_set_params;
33 static OSSL_OP_keymgmt_gen_settable_params_fn rsa_gen_settable_params;
34 static OSSL_OP_keymgmt_gen_fn rsa_gen;
35 static OSSL_OP_keymgmt_gen_cleanup_fn rsa_gen_cleanup;
36 static OSSL_OP_keymgmt_free_fn rsa_freedata;
37 static OSSL_OP_keymgmt_get_params_fn rsa_get_params;
38 static OSSL_OP_keymgmt_gettable_params_fn rsa_gettable_params;
39 static OSSL_OP_keymgmt_has_fn rsa_has;
40 static OSSL_OP_keymgmt_match_fn rsa_match;
41 static OSSL_OP_keymgmt_validate_fn rsa_validate;
42 static OSSL_OP_keymgmt_import_fn rsa_import;
43 static OSSL_OP_keymgmt_import_types_fn rsa_import_types;
44 static OSSL_OP_keymgmt_export_fn rsa_export;
45 static OSSL_OP_keymgmt_export_types_fn rsa_export_types;
46
47 #define RSA_DEFAULT_MD "SHA256"
48 #define RSA_POSSIBLE_SELECTIONS                 \
49     (OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS)
50
51 DEFINE_STACK_OF(BIGNUM)
52 DEFINE_SPECIAL_STACK_OF_CONST(BIGNUM_const, BIGNUM)
53
54 static int collect_numbers(STACK_OF(BIGNUM) *numbers,
55                            const OSSL_PARAM params[], const char *key)
56 {
57     const OSSL_PARAM *p = NULL;
58
59     if (numbers == NULL)
60         return 0;
61
62     for (p = params; (p = OSSL_PARAM_locate_const(p, key)) != NULL; p++) {
63         BIGNUM *tmp = NULL;
64
65         if (!OSSL_PARAM_get_BN(p, &tmp))
66             return 0;
67         sk_BIGNUM_push(numbers, tmp);
68     }
69
70     return 1;
71 }
72
73 static int params_to_key(RSA *rsa, const OSSL_PARAM params[])
74 {
75     const OSSL_PARAM *param_n, *param_e,  *param_d;
76     BIGNUM *n = NULL, *e = NULL, *d = NULL;
77     STACK_OF(BIGNUM) *factors = NULL, *exps = NULL, *coeffs = NULL;
78     int is_private = 0;
79
80     if (rsa == NULL)
81         return 0;
82
83     param_n = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_N);
84     param_e = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E);
85     param_d = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_D);
86
87     if ((param_n != NULL && !OSSL_PARAM_get_BN(param_n, &n))
88         || (param_e != NULL && !OSSL_PARAM_get_BN(param_e, &e))
89         || (param_d != NULL && !OSSL_PARAM_get_BN(param_d, &d)))
90         goto err;
91
92     is_private = (d != NULL);
93
94     if (!RSA_set0_key(rsa, n, e, d))
95         goto err;
96     n = e = d = NULL;
97
98     if (is_private) {
99         if (!collect_numbers(factors = sk_BIGNUM_new_null(), params,
100                              OSSL_PKEY_PARAM_RSA_FACTOR)
101             || !collect_numbers(exps = sk_BIGNUM_new_null(), params,
102                                 OSSL_PKEY_PARAM_RSA_EXPONENT)
103             || !collect_numbers(coeffs = sk_BIGNUM_new_null(), params,
104                                 OSSL_PKEY_PARAM_RSA_COEFFICIENT))
105             goto err;
106
107         /* It's ok if this private key just has n, e and d */
108         if (sk_BIGNUM_num(factors) != 0
109             && !rsa_set0_all_params(rsa, factors, exps, coeffs))
110             goto err;
111     }
112
113     sk_BIGNUM_free(factors);
114     sk_BIGNUM_free(exps);
115     sk_BIGNUM_free(coeffs);
116     return 1;
117
118  err:
119     BN_free(n);
120     BN_free(e);
121     BN_free(d);
122     sk_BIGNUM_pop_free(factors, BN_free);
123     sk_BIGNUM_pop_free(exps, BN_free);
124     sk_BIGNUM_pop_free(coeffs, BN_free);
125     return 0;
126 }
127
128 static int export_numbers(OSSL_PARAM_BLD *tmpl, const char *key,
129                           STACK_OF(BIGNUM_const) *numbers)
130 {
131     int i, nnum;
132
133     if (numbers == NULL)
134         return 0;
135
136     nnum = sk_BIGNUM_const_num(numbers);
137
138     for (i = 0; i < nnum; i++) {
139         if (!ossl_param_bld_push_BN(tmpl, key,
140                                     sk_BIGNUM_const_value(numbers, i)))
141             return 0;
142     }
143
144     return 1;
145 }
146
147 static int key_to_params(RSA *rsa, OSSL_PARAM_BLD *tmpl)
148 {
149     int ret = 0;
150     const BIGNUM *rsa_d = NULL, *rsa_n = NULL, *rsa_e = NULL;
151     STACK_OF(BIGNUM_const) *factors = sk_BIGNUM_const_new_null();
152     STACK_OF(BIGNUM_const) *exps = sk_BIGNUM_const_new_null();
153     STACK_OF(BIGNUM_const) *coeffs = sk_BIGNUM_const_new_null();
154
155     if (rsa == NULL || factors == NULL || exps == NULL || coeffs == NULL)
156         goto err;
157
158     RSA_get0_key(rsa, &rsa_n, &rsa_e, &rsa_d);
159     rsa_get0_all_params(rsa, factors, exps, coeffs);
160
161     if (rsa_n != NULL
162         && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_N, rsa_n))
163         goto err;
164     if (rsa_e != NULL
165         && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_E, rsa_e))
166         goto err;
167     if (rsa_d != NULL
168         && !ossl_param_bld_push_BN(tmpl, OSSL_PKEY_PARAM_RSA_D, rsa_d))
169         goto err;
170
171     if (!export_numbers(tmpl, OSSL_PKEY_PARAM_RSA_FACTOR, factors)
172         || !export_numbers(tmpl, OSSL_PKEY_PARAM_RSA_EXPONENT, exps)
173         || !export_numbers(tmpl, OSSL_PKEY_PARAM_RSA_COEFFICIENT, coeffs))
174         goto err;
175
176     ret = 1;
177  err:
178     sk_BIGNUM_const_free(factors);
179     sk_BIGNUM_const_free(exps);
180     sk_BIGNUM_const_free(coeffs);
181     return ret;
182 }
183
184 static void *rsa_newdata(void *provctx)
185 {
186     OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
187
188     return rsa_new_with_ctx(libctx);
189 }
190
191 static void rsa_freedata(void *keydata)
192 {
193     RSA_free(keydata);
194 }
195
196 static int rsa_has(void *keydata, int selection)
197 {
198     RSA *rsa = keydata;
199     int ok = 0;
200
201     if ((selection & RSA_POSSIBLE_SELECTIONS) != 0)
202         ok = 1;
203
204     ok = ok && (RSA_get0_e(rsa) != NULL);
205     if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
206         ok = ok && (RSA_get0_n(rsa) != NULL);
207     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
208         ok = ok && (RSA_get0_d(rsa) != NULL);
209     return ok;
210 }
211
212 static int rsa_match(const void *keydata1, const void *keydata2, int selection)
213 {
214     const RSA *rsa1 = keydata1;
215     const RSA *rsa2 = keydata2;
216     int ok = 1;
217
218     /* There is always an |e| */
219     ok = ok && BN_cmp(RSA_get0_e(rsa1), RSA_get0_e(rsa2)) == 0;
220     if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
221         ok = ok && BN_cmp(RSA_get0_n(rsa1), RSA_get0_n(rsa2)) == 0;
222     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
223         ok = ok && BN_cmp(RSA_get0_d(rsa1), RSA_get0_d(rsa2)) == 0;
224     return ok;
225 }
226
227 static int rsa_import(void *keydata, int selection, const OSSL_PARAM params[])
228 {
229     RSA *rsa = keydata;
230     int ok = 1;
231
232     if (rsa == NULL)
233         return 0;
234
235     /* TODO(3.0) PSS and OAEP should bring on parameters */
236
237     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
238         ok = ok && params_to_key(rsa, params);
239
240     return ok;
241 }
242
243 static int rsa_export(void *keydata, int selection,
244                       OSSL_CALLBACK *param_callback, void *cbarg)
245 {
246     RSA *rsa = keydata;
247     OSSL_PARAM_BLD tmpl;
248     OSSL_PARAM *params = NULL;
249     int ok = 1;
250
251     if (rsa == NULL)
252         return 0;
253
254     /* TODO(3.0) PSS and OAEP should bring on parameters */
255
256     ossl_param_bld_init(&tmpl);
257
258     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
259         ok = ok && key_to_params(rsa, &tmpl);
260
261     if (!ok
262         || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
263         return 0;
264
265     ok = param_callback(params, cbarg);
266     ossl_param_bld_free(params);
267     return ok;
268 }
269
270 /*
271  * This provider can export everything in an RSA key, so we use the exact
272  * same type description for export as for import.  Other providers might
273  * choose to import full keys, but only export the public parts, and will
274  * therefore have the importkey_types and importkey_types functions return
275  * different arrays.
276  */
277 static const OSSL_PARAM rsa_key_types[] = {
278     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_N, NULL, 0),
279     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_E, NULL, 0),
280     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_D, NULL, 0),
281     /* We tolerate up to 10 factors... */
282     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
283     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
284     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
285     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
286     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
287     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
288     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
289     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
290     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
291     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
292     /* ..., up to 10 CRT exponents... */
293     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
294     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
295     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
296     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
297     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
298     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
299     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
300     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
301     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
302     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
303     /* ..., and up to 9 CRT coefficients */
304     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
305     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
306     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
307     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
308     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
309     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
310     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
311     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
312     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
313 };
314 /*
315  * We lied about the amount of factors, exponents and coefficients, the
316  * export and import functions can really deal with an infinite amount
317  * of these numbers.  However, RSA keys with too many primes are futile,
318  * so we at least pretend to have some limits.
319  */
320
321 static const OSSL_PARAM *rsa_imexport_types(int selection)
322 {
323     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
324         return rsa_key_types;
325     return NULL;
326 }
327
328 static const OSSL_PARAM *rsa_import_types(int selection)
329 {
330     return rsa_imexport_types(selection);
331 }
332
333
334 static const OSSL_PARAM *rsa_export_types(int selection)
335 {
336     return rsa_imexport_types(selection);
337 }
338
339 static int rsa_get_params(void *key, OSSL_PARAM params[])
340 {
341     RSA *rsa = key;
342     OSSL_PARAM *p;
343
344     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL
345         && !OSSL_PARAM_set_int(p, RSA_bits(rsa)))
346         return 0;
347     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL
348         && !OSSL_PARAM_set_int(p, RSA_security_bits(rsa)))
349         return 0;
350     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL
351         && !OSSL_PARAM_set_int(p, RSA_size(rsa)))
352         return 0;
353
354 # if 0  /* TODO(3.0): PSS support pending */
355     if ((p = OSSL_PARAM_locate(params,
356                                OSSL_PKEY_PARAM_MANDATORY_DIGEST)) != NULL
357         && RSA_get0_pss_params(rsa) != NULL) {
358         const EVP_MD *md, *mgf1md;
359         int min_saltlen;
360
361         if (!rsa_pss_get_param(RSA_get0_pss_params(rsa),
362                                &md, &mgf1md, &min_saltlen)) {
363             ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
364             return 0;
365         }
366         if (!OSSL_PARAM_set_utf8_string(p, EVP_MD_name(md)))
367             return 0;
368     }
369 #endif
370     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
371 /* TODO(3.0): PSS support pending */
372 #if 0
373             && RSA_get0_pss_params(rsa) == NULL
374 #endif
375             ) {
376         if (!OSSL_PARAM_set_utf8_string(p, RSA_DEFAULT_MD))
377             return 0;
378     }
379
380     return 1;
381 }
382
383 static const OSSL_PARAM rsa_params[] = {
384     OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL),
385     OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
386     OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL),
387     OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_DEFAULT_DIGEST, NULL, 0),
388     OSSL_PARAM_END
389 };
390
391 static const OSSL_PARAM *rsa_gettable_params(void)
392 {
393     return rsa_params;
394 }
395
396 static int rsa_validate(void *keydata, int selection)
397 {
398     RSA *rsa = keydata;
399     int ok = 0;
400
401     if ((selection & RSA_POSSIBLE_SELECTIONS) != 0)
402         ok = 1;
403
404     /* If the whole key is selected, we do a pairwise validation */
405     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR)
406         == OSSL_KEYMGMT_SELECT_KEYPAIR) {
407         ok = ok && rsa_validate_pairwise(rsa);
408     } else {
409         if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
410             ok = ok && rsa_validate_private(rsa);
411         if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
412             ok = ok && rsa_validate_public(rsa);
413     }
414     return ok;
415 }
416
417 struct rsa_gen_ctx {
418     OPENSSL_CTX *libctx;
419
420     size_t nbits;
421     BIGNUM *pub_exp;
422     size_t primes;
423
424     /* For generation callback */
425     OSSL_CALLBACK *cb;
426     void *cbarg;
427 };
428
429 static int rsa_gencb(int p, int n, BN_GENCB *cb)
430 {
431     struct rsa_gen_ctx *gctx = BN_GENCB_get_arg(cb);
432     OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END };
433
434     params[0] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_POTENTIAL, &p);
435     params[1] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_ITERATION, &n);
436
437     return gctx->cb(params, gctx->cbarg);
438 }
439
440 static void *rsa_gen_init(void *provctx, int selection)
441 {
442     OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
443     struct rsa_gen_ctx *gctx = NULL;
444
445     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
446         return NULL;
447
448     if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
449         gctx->libctx = libctx;
450         if ((gctx->pub_exp = BN_new()) == NULL
451             || !BN_set_word(gctx->pub_exp, RSA_F4)) {
452             BN_free(gctx->pub_exp);
453             gctx = NULL;
454         } else {
455             gctx->nbits = 2048;
456             gctx->primes = RSA_DEFAULT_PRIME_NUM;
457         }
458     }
459     return gctx;
460 }
461
462 static int rsa_gen_set_params(void *genctx, const OSSL_PARAM params[])
463 {
464     struct rsa_gen_ctx *gctx = genctx;
465     const OSSL_PARAM *p;
466
467     if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_BITS)) != NULL
468         && !OSSL_PARAM_get_size_t(p, &gctx->nbits))
469         return 0;
470     if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_PRIMES)) != NULL
471         && !OSSL_PARAM_get_size_t(p, &gctx->primes))
472         return 0;
473     if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E)) != NULL
474         && !OSSL_PARAM_get_BN(p, &gctx->pub_exp))
475         return 0;
476     return 1;
477 }
478
479 static const OSSL_PARAM *rsa_gen_settable_params(void *provctx)
480 {
481     static OSSL_PARAM settable[] = {
482         OSSL_PARAM_size_t(OSSL_PKEY_PARAM_RSA_BITS, NULL),
483         OSSL_PARAM_size_t(OSSL_PKEY_PARAM_RSA_PRIMES, NULL),
484         OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_E, NULL, 0),
485         OSSL_PARAM_END
486     };
487
488     return settable;
489 }
490
491 static void *rsa_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
492 {
493     struct rsa_gen_ctx *gctx = genctx;
494     RSA *rsa = NULL;
495     BN_GENCB *gencb = NULL;
496
497     if (gctx == NULL
498         || (rsa = rsa_new_with_ctx(gctx->libctx)) == NULL)
499         return NULL;
500
501     gctx->cb = osslcb;
502     gctx->cbarg = cbarg;
503     gencb = BN_GENCB_new();
504     if (gencb != NULL)
505         BN_GENCB_set(gencb, rsa_gencb, genctx);
506
507     if (!RSA_generate_multi_prime_key(rsa, (int)gctx->nbits, (int)gctx->primes,
508                                       gctx->pub_exp, gencb)) {
509         RSA_free(rsa);
510         rsa = NULL;
511     }
512
513     BN_GENCB_free(gencb);
514
515     return rsa;
516 }
517
518 static void rsa_gen_cleanup(void *genctx)
519 {
520     struct rsa_gen_ctx *gctx = genctx;
521
522     if (gctx == NULL)
523         return;
524
525     BN_clear_free(gctx->pub_exp);
526     OPENSSL_free(gctx);
527 }
528
529 const OSSL_DISPATCH rsa_keymgmt_functions[] = {
530     { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))rsa_newdata },
531     { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))rsa_gen_init },
532     { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS,
533       (void (*)(void))rsa_gen_set_params },
534     { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
535       (void (*)(void))rsa_gen_settable_params },
536     { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))rsa_gen },
537     { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))rsa_gen_cleanup },
538     { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))rsa_freedata },
539     { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))rsa_get_params },
540     { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))rsa_gettable_params },
541     { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))rsa_has },
542     { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))rsa_match },
543     { OSSL_FUNC_KEYMGMT_VALIDATE, (void (*)(void))rsa_validate },
544     { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))rsa_import },
545     { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))rsa_import_types },
546     { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))rsa_export },
547     { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))rsa_export_types },
548     { 0, NULL }
549 };