EVP: Clarify the states of an EVP_PKEY
[oweals/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 (rsa != NULL) {
202         if ((selection & RSA_POSSIBLE_SELECTIONS) != 0)
203             ok = 1;
204
205         if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0)
206             ok = ok && 0;     /* This will change with PSS and OAEP */
207         if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
208             ok = ok && (RSA_get0_e(rsa) != NULL);
209         if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
210             ok = ok && (RSA_get0_n(rsa) != NULL);
211         if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
212             ok = ok && (RSA_get0_d(rsa) != NULL);
213     }
214     return ok;
215 }
216
217 static int rsa_match(const void *keydata1, const void *keydata2, int selection)
218 {
219     const RSA *rsa1 = keydata1;
220     const RSA *rsa2 = keydata2;
221     int ok = 1;
222
223     /* There is always an |e| */
224     ok = ok && BN_cmp(RSA_get0_e(rsa1), RSA_get0_e(rsa2)) == 0;
225     if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
226         ok = ok && BN_cmp(RSA_get0_n(rsa1), RSA_get0_n(rsa2)) == 0;
227     if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
228         ok = ok && BN_cmp(RSA_get0_d(rsa1), RSA_get0_d(rsa2)) == 0;
229     return ok;
230 }
231
232 static int rsa_import(void *keydata, int selection, const OSSL_PARAM params[])
233 {
234     RSA *rsa = keydata;
235     int ok = 1;
236
237     if (rsa == NULL)
238         return 0;
239
240     /* TODO(3.0) PSS and OAEP should bring on parameters */
241
242     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
243         ok = ok && params_to_key(rsa, params);
244
245     return ok;
246 }
247
248 static int rsa_export(void *keydata, int selection,
249                       OSSL_CALLBACK *param_callback, void *cbarg)
250 {
251     RSA *rsa = keydata;
252     OSSL_PARAM_BLD tmpl;
253     OSSL_PARAM *params = NULL;
254     int ok = 1;
255
256     if (rsa == NULL)
257         return 0;
258
259     /* TODO(3.0) PSS and OAEP should bring on parameters */
260
261     ossl_param_bld_init(&tmpl);
262
263     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
264         ok = ok && key_to_params(rsa, &tmpl);
265
266     if (!ok
267         || (params = ossl_param_bld_to_param(&tmpl)) == NULL)
268         return 0;
269
270     ok = param_callback(params, cbarg);
271     ossl_param_bld_free(params);
272     return ok;
273 }
274
275 /*
276  * This provider can export everything in an RSA key, so we use the exact
277  * same type description for export as for import.  Other providers might
278  * choose to import full keys, but only export the public parts, and will
279  * therefore have the importkey_types and importkey_types functions return
280  * different arrays.
281  */
282 static const OSSL_PARAM rsa_key_types[] = {
283     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_N, NULL, 0),
284     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_E, NULL, 0),
285     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_D, NULL, 0),
286     /* We tolerate up to 10 factors... */
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     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
293     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
294     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
295     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
296     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_FACTOR, NULL, 0),
297     /* ..., up to 10 CRT exponents... */
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     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
304     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
305     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
306     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
307     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_EXPONENT, NULL, 0),
308     /* ..., and up to 9 CRT coefficients */
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     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
314     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
315     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
316     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
317     OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_COEFFICIENT, NULL, 0),
318 };
319 /*
320  * We lied about the amount of factors, exponents and coefficients, the
321  * export and import functions can really deal with an infinite amount
322  * of these numbers.  However, RSA keys with too many primes are futile,
323  * so we at least pretend to have some limits.
324  */
325
326 static const OSSL_PARAM *rsa_imexport_types(int selection)
327 {
328     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) != 0)
329         return rsa_key_types;
330     return NULL;
331 }
332
333 static const OSSL_PARAM *rsa_import_types(int selection)
334 {
335     return rsa_imexport_types(selection);
336 }
337
338
339 static const OSSL_PARAM *rsa_export_types(int selection)
340 {
341     return rsa_imexport_types(selection);
342 }
343
344 static int rsa_get_params(void *key, OSSL_PARAM params[])
345 {
346     RSA *rsa = key;
347     OSSL_PARAM *p;
348
349     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_BITS)) != NULL
350         && !OSSL_PARAM_set_int(p, RSA_bits(rsa)))
351         return 0;
352     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_SECURITY_BITS)) != NULL
353         && !OSSL_PARAM_set_int(p, RSA_security_bits(rsa)))
354         return 0;
355     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_MAX_SIZE)) != NULL
356         && !OSSL_PARAM_set_int(p, RSA_size(rsa)))
357         return 0;
358
359 # if 0  /* TODO(3.0): PSS support pending */
360     if ((p = OSSL_PARAM_locate(params,
361                                OSSL_PKEY_PARAM_MANDATORY_DIGEST)) != NULL
362         && RSA_get0_pss_params(rsa) != NULL) {
363         const EVP_MD *md, *mgf1md;
364         int min_saltlen;
365
366         if (!rsa_pss_get_param(RSA_get0_pss_params(rsa),
367                                &md, &mgf1md, &min_saltlen)) {
368             ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
369             return 0;
370         }
371         if (!OSSL_PARAM_set_utf8_string(p, EVP_MD_name(md)))
372             return 0;
373     }
374 #endif
375     if ((p = OSSL_PARAM_locate(params, OSSL_PKEY_PARAM_DEFAULT_DIGEST)) != NULL
376 /* TODO(3.0): PSS support pending */
377 #if 0
378             && RSA_get0_pss_params(rsa) == NULL
379 #endif
380             ) {
381         if (!OSSL_PARAM_set_utf8_string(p, RSA_DEFAULT_MD))
382             return 0;
383     }
384
385     return 1;
386 }
387
388 static const OSSL_PARAM rsa_params[] = {
389     OSSL_PARAM_int(OSSL_PKEY_PARAM_BITS, NULL),
390     OSSL_PARAM_int(OSSL_PKEY_PARAM_SECURITY_BITS, NULL),
391     OSSL_PARAM_int(OSSL_PKEY_PARAM_MAX_SIZE, NULL),
392     OSSL_PARAM_utf8_string(OSSL_PKEY_PARAM_DEFAULT_DIGEST, NULL, 0),
393     OSSL_PARAM_END
394 };
395
396 static const OSSL_PARAM *rsa_gettable_params(void)
397 {
398     return rsa_params;
399 }
400
401 static int rsa_validate(void *keydata, int selection)
402 {
403     RSA *rsa = keydata;
404     int ok = 0;
405
406     if ((selection & RSA_POSSIBLE_SELECTIONS) != 0)
407         ok = 1;
408
409     /* If the whole key is selected, we do a pairwise validation */
410     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR)
411         == OSSL_KEYMGMT_SELECT_KEYPAIR) {
412         ok = ok && rsa_validate_pairwise(rsa);
413     } else {
414         if ((selection & OSSL_KEYMGMT_SELECT_PRIVATE_KEY) != 0)
415             ok = ok && rsa_validate_private(rsa);
416         if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0)
417             ok = ok && rsa_validate_public(rsa);
418     }
419     return ok;
420 }
421
422 struct rsa_gen_ctx {
423     OPENSSL_CTX *libctx;
424
425     size_t nbits;
426     BIGNUM *pub_exp;
427     size_t primes;
428
429     /* For generation callback */
430     OSSL_CALLBACK *cb;
431     void *cbarg;
432 };
433
434 static int rsa_gencb(int p, int n, BN_GENCB *cb)
435 {
436     struct rsa_gen_ctx *gctx = BN_GENCB_get_arg(cb);
437     OSSL_PARAM params[] = { OSSL_PARAM_END, OSSL_PARAM_END, OSSL_PARAM_END };
438
439     params[0] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_POTENTIAL, &p);
440     params[1] = OSSL_PARAM_construct_int(OSSL_GEN_PARAM_ITERATION, &n);
441
442     return gctx->cb(params, gctx->cbarg);
443 }
444
445 static void *rsa_gen_init(void *provctx, int selection)
446 {
447     OPENSSL_CTX *libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
448     struct rsa_gen_ctx *gctx = NULL;
449
450     if ((selection & OSSL_KEYMGMT_SELECT_KEYPAIR) == 0)
451         return NULL;
452
453     if ((gctx = OPENSSL_zalloc(sizeof(*gctx))) != NULL) {
454         gctx->libctx = libctx;
455         if ((gctx->pub_exp = BN_new()) == NULL
456             || !BN_set_word(gctx->pub_exp, RSA_F4)) {
457             BN_free(gctx->pub_exp);
458             gctx = NULL;
459         } else {
460             gctx->nbits = 2048;
461             gctx->primes = RSA_DEFAULT_PRIME_NUM;
462         }
463     }
464     return gctx;
465 }
466
467 static int rsa_gen_set_params(void *genctx, const OSSL_PARAM params[])
468 {
469     struct rsa_gen_ctx *gctx = genctx;
470     const OSSL_PARAM *p;
471
472     if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_BITS)) != NULL
473         && !OSSL_PARAM_get_size_t(p, &gctx->nbits))
474         return 0;
475     if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_PRIMES)) != NULL
476         && !OSSL_PARAM_get_size_t(p, &gctx->primes))
477         return 0;
478     if ((p = OSSL_PARAM_locate_const(params, OSSL_PKEY_PARAM_RSA_E)) != NULL
479         && !OSSL_PARAM_get_BN(p, &gctx->pub_exp))
480         return 0;
481     return 1;
482 }
483
484 static const OSSL_PARAM *rsa_gen_settable_params(void *provctx)
485 {
486     static OSSL_PARAM settable[] = {
487         OSSL_PARAM_size_t(OSSL_PKEY_PARAM_RSA_BITS, NULL),
488         OSSL_PARAM_size_t(OSSL_PKEY_PARAM_RSA_PRIMES, NULL),
489         OSSL_PARAM_BN(OSSL_PKEY_PARAM_RSA_E, NULL, 0),
490         OSSL_PARAM_END
491     };
492
493     return settable;
494 }
495
496 static void *rsa_gen(void *genctx, OSSL_CALLBACK *osslcb, void *cbarg)
497 {
498     struct rsa_gen_ctx *gctx = genctx;
499     RSA *rsa = NULL;
500     BN_GENCB *gencb = NULL;
501
502     if (gctx == NULL
503         || (rsa = rsa_new_with_ctx(gctx->libctx)) == NULL)
504         return NULL;
505
506     gctx->cb = osslcb;
507     gctx->cbarg = cbarg;
508     gencb = BN_GENCB_new();
509     if (gencb != NULL)
510         BN_GENCB_set(gencb, rsa_gencb, genctx);
511
512     if (!RSA_generate_multi_prime_key(rsa, (int)gctx->nbits, (int)gctx->primes,
513                                       gctx->pub_exp, gencb)) {
514         RSA_free(rsa);
515         rsa = NULL;
516     }
517
518     BN_GENCB_free(gencb);
519
520     return rsa;
521 }
522
523 static void rsa_gen_cleanup(void *genctx)
524 {
525     struct rsa_gen_ctx *gctx = genctx;
526
527     if (gctx == NULL)
528         return;
529
530     BN_clear_free(gctx->pub_exp);
531     OPENSSL_free(gctx);
532 }
533
534 const OSSL_DISPATCH rsa_keymgmt_functions[] = {
535     { OSSL_FUNC_KEYMGMT_NEW, (void (*)(void))rsa_newdata },
536     { OSSL_FUNC_KEYMGMT_GEN_INIT, (void (*)(void))rsa_gen_init },
537     { OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS,
538       (void (*)(void))rsa_gen_set_params },
539     { OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS,
540       (void (*)(void))rsa_gen_settable_params },
541     { OSSL_FUNC_KEYMGMT_GEN, (void (*)(void))rsa_gen },
542     { OSSL_FUNC_KEYMGMT_GEN_CLEANUP, (void (*)(void))rsa_gen_cleanup },
543     { OSSL_FUNC_KEYMGMT_FREE, (void (*)(void))rsa_freedata },
544     { OSSL_FUNC_KEYMGMT_GET_PARAMS, (void (*) (void))rsa_get_params },
545     { OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS, (void (*) (void))rsa_gettable_params },
546     { OSSL_FUNC_KEYMGMT_HAS, (void (*)(void))rsa_has },
547     { OSSL_FUNC_KEYMGMT_MATCH, (void (*)(void))rsa_match },
548     { OSSL_FUNC_KEYMGMT_VALIDATE, (void (*)(void))rsa_validate },
549     { OSSL_FUNC_KEYMGMT_IMPORT, (void (*)(void))rsa_import },
550     { OSSL_FUNC_KEYMGMT_IMPORT_TYPES, (void (*)(void))rsa_import_types },
551     { OSSL_FUNC_KEYMGMT_EXPORT, (void (*)(void))rsa_export },
552     { OSSL_FUNC_KEYMGMT_EXPORT_TYPES, (void (*)(void))rsa_export_types },
553     { 0, NULL }
554 };