7b534e76ed321ad94af5281ff361c95c387e6734
[openssl.git] / providers / implementations / asymciphers / rsa_enc.c
1 /*
2  * Copyright 2019-2021 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/crypto.h>
17 #include <openssl/evp.h>
18 #include <openssl/core_dispatch.h>
19 #include <openssl/core_names.h>
20 #include <openssl/rsa.h>
21 #include <openssl/params.h>
22 #include <openssl/err.h>
23 #include <openssl/proverr.h>
24 /* Just for SSL_MAX_MASTER_KEY_LENGTH */
25 #include <openssl/ssl.h>
26 #include "internal/constant_time.h"
27 #include "internal/sizes.h"
28 #include "crypto/rsa.h"
29 #include "prov/provider_ctx.h"
30 #include "prov/implementations.h"
31 #include "prov/providercommon.h"
32 #include "prov/securitycheck.h"
33
34 #include <stdlib.h>
35
36 static OSSL_FUNC_asym_cipher_newctx_fn rsa_newctx;
37 static OSSL_FUNC_asym_cipher_encrypt_init_fn rsa_encrypt_init;
38 static OSSL_FUNC_asym_cipher_encrypt_fn rsa_encrypt;
39 static OSSL_FUNC_asym_cipher_decrypt_init_fn rsa_decrypt_init;
40 static OSSL_FUNC_asym_cipher_decrypt_fn rsa_decrypt;
41 static OSSL_FUNC_asym_cipher_freectx_fn rsa_freectx;
42 static OSSL_FUNC_asym_cipher_dupctx_fn rsa_dupctx;
43 static OSSL_FUNC_asym_cipher_get_ctx_params_fn rsa_get_ctx_params;
44 static OSSL_FUNC_asym_cipher_gettable_ctx_params_fn rsa_gettable_ctx_params;
45 static OSSL_FUNC_asym_cipher_set_ctx_params_fn rsa_set_ctx_params;
46 static OSSL_FUNC_asym_cipher_settable_ctx_params_fn rsa_settable_ctx_params;
47
48 static OSSL_ITEM padding_item[] = {
49     { RSA_PKCS1_PADDING,        OSSL_PKEY_RSA_PAD_MODE_PKCSV15 },
50     { RSA_NO_PADDING,           OSSL_PKEY_RSA_PAD_MODE_NONE },
51     { RSA_PKCS1_OAEP_PADDING,   OSSL_PKEY_RSA_PAD_MODE_OAEP }, /* Correct spelling first */
52     { RSA_PKCS1_OAEP_PADDING,   "oeap"   },
53     { RSA_X931_PADDING,         OSSL_PKEY_RSA_PAD_MODE_X931 },
54     { 0,                        NULL     }
55 };
56
57 /*
58  * What's passed as an actual key is defined by the KEYMGMT interface.
59  * We happen to know that our KEYMGMT simply passes RSA structures, so
60  * we use that here too.
61  */
62
63 typedef struct {
64     OSSL_LIB_CTX *libctx;
65     RSA *rsa;
66     int pad_mode;
67     int operation;
68     /* OAEP message digest */
69     EVP_MD *oaep_md;
70     /* message digest for MGF1 */
71     EVP_MD *mgf1_md;
72     /* OAEP label */
73     unsigned char *oaep_label;
74     size_t oaep_labellen;
75     /* TLS padding */
76     unsigned int client_version;
77     unsigned int alt_version;
78 } PROV_RSA_CTX;
79
80 static void *rsa_newctx(void *provctx)
81 {
82     PROV_RSA_CTX *prsactx;
83
84     if (!ossl_prov_is_running())
85         return NULL;
86     prsactx = OPENSSL_zalloc(sizeof(PROV_RSA_CTX));
87     if (prsactx == NULL)
88         return NULL;
89     prsactx->libctx = PROV_LIBCTX_OF(provctx);
90
91     return prsactx;
92 }
93
94 static int rsa_init(void *vprsactx, void *vrsa, const OSSL_PARAM params[],
95                     int operation)
96 {
97     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
98
99     if (!ossl_prov_is_running() || prsactx == NULL || vrsa == NULL)
100         return 0;
101
102     if (!ossl_rsa_check_key(prsactx->libctx, vrsa, operation))
103         return 0;
104
105     if (!RSA_up_ref(vrsa))
106         return 0;
107     RSA_free(prsactx->rsa);
108     prsactx->rsa = vrsa;
109     prsactx->operation = operation;
110
111     switch (RSA_test_flags(prsactx->rsa, RSA_FLAG_TYPE_MASK)) {
112     case RSA_FLAG_TYPE_RSA:
113         prsactx->pad_mode = RSA_PKCS1_PADDING;
114         break;
115     default:
116         /* This should not happen due to the check above */
117         ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
118         return 0;
119     }
120     return rsa_set_ctx_params(prsactx, params);
121 }
122
123 static int rsa_encrypt_init(void *vprsactx, void *vrsa,
124                             const OSSL_PARAM params[])
125 {
126     return rsa_init(vprsactx, vrsa, params, EVP_PKEY_OP_ENCRYPT);
127 }
128
129 static int rsa_decrypt_init(void *vprsactx, void *vrsa,
130                             const OSSL_PARAM params[])
131 {
132     return rsa_init(vprsactx, vrsa, params, EVP_PKEY_OP_DECRYPT);
133 }
134
135 static int rsa_encrypt(void *vprsactx, unsigned char *out, size_t *outlen,
136                        size_t outsize, const unsigned char *in, size_t inlen)
137 {
138     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
139     int ret;
140
141     if (!ossl_prov_is_running())
142         return 0;
143
144     if (out == NULL) {
145         size_t len = RSA_size(prsactx->rsa);
146
147         if (len == 0) {
148             ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
149             return 0;
150         }
151         *outlen = len;
152         return 1;
153     }
154
155     if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING) {
156         int rsasize = RSA_size(prsactx->rsa);
157         unsigned char *tbuf;
158
159         if ((tbuf = OPENSSL_malloc(rsasize)) == NULL) {
160             ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
161             return 0;
162         }
163         if (prsactx->oaep_md == NULL) {
164             OPENSSL_free(tbuf);
165             prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
166             ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
167             return 0;
168         }
169         ret =
170             ossl_rsa_padding_add_PKCS1_OAEP_mgf1_ex(prsactx->libctx, tbuf,
171                                                     rsasize, in, inlen,
172                                                     prsactx->oaep_label,
173                                                     prsactx->oaep_labellen,
174                                                     prsactx->oaep_md,
175                                                     prsactx->mgf1_md);
176
177         if (!ret) {
178             OPENSSL_free(tbuf);
179             return 0;
180         }
181         ret = RSA_public_encrypt(rsasize, tbuf, out, prsactx->rsa,
182                                  RSA_NO_PADDING);
183         OPENSSL_free(tbuf);
184     } else {
185         ret = RSA_public_encrypt(inlen, in, out, prsactx->rsa,
186                                  prsactx->pad_mode);
187     }
188     /* A ret value of 0 is not an error */
189     if (ret < 0)
190         return ret;
191     *outlen = ret;
192     return 1;
193 }
194
195 static int rsa_decrypt(void *vprsactx, unsigned char *out, size_t *outlen,
196                        size_t outsize, const unsigned char *in, size_t inlen)
197 {
198     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
199     int ret;
200     size_t len = RSA_size(prsactx->rsa);
201
202     if (!ossl_prov_is_running())
203         return 0;
204
205     if (prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) {
206         if (out == NULL) {
207             *outlen = SSL_MAX_MASTER_KEY_LENGTH;
208             return 1;
209         }
210         if (outsize < SSL_MAX_MASTER_KEY_LENGTH) {
211             ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH);
212             return 0;
213         }
214     } else {
215         if (out == NULL) {
216             if (len == 0) {
217                 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY);
218                 return 0;
219             }
220             *outlen = len;
221             return 1;
222         }
223
224         if (outsize < len) {
225             ERR_raise(ERR_LIB_PROV, PROV_R_BAD_LENGTH);
226             return 0;
227         }
228     }
229
230     if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING
231             || prsactx->pad_mode == RSA_PKCS1_WITH_TLS_PADDING) {
232         unsigned char *tbuf;
233
234         if ((tbuf = OPENSSL_malloc(len)) == NULL) {
235             ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
236             return 0;
237         }
238         ret = RSA_private_decrypt(inlen, in, tbuf, prsactx->rsa,
239                                   RSA_NO_PADDING);
240         /*
241          * With no padding then, on success ret should be len, otherwise an
242          * error occurred (non-constant time)
243          */
244         if (ret != (int)len) {
245             OPENSSL_free(tbuf);
246             ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_DECRYPT);
247             return 0;
248         }
249         if (prsactx->pad_mode == RSA_PKCS1_OAEP_PADDING) {
250             if (prsactx->oaep_md == NULL) {
251                 prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA-1", NULL);
252                 if (prsactx->oaep_md == NULL) {
253                     OPENSSL_free(tbuf);
254                     ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
255                     return 0;
256                 }
257             }
258             ret = RSA_padding_check_PKCS1_OAEP_mgf1(out, outsize, tbuf,
259                                                     len, len,
260                                                     prsactx->oaep_label,
261                                                     prsactx->oaep_labellen,
262                                                     prsactx->oaep_md,
263                                                     prsactx->mgf1_md);
264         } else {
265             /* RSA_PKCS1_WITH_TLS_PADDING */
266             if (prsactx->client_version <= 0) {
267                 ERR_raise(ERR_LIB_PROV, PROV_R_BAD_TLS_CLIENT_VERSION);
268                 OPENSSL_free(tbuf);
269                 return 0;
270             }
271             ret = ossl_rsa_padding_check_PKCS1_type_2_TLS(
272                         prsactx->libctx, out, outsize, tbuf, len,
273                         prsactx->client_version, prsactx->alt_version);
274         }
275         OPENSSL_free(tbuf);
276     } else {
277         ret = RSA_private_decrypt(inlen, in, out, prsactx->rsa,
278                                   prsactx->pad_mode);
279     }
280     *outlen = constant_time_select_s(constant_time_msb_s(ret), *outlen, ret);
281     ret = constant_time_select_int(constant_time_msb(ret), 0, 1);
282     return ret;
283 }
284
285 static void rsa_freectx(void *vprsactx)
286 {
287     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
288
289     RSA_free(prsactx->rsa);
290
291     EVP_MD_free(prsactx->oaep_md);
292     EVP_MD_free(prsactx->mgf1_md);
293     OPENSSL_free(prsactx->oaep_label);
294
295     OPENSSL_free(prsactx);
296 }
297
298 static void *rsa_dupctx(void *vprsactx)
299 {
300     PROV_RSA_CTX *srcctx = (PROV_RSA_CTX *)vprsactx;
301     PROV_RSA_CTX *dstctx;
302
303     if (!ossl_prov_is_running())
304         return NULL;
305
306     dstctx = OPENSSL_zalloc(sizeof(*srcctx));
307     if (dstctx == NULL)
308         return NULL;
309
310     *dstctx = *srcctx;
311     if (dstctx->rsa != NULL && !RSA_up_ref(dstctx->rsa)) {
312         OPENSSL_free(dstctx);
313         return NULL;
314     }
315
316     if (dstctx->oaep_md != NULL && !EVP_MD_up_ref(dstctx->oaep_md)) {
317         RSA_free(dstctx->rsa);
318         OPENSSL_free(dstctx);
319         return NULL;
320     }
321
322     if (dstctx->mgf1_md != NULL && !EVP_MD_up_ref(dstctx->mgf1_md)) {
323         RSA_free(dstctx->rsa);
324         EVP_MD_free(dstctx->oaep_md);
325         OPENSSL_free(dstctx);
326         return NULL;
327     }
328
329     return dstctx;
330 }
331
332 static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
333 {
334     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
335     OSSL_PARAM *p;
336
337     if (prsactx == NULL)
338         return 0;
339
340     p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_PAD_MODE);
341     if (p != NULL)
342         switch (p->data_type) {
343         case OSSL_PARAM_INTEGER: /* Support for legacy pad mode number */
344             if (!OSSL_PARAM_set_int(p, prsactx->pad_mode))
345                 return 0;
346             break;
347         case OSSL_PARAM_UTF8_STRING:
348             {
349                 int i;
350                 const char *word = NULL;
351
352                 for (i = 0; padding_item[i].id != 0; i++) {
353                     if (prsactx->pad_mode == (int)padding_item[i].id) {
354                         word = padding_item[i].ptr;
355                         break;
356                     }
357                 }
358
359                 if (word != NULL) {
360                     if (!OSSL_PARAM_set_utf8_string(p, word))
361                         return 0;
362                 } else {
363                     ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
364                 }
365             }
366             break;
367         default:
368             return 0;
369         }
370
371     p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST);
372     if (p != NULL && !OSSL_PARAM_set_utf8_string(p, prsactx->oaep_md == NULL
373                                                     ? ""
374                                                     : EVP_MD_get0_name(prsactx->oaep_md)))
375         return 0;
376
377     p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST);
378     if (p != NULL) {
379         EVP_MD *mgf1_md = prsactx->mgf1_md == NULL ? prsactx->oaep_md
380                                                    : prsactx->mgf1_md;
381
382         if (!OSSL_PARAM_set_utf8_string(p, mgf1_md == NULL
383                                            ? ""
384                                            : EVP_MD_get0_name(mgf1_md)))
385         return 0;
386     }
387
388     p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL);
389     if (p != NULL &&
390         !OSSL_PARAM_set_octet_ptr(p, prsactx->oaep_label,
391                                   prsactx->oaep_labellen))
392         return 0;
393
394     p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION);
395     if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->client_version))
396         return 0;
397
398     p = OSSL_PARAM_locate(params, OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION);
399     if (p != NULL && !OSSL_PARAM_set_uint(p, prsactx->alt_version))
400         return 0;
401
402     return 1;
403 }
404
405 static const OSSL_PARAM known_gettable_ctx_params[] = {
406     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST, NULL, 0),
407     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_PAD_MODE, NULL, 0),
408     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST, NULL, 0),
409     OSSL_PARAM_DEFN(OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL, OSSL_PARAM_OCTET_PTR,
410                     NULL, 0),
411     OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION, NULL),
412     OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION, NULL),
413     OSSL_PARAM_END
414 };
415
416 static const OSSL_PARAM *rsa_gettable_ctx_params(ossl_unused void *vprsactx,
417                                                  ossl_unused void *provctx)
418 {
419     return known_gettable_ctx_params;
420 }
421
422 static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
423 {
424     PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
425     const OSSL_PARAM *p;
426     char mdname[OSSL_MAX_NAME_SIZE];
427     char mdprops[OSSL_MAX_PROPQUERY_SIZE] = { '\0' };
428     char *str = mdname;
429
430     if (prsactx == NULL)
431         return 0;
432     if (params == NULL)
433         return 1;
434
435     p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST);
436     if (p != NULL) {
437         if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdname)))
438             return 0;
439
440         str = mdprops;
441         p = OSSL_PARAM_locate_const(params,
442                                     OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST_PROPS);
443         if (p != NULL) {
444             if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdprops)))
445                 return 0;
446         }
447
448         EVP_MD_free(prsactx->oaep_md);
449         prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, mdname, mdprops);
450
451         if (prsactx->oaep_md == NULL)
452             return 0;
453     }
454
455     p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_PAD_MODE);
456     if (p != NULL) {
457         int pad_mode = 0;
458
459         switch (p->data_type) {
460         case OSSL_PARAM_INTEGER: /* Support for legacy pad mode number */
461             if (!OSSL_PARAM_get_int(p, &pad_mode))
462                 return 0;
463             break;
464         case OSSL_PARAM_UTF8_STRING:
465             {
466                 int i;
467
468                 if (p->data == NULL)
469                     return 0;
470
471                 for (i = 0; padding_item[i].id != 0; i++) {
472                     if (strcmp(p->data, padding_item[i].ptr) == 0) {
473                         pad_mode = padding_item[i].id;
474                         break;
475                     }
476                 }
477             }
478             break;
479         default:
480             return 0;
481         }
482
483         /*
484          * PSS padding is for signatures only so is not compatible with
485          * asymmetric cipher use.
486          */
487         if (pad_mode == RSA_PKCS1_PSS_PADDING)
488             return 0;
489         if (pad_mode == RSA_PKCS1_OAEP_PADDING && prsactx->oaep_md == NULL) {
490             prsactx->oaep_md = EVP_MD_fetch(prsactx->libctx, "SHA1", mdprops);
491             if (prsactx->oaep_md == NULL)
492                 return 0;
493         }
494         prsactx->pad_mode = pad_mode;
495     }
496
497     p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST);
498     if (p != NULL) {
499         if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdname)))
500             return 0;
501
502         str = mdprops;
503         p = OSSL_PARAM_locate_const(params,
504                                     OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS);
505         if (p != NULL) {
506             if (!OSSL_PARAM_get_utf8_string(p, &str, sizeof(mdprops)))
507                 return 0;
508         } else {
509             str = NULL;
510         }
511
512         EVP_MD_free(prsactx->mgf1_md);
513         prsactx->mgf1_md = EVP_MD_fetch(prsactx->libctx, mdname, str);
514
515         if (prsactx->mgf1_md == NULL)
516             return 0;
517     }
518
519     p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL);
520     if (p != NULL) {
521         void *tmp_label = NULL;
522         size_t tmp_labellen;
523
524         if (!OSSL_PARAM_get_octet_string(p, &tmp_label, 0, &tmp_labellen))
525             return 0;
526         OPENSSL_free(prsactx->oaep_label);
527         prsactx->oaep_label = (unsigned char *)tmp_label;
528         prsactx->oaep_labellen = tmp_labellen;
529     }
530
531     p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION);
532     if (p != NULL) {
533         unsigned int client_version;
534
535         if (!OSSL_PARAM_get_uint(p, &client_version))
536             return 0;
537         prsactx->client_version = client_version;
538     }
539
540     p = OSSL_PARAM_locate_const(params, OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION);
541     if (p != NULL) {
542         unsigned int alt_version;
543
544         if (!OSSL_PARAM_get_uint(p, &alt_version))
545             return 0;
546         prsactx->alt_version = alt_version;
547     }
548
549     return 1;
550 }
551
552 static const OSSL_PARAM known_settable_ctx_params[] = {
553     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_OAEP_DIGEST, NULL, 0),
554     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_PAD_MODE, NULL, 0),
555     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST, NULL, 0),
556     OSSL_PARAM_utf8_string(OSSL_ASYM_CIPHER_PARAM_MGF1_DIGEST_PROPS, NULL, 0),
557     OSSL_PARAM_octet_string(OSSL_ASYM_CIPHER_PARAM_OAEP_LABEL, NULL, 0),
558     OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_CLIENT_VERSION, NULL),
559     OSSL_PARAM_uint(OSSL_ASYM_CIPHER_PARAM_TLS_NEGOTIATED_VERSION, NULL),
560     OSSL_PARAM_END
561 };
562
563 static const OSSL_PARAM *rsa_settable_ctx_params(ossl_unused void *vprsactx,
564                                                  ossl_unused void *provctx)
565 {
566     return known_settable_ctx_params;
567 }
568
569 const OSSL_DISPATCH ossl_rsa_asym_cipher_functions[] = {
570     { OSSL_FUNC_ASYM_CIPHER_NEWCTX, (void (*)(void))rsa_newctx },
571     { OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT, (void (*)(void))rsa_encrypt_init },
572     { OSSL_FUNC_ASYM_CIPHER_ENCRYPT, (void (*)(void))rsa_encrypt },
573     { OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT, (void (*)(void))rsa_decrypt_init },
574     { OSSL_FUNC_ASYM_CIPHER_DECRYPT, (void (*)(void))rsa_decrypt },
575     { OSSL_FUNC_ASYM_CIPHER_FREECTX, (void (*)(void))rsa_freectx },
576     { OSSL_FUNC_ASYM_CIPHER_DUPCTX, (void (*)(void))rsa_dupctx },
577     { OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS,
578       (void (*)(void))rsa_get_ctx_params },
579     { OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS,
580       (void (*)(void))rsa_gettable_ctx_params },
581     { OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS,
582       (void (*)(void))rsa_set_ctx_params },
583     { OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS,
584       (void (*)(void))rsa_settable_ctx_params },
585     { 0, NULL }
586 };