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