]> git.ipfire.org Git - thirdparty/openssl.git/blob - providers/implementations/signature/rsa.c
27e35be3c9aeb063d0430e9d73acabe85bb7617e
[thirdparty/openssl.git] / providers / implementations / signature / rsa.c
1 /*
2 * Copyright 2019-2020 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 <string.h>
17 #include <openssl/crypto.h>
18 #include <openssl/core_numbers.h>
19 #include <openssl/core_names.h>
20 #include <openssl/err.h>
21 #include <openssl/rsa.h>
22 #include <openssl/params.h>
23 #include <openssl/evp.h>
24 #include "internal/cryptlib.h"
25 #include "internal/nelem.h"
26 #include "internal/sizes.h"
27 #include "crypto/rsa.h"
28 #include "prov/providercommonerr.h"
29 #include "prov/implementations.h"
30 #include "prov/provider_ctx.h"
31 #include "prov/der_rsa.h"
32
33 static OSSL_OP_signature_newctx_fn rsa_newctx;
34 static OSSL_OP_signature_sign_init_fn rsa_sign_init;
35 static OSSL_OP_signature_verify_init_fn rsa_verify_init;
36 static OSSL_OP_signature_verify_recover_init_fn rsa_verify_recover_init;
37 static OSSL_OP_signature_sign_fn rsa_sign;
38 static OSSL_OP_signature_verify_fn rsa_verify;
39 static OSSL_OP_signature_verify_recover_fn rsa_verify_recover;
40 static OSSL_OP_signature_digest_sign_init_fn rsa_digest_sign_init;
41 static OSSL_OP_signature_digest_sign_update_fn rsa_digest_signverify_update;
42 static OSSL_OP_signature_digest_sign_final_fn rsa_digest_sign_final;
43 static OSSL_OP_signature_digest_verify_init_fn rsa_digest_verify_init;
44 static OSSL_OP_signature_digest_verify_update_fn rsa_digest_signverify_update;
45 static OSSL_OP_signature_digest_verify_final_fn rsa_digest_verify_final;
46 static OSSL_OP_signature_freectx_fn rsa_freectx;
47 static OSSL_OP_signature_dupctx_fn rsa_dupctx;
48 static OSSL_OP_signature_get_ctx_params_fn rsa_get_ctx_params;
49 static OSSL_OP_signature_gettable_ctx_params_fn rsa_gettable_ctx_params;
50 static OSSL_OP_signature_set_ctx_params_fn rsa_set_ctx_params;
51 static OSSL_OP_signature_settable_ctx_params_fn rsa_settable_ctx_params;
52 static OSSL_OP_signature_get_ctx_md_params_fn rsa_get_ctx_md_params;
53 static OSSL_OP_signature_gettable_ctx_md_params_fn rsa_gettable_ctx_md_params;
54 static OSSL_OP_signature_set_ctx_md_params_fn rsa_set_ctx_md_params;
55 static OSSL_OP_signature_settable_ctx_md_params_fn rsa_settable_ctx_md_params;
56
57 static OSSL_ITEM padding_item[] = {
58 { RSA_PKCS1_PADDING, "pkcs1" },
59 { RSA_SSLV23_PADDING, "sslv23" },
60 { RSA_NO_PADDING, "none" },
61 { RSA_PKCS1_OAEP_PADDING, "oaep" }, /* Correct spelling first */
62 { RSA_PKCS1_OAEP_PADDING, "oeap" },
63 { RSA_X931_PADDING, "x931" },
64 { RSA_PKCS1_PSS_PADDING, "pss" },
65 { 0, NULL }
66 };
67
68 /*
69 * What's passed as an actual key is defined by the KEYMGMT interface.
70 * We happen to know that our KEYMGMT simply passes RSA structures, so
71 * we use that here too.
72 */
73
74 typedef struct {
75 OPENSSL_CTX *libctx;
76 char *propq;
77 RSA *rsa;
78 int operation;
79
80 /*
81 * Flag to determine if the hash function can be changed (1) or not (0)
82 * Because it's dangerous to change during a DigestSign or DigestVerify
83 * operation, this flag is cleared by their Init function, and set again
84 * by their Final function.
85 */
86 unsigned int flag_allow_md : 1;
87
88 /* The Algorithm Identifier of the combined signature agorithm */
89 unsigned char aid_buf[128];
90 unsigned char *aid;
91 size_t aid_len;
92
93 /* main digest */
94 EVP_MD *md;
95 EVP_MD_CTX *mdctx;
96 int mdnid;
97 char mdname[OSSL_MAX_NAME_SIZE]; /* Purely informational */
98
99 /* RSA padding mode */
100 int pad_mode;
101 /* message digest for MGF1 */
102 EVP_MD *mgf1_md;
103 char mgf1_mdname[OSSL_MAX_NAME_SIZE]; /* Purely informational */
104 /* PSS salt length */
105 int saltlen;
106 /* Minimum salt length or -1 if no PSS parameter restriction */
107 int min_saltlen;
108
109 /* Temp buffer */
110 unsigned char *tbuf;
111
112 } PROV_RSA_CTX;
113
114 static size_t rsa_get_md_size(const PROV_RSA_CTX *prsactx)
115 {
116 if (prsactx->md != NULL)
117 return EVP_MD_size(prsactx->md);
118 return 0;
119 }
120
121 static int rsa_get_md_nid(const EVP_MD *md)
122 {
123 /*
124 * Because the RSA library deals with NIDs, we need to translate.
125 * We do so using EVP_MD_is_a(), and therefore need a name to NID
126 * map.
127 */
128 static const OSSL_ITEM name_to_nid[] = {
129 { NID_sha1, OSSL_DIGEST_NAME_SHA1 },
130 { NID_sha224, OSSL_DIGEST_NAME_SHA2_224 },
131 { NID_sha256, OSSL_DIGEST_NAME_SHA2_256 },
132 { NID_sha384, OSSL_DIGEST_NAME_SHA2_384 },
133 { NID_sha512, OSSL_DIGEST_NAME_SHA2_512 },
134 { NID_sha512_224, OSSL_DIGEST_NAME_SHA2_512_224 },
135 { NID_sha512_256, OSSL_DIGEST_NAME_SHA2_512_256 },
136 { NID_md5, OSSL_DIGEST_NAME_MD5 },
137 { NID_md5_sha1, OSSL_DIGEST_NAME_MD5_SHA1 },
138 { NID_md2, OSSL_DIGEST_NAME_MD2 },
139 { NID_md4, OSSL_DIGEST_NAME_MD4 },
140 { NID_mdc2, OSSL_DIGEST_NAME_MDC2 },
141 { NID_ripemd160, OSSL_DIGEST_NAME_RIPEMD160 },
142 { NID_sha3_224, OSSL_DIGEST_NAME_SHA3_224 },
143 { NID_sha3_256, OSSL_DIGEST_NAME_SHA3_256 },
144 { NID_sha3_384, OSSL_DIGEST_NAME_SHA3_384 },
145 { NID_sha3_512, OSSL_DIGEST_NAME_SHA3_512 },
146 };
147 size_t i;
148 int mdnid = NID_undef;
149
150 if (md == NULL)
151 goto end;
152
153 for (i = 0; i < OSSL_NELEM(name_to_nid); i++) {
154 if (EVP_MD_is_a(md, name_to_nid[i].ptr)) {
155 mdnid = (int)name_to_nid[i].id;
156 break;
157 }
158 }
159
160 if (mdnid == NID_undef)
161 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DIGEST);
162
163 end:
164 return mdnid;
165 }
166
167 static int rsa_check_padding(int mdnid, int padding)
168 {
169 if (padding == RSA_NO_PADDING) {
170 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE);
171 return 0;
172 }
173
174 if (padding == RSA_X931_PADDING) {
175 if (RSA_X931_hash_id(mdnid) == -1) {
176 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_X931_DIGEST);
177 return 0;
178 }
179 }
180
181 return 1;
182 }
183
184 static void *rsa_newctx(void *provctx, const char *propq)
185 {
186 PROV_RSA_CTX *prsactx = OPENSSL_zalloc(sizeof(PROV_RSA_CTX));
187
188 if (prsactx == NULL)
189 return NULL;
190
191 prsactx->libctx = PROV_LIBRARY_CONTEXT_OF(provctx);
192 prsactx->flag_allow_md = 1;
193 if (propq != NULL && (prsactx->propq = OPENSSL_strdup(propq)) == NULL) {
194 OPENSSL_free(prsactx);
195 prsactx = NULL;
196 ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
197 }
198 return prsactx;
199 }
200
201 /* True if PSS parameters are restricted */
202 #define rsa_pss_restricted(prsactx) (prsactx->min_saltlen != -1)
203
204 static int rsa_signature_init(void *vprsactx, void *vrsa, int operation)
205 {
206 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
207
208 if (prsactx == NULL || vrsa == NULL || !RSA_up_ref(vrsa))
209 return 0;
210
211 RSA_free(prsactx->rsa);
212 prsactx->rsa = vrsa;
213 prsactx->operation = operation;
214 if (RSA_get0_pss_params(prsactx->rsa) != NULL)
215 prsactx->pad_mode = RSA_PKCS1_PSS_PADDING;
216 else
217 prsactx->pad_mode = RSA_PKCS1_PADDING;
218 /* Maximum for sign, auto for verify */
219 prsactx->saltlen = RSA_PSS_SALTLEN_AUTO;
220 prsactx->min_saltlen = -1;
221
222 return 1;
223 }
224
225 static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname,
226 const char *mdprops)
227 {
228 if (mdprops == NULL)
229 mdprops = ctx->propq;
230
231 if (mdname != NULL) {
232 EVP_MD *md = EVP_MD_fetch(ctx->libctx, mdname, mdprops);
233 int md_nid = rsa_get_md_nid(md);
234 WPACKET pkt;
235
236 if (md == NULL
237 || md_nid == NID_undef
238 || !rsa_check_padding(md_nid, ctx->pad_mode)) {
239 EVP_MD_free(md);
240 return 0;
241 }
242
243 EVP_MD_CTX_free(ctx->mdctx);
244 EVP_MD_free(ctx->md);
245
246 /*
247 * TODO(3.0) Should we care about DER writing errors?
248 * All it really means is that for some reason, there's no
249 * AlgorithmIdentifier to be had (consider RSA with MD5-SHA1),
250 * but the operation itself is still valid, just as long as it's
251 * not used to construct anything that needs an AlgorithmIdentifier.
252 */
253 ctx->aid_len = 0;
254 if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf))
255 && DER_w_algorithmIdentifier_RSA_with(&pkt, -1, ctx->rsa, md_nid)
256 && WPACKET_finish(&pkt)) {
257 WPACKET_get_total_written(&pkt, &ctx->aid_len);
258 ctx->aid = WPACKET_get_curr(&pkt);
259 }
260 WPACKET_cleanup(&pkt);
261
262 ctx->mdctx = NULL;
263 ctx->md = md;
264 ctx->mdnid = md_nid;
265 OPENSSL_strlcpy(ctx->mdname, mdname, sizeof(ctx->mdname));
266 }
267
268 return 1;
269 }
270
271 static int rsa_setup_mgf1_md(PROV_RSA_CTX *ctx, const char *mdname,
272 const char *mdprops)
273 {
274 if (mdprops == NULL)
275 mdprops = ctx->propq;
276
277 if (ctx->mgf1_mdname[0] != '\0')
278 EVP_MD_free(ctx->mgf1_md);
279
280 if ((ctx->mgf1_md = EVP_MD_fetch(ctx->libctx, mdname, mdprops)) == NULL)
281 return 0;
282 OPENSSL_strlcpy(ctx->mgf1_mdname, mdname, sizeof(ctx->mgf1_mdname));
283
284 return 1;
285 }
286
287 static int setup_tbuf(PROV_RSA_CTX *ctx)
288 {
289 if (ctx->tbuf != NULL)
290 return 1;
291 if ((ctx->tbuf = OPENSSL_malloc(RSA_size(ctx->rsa))) == NULL) {
292 ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
293 return 0;
294 }
295 return 1;
296 }
297
298 static void clean_tbuf(PROV_RSA_CTX *ctx)
299 {
300 if (ctx->tbuf != NULL)
301 OPENSSL_cleanse(ctx->tbuf, RSA_size(ctx->rsa));
302 }
303
304 static void free_tbuf(PROV_RSA_CTX *ctx)
305 {
306 OPENSSL_clear_free(ctx->tbuf, RSA_size(ctx->rsa));
307 ctx->tbuf = NULL;
308 }
309
310 static int rsa_sign_init(void *vprsactx, void *vrsa)
311 {
312 return rsa_signature_init(vprsactx, vrsa, EVP_PKEY_OP_SIGN);
313 }
314
315 static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen,
316 size_t sigsize, const unsigned char *tbs, size_t tbslen)
317 {
318 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
319 int ret;
320 size_t rsasize = RSA_size(prsactx->rsa);
321 size_t mdsize = rsa_get_md_size(prsactx);
322
323 if (sig == NULL) {
324 *siglen = rsasize;
325 return 1;
326 }
327
328 if (sigsize < (size_t)rsasize)
329 return 0;
330
331 if (mdsize != 0) {
332 if (tbslen != mdsize) {
333 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_DIGEST_LENGTH);
334 return 0;
335 }
336
337 #ifndef FIPS_MODULE
338 if (EVP_MD_is_a(prsactx->md, OSSL_DIGEST_NAME_MDC2)) {
339 unsigned int sltmp;
340
341 if (prsactx->pad_mode != RSA_PKCS1_PADDING) {
342 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE,
343 "only PKCS#1 padding supported with MDC2");
344 return 0;
345 }
346 ret = RSA_sign_ASN1_OCTET_STRING(0, tbs, tbslen, sig, &sltmp,
347 prsactx->rsa);
348
349 if (ret <= 0) {
350 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
351 return 0;
352 }
353 ret = sltmp;
354 goto end;
355 }
356 #endif
357 switch (prsactx->pad_mode) {
358 case RSA_X931_PADDING:
359 if ((size_t)RSA_size(prsactx->rsa) < tbslen + 1) {
360 ERR_raise(ERR_LIB_PROV, PROV_R_KEY_SIZE_TOO_SMALL);
361 return 0;
362 }
363 if (!setup_tbuf(prsactx)) {
364 ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
365 return 0;
366 }
367 memcpy(prsactx->tbuf, tbs, tbslen);
368 prsactx->tbuf[tbslen] = RSA_X931_hash_id(prsactx->mdnid);
369 ret = RSA_private_encrypt(tbslen + 1, prsactx->tbuf,
370 sig, prsactx->rsa, RSA_X931_PADDING);
371 clean_tbuf(prsactx);
372 break;
373
374 case RSA_PKCS1_PADDING:
375 {
376 unsigned int sltmp;
377
378 ret = RSA_sign(prsactx->mdnid, tbs, tbslen, sig, &sltmp,
379 prsactx->rsa);
380 if (ret <= 0) {
381 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
382 return 0;
383 }
384 ret = sltmp;
385 }
386 break;
387
388 case RSA_PKCS1_PSS_PADDING:
389 /* Check PSS restrictions */
390 if (rsa_pss_restricted(prsactx)) {
391 switch (prsactx->saltlen) {
392 case RSA_PSS_SALTLEN_DIGEST:
393 if (prsactx->min_saltlen > EVP_MD_size(prsactx->md)) {
394 ERR_raise(ERR_LIB_PROV, PROV_R_PSS_SALTLEN_TOO_SMALL);
395 return 0;
396 }
397 /* FALLTHRU */
398 default:
399 if (prsactx->saltlen >= 0
400 && prsactx->saltlen < prsactx->min_saltlen) {
401 ERR_raise(ERR_LIB_PROV, PROV_R_PSS_SALTLEN_TOO_SMALL);
402 return 0;
403 }
404 break;
405 }
406 }
407 if (!setup_tbuf(prsactx))
408 return 0;
409 if (!RSA_padding_add_PKCS1_PSS_mgf1(prsactx->rsa,
410 prsactx->tbuf, tbs,
411 prsactx->md, prsactx->mgf1_md,
412 prsactx->saltlen)) {
413 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
414 return 0;
415 }
416 ret = RSA_private_encrypt(RSA_size(prsactx->rsa), prsactx->tbuf,
417 sig, prsactx->rsa, RSA_NO_PADDING);
418 clean_tbuf(prsactx);
419 break;
420
421 default:
422 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE,
423 "Only X.931, PKCS#1 v1.5 or PSS padding allowed");
424 return 0;
425 }
426 } else {
427 ret = RSA_private_encrypt(tbslen, tbs, sig, prsactx->rsa,
428 prsactx->pad_mode);
429 }
430
431 #ifndef FIPS_MODULE
432 end:
433 #endif
434 if (ret <= 0) {
435 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
436 return 0;
437 }
438
439 *siglen = ret;
440 return 1;
441 }
442
443 static int rsa_verify_recover_init(void *vprsactx, void *vrsa)
444 {
445 return rsa_signature_init(vprsactx, vrsa, EVP_PKEY_OP_VERIFYRECOVER);
446 }
447
448 static int rsa_verify_recover(void *vprsactx,
449 unsigned char *rout,
450 size_t *routlen,
451 size_t routsize,
452 const unsigned char *sig,
453 size_t siglen)
454 {
455 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
456 int ret;
457
458 if (rout == NULL) {
459 *routlen = RSA_size(prsactx->rsa);
460 return 1;
461 }
462
463 if (prsactx->md != NULL) {
464 switch (prsactx->pad_mode) {
465 case RSA_X931_PADDING:
466 if (!setup_tbuf(prsactx))
467 return 0;
468 ret = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa,
469 RSA_X931_PADDING);
470 if (ret < 1) {
471 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
472 return 0;
473 }
474 ret--;
475 if (prsactx->tbuf[ret] != RSA_X931_hash_id(prsactx->mdnid)) {
476 ERR_raise(ERR_LIB_PROV, PROV_R_ALGORITHM_MISMATCH);
477 return 0;
478 }
479 if (ret != EVP_MD_size(prsactx->md)) {
480 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST_LENGTH,
481 "Should be %d, but got %d",
482 EVP_MD_size(prsactx->md), ret);
483 return 0;
484 }
485
486 *routlen = ret;
487 if (routsize < (size_t)ret) {
488 ERR_raise(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL);
489 return 0;
490 }
491 memcpy(rout, prsactx->tbuf, ret);
492 break;
493
494 case RSA_PKCS1_PADDING:
495 {
496 size_t sltmp;
497
498 ret = int_rsa_verify(prsactx->mdnid, NULL, 0, rout, &sltmp,
499 sig, siglen, prsactx->rsa);
500 if (ret <= 0) {
501 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
502 return 0;
503 }
504 ret = sltmp;
505 }
506 break;
507
508 default:
509 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE,
510 "Only X.931 or PKCS#1 v1.5 padding allowed");
511 return 0;
512 }
513 } else {
514 ret = RSA_public_decrypt(siglen, sig, rout, prsactx->rsa,
515 prsactx->pad_mode);
516 if (ret < 0) {
517 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
518 return 0;
519 }
520 }
521 *routlen = ret;
522 return 1;
523 }
524
525 static int rsa_verify_init(void *vprsactx, void *vrsa)
526 {
527 return rsa_signature_init(vprsactx, vrsa, EVP_PKEY_OP_VERIFY);
528 }
529
530 static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen,
531 const unsigned char *tbs, size_t tbslen)
532 {
533 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
534 size_t rslen;
535
536 if (prsactx->md != NULL) {
537 switch (prsactx->pad_mode) {
538 case RSA_PKCS1_PADDING:
539 if (!RSA_verify(prsactx->mdnid, tbs, tbslen, sig, siglen,
540 prsactx->rsa)) {
541 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
542 return 0;
543 }
544 return 1;
545 case RSA_X931_PADDING:
546 if (rsa_verify_recover(prsactx, NULL, &rslen, 0, sig, siglen) <= 0)
547 return 0;
548 break;
549 case RSA_PKCS1_PSS_PADDING:
550 {
551 int ret;
552 size_t mdsize;
553
554 /*
555 * We need to check this for the RSA_verify_PKCS1_PSS_mgf1()
556 * call
557 */
558 mdsize = rsa_get_md_size(prsactx);
559 if (tbslen != mdsize) {
560 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST_LENGTH,
561 "Should be %d, but got %d",
562 mdsize, tbslen);
563 return 0;
564 }
565
566 if (!setup_tbuf(prsactx))
567 return 0;
568 ret = RSA_public_decrypt(siglen, sig, prsactx->tbuf,
569 prsactx->rsa, RSA_NO_PADDING);
570 if (ret <= 0) {
571 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
572 return 0;
573 }
574 ret = RSA_verify_PKCS1_PSS_mgf1(prsactx->rsa, tbs,
575 prsactx->md, prsactx->mgf1_md,
576 prsactx->tbuf,
577 prsactx->saltlen);
578 if (ret <= 0) {
579 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
580 return 0;
581 }
582 return 1;
583 }
584 default:
585 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE,
586 "Only X.931, PKCS#1 v1.5 or PSS padding allowed");
587 return 0;
588 }
589 } else {
590 if (!setup_tbuf(prsactx))
591 return 0;
592 rslen = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa,
593 prsactx->pad_mode);
594 if (rslen == 0) {
595 ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA);
596 return 0;
597 }
598 }
599
600 if ((rslen != tbslen) || memcmp(tbs, prsactx->tbuf, rslen))
601 return 0;
602
603 return 1;
604 }
605
606 static int rsa_digest_signverify_init(void *vprsactx, const char *mdname,
607 void *vrsa, int operation)
608 {
609 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
610
611 prsactx->flag_allow_md = 0;
612 if (!rsa_signature_init(vprsactx, vrsa, operation)
613 || !rsa_setup_md(prsactx, mdname, NULL))
614 return 0;
615
616 prsactx->mdctx = EVP_MD_CTX_new();
617 if (prsactx->mdctx == NULL)
618 goto error;
619
620 if (!EVP_DigestInit_ex(prsactx->mdctx, prsactx->md, NULL))
621 goto error;
622
623 return 1;
624
625 error:
626 EVP_MD_CTX_free(prsactx->mdctx);
627 EVP_MD_free(prsactx->md);
628 prsactx->mdctx = NULL;
629 prsactx->md = NULL;
630 return 0;
631 }
632
633 static int rsa_digest_signverify_update(void *vprsactx,
634 const unsigned char *data,
635 size_t datalen)
636 {
637 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
638
639 if (prsactx == NULL || prsactx->mdctx == NULL)
640 return 0;
641
642 return EVP_DigestUpdate(prsactx->mdctx, data, datalen);
643 }
644
645 static int rsa_digest_sign_init(void *vprsactx, const char *mdname,
646 const char *props, void *vrsa)
647 {
648 return rsa_digest_signverify_init(vprsactx, mdname, props, vrsa,
649 EVP_PKEY_OP_SIGN);
650 }
651
652 static int rsa_digest_sign_final(void *vprsactx, unsigned char *sig,
653 size_t *siglen, size_t sigsize)
654 {
655 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
656 unsigned char digest[EVP_MAX_MD_SIZE];
657 unsigned int dlen = 0;
658
659 prsactx->flag_allow_md = 1;
660 if (prsactx == NULL || prsactx->mdctx == NULL)
661 return 0;
662
663 /*
664 * If sig is NULL then we're just finding out the sig size. Other fields
665 * are ignored. Defer to rsa_sign.
666 */
667 if (sig != NULL) {
668 /*
669 * TODO(3.0): There is the possibility that some externally provided
670 * digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow -
671 * but that problem is much larger than just in RSA.
672 */
673 if (!EVP_DigestFinal_ex(prsactx->mdctx, digest, &dlen))
674 return 0;
675 }
676
677 return rsa_sign(vprsactx, sig, siglen, sigsize, digest, (size_t)dlen);
678 }
679
680 static int rsa_digest_verify_init(void *vprsactx, const char *mdname,
681 const char *props, void *vrsa)
682 {
683 return rsa_digest_signverify_init(vprsactx, mdname, props, vrsa,
684 EVP_PKEY_OP_VERIFY);
685 }
686
687 int rsa_digest_verify_final(void *vprsactx, const unsigned char *sig,
688 size_t siglen)
689 {
690 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
691 unsigned char digest[EVP_MAX_MD_SIZE];
692 unsigned int dlen = 0;
693
694 prsactx->flag_allow_md = 1;
695 if (prsactx == NULL || prsactx->mdctx == NULL)
696 return 0;
697
698 /*
699 * TODO(3.0): There is the possibility that some externally provided
700 * digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow -
701 * but that problem is much larger than just in RSA.
702 */
703 if (!EVP_DigestFinal_ex(prsactx->mdctx, digest, &dlen))
704 return 0;
705
706 return rsa_verify(vprsactx, sig, siglen, digest, (size_t)dlen);
707 }
708
709 static void rsa_freectx(void *vprsactx)
710 {
711 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
712
713 if (prsactx == NULL)
714 return;
715
716 RSA_free(prsactx->rsa);
717 EVP_MD_CTX_free(prsactx->mdctx);
718 EVP_MD_free(prsactx->md);
719 EVP_MD_free(prsactx->mgf1_md);
720 OPENSSL_free(prsactx->propq);
721 free_tbuf(prsactx);
722
723 OPENSSL_clear_free(prsactx, sizeof(prsactx));
724 }
725
726 static void *rsa_dupctx(void *vprsactx)
727 {
728 PROV_RSA_CTX *srcctx = (PROV_RSA_CTX *)vprsactx;
729 PROV_RSA_CTX *dstctx;
730
731 dstctx = OPENSSL_zalloc(sizeof(*srcctx));
732 if (dstctx == NULL)
733 return NULL;
734
735 *dstctx = *srcctx;
736 dstctx->rsa = NULL;
737 dstctx->md = NULL;
738 dstctx->mdctx = NULL;
739 dstctx->tbuf = NULL;
740
741 if (srcctx->rsa != NULL && !RSA_up_ref(srcctx->rsa))
742 goto err;
743 dstctx->rsa = srcctx->rsa;
744
745 if (srcctx->md != NULL && !EVP_MD_up_ref(srcctx->md))
746 goto err;
747 dstctx->md = srcctx->md;
748
749 if (srcctx->mgf1_md != NULL && !EVP_MD_up_ref(srcctx->mgf1_md))
750 goto err;
751 dstctx->mgf1_md = srcctx->mgf1_md;
752
753 if (srcctx->mdctx != NULL) {
754 dstctx->mdctx = EVP_MD_CTX_new();
755 if (dstctx->mdctx == NULL
756 || !EVP_MD_CTX_copy_ex(dstctx->mdctx, srcctx->mdctx))
757 goto err;
758 }
759
760 return dstctx;
761 err:
762 rsa_freectx(dstctx);
763 return NULL;
764 }
765
766 static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params)
767 {
768 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
769 OSSL_PARAM *p;
770
771 if (prsactx == NULL || params == NULL)
772 return 0;
773
774 p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID);
775 if (p != NULL
776 && !OSSL_PARAM_set_octet_string(p, prsactx->aid, prsactx->aid_len))
777 return 0;
778
779 p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_PAD_MODE);
780 if (p != NULL)
781 switch (p->data_type) {
782 case OSSL_PARAM_INTEGER:
783 if (!OSSL_PARAM_set_int(p, prsactx->pad_mode))
784 return 0;
785 break;
786 case OSSL_PARAM_UTF8_STRING:
787 {
788 int i;
789 const char *word = NULL;
790
791 for (i = 0; padding_item[i].id != 0; i++) {
792 if (prsactx->pad_mode == (int)padding_item[i].id) {
793 word = padding_item[i].ptr;
794 break;
795 }
796 }
797
798 if (word != NULL) {
799 if (!OSSL_PARAM_set_utf8_string(p, word))
800 return 0;
801 } else {
802 ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR);
803 }
804 }
805 break;
806 default:
807 return 0;
808 }
809
810 p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_DIGEST);
811 if (p != NULL && !OSSL_PARAM_set_utf8_string(p, prsactx->mdname))
812 return 0;
813
814 p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_MGF1_DIGEST);
815 if (p != NULL && !OSSL_PARAM_set_utf8_string(p, prsactx->mgf1_mdname))
816 return 0;
817
818 p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_PSS_SALTLEN);
819 if (p != NULL) {
820 if (p->data_type == OSSL_PARAM_INTEGER) {
821 if (!OSSL_PARAM_set_int(p, prsactx->saltlen))
822 return 0;
823 } else if (p->data_type == OSSL_PARAM_UTF8_STRING) {
824 switch (prsactx->saltlen) {
825 case RSA_PSS_SALTLEN_DIGEST:
826 if (!OSSL_PARAM_set_utf8_string(p, "digest"))
827 return 0;
828 break;
829 case RSA_PSS_SALTLEN_MAX:
830 if (!OSSL_PARAM_set_utf8_string(p, "max"))
831 return 0;
832 break;
833 case RSA_PSS_SALTLEN_AUTO:
834 if (!OSSL_PARAM_set_utf8_string(p, "auto"))
835 return 0;
836 break;
837 default:
838 if (BIO_snprintf(p->data, p->data_size, "%d", prsactx->saltlen)
839 <= 0)
840 return 0;
841 break;
842 }
843 }
844 }
845
846 return 1;
847 }
848
849 static const OSSL_PARAM known_gettable_ctx_params[] = {
850 OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID, NULL, 0),
851 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PAD_MODE, NULL, 0),
852 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
853 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_DIGEST, NULL, 0),
854 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PSS_SALTLEN, NULL, 0),
855 OSSL_PARAM_END
856 };
857
858 static const OSSL_PARAM *rsa_gettable_ctx_params(void)
859 {
860 return known_gettable_ctx_params;
861 }
862
863 static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[])
864 {
865 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
866 const OSSL_PARAM *p;
867
868 if (prsactx == NULL || params == NULL)
869 return 0;
870
871 p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST);
872 /* Not allowed during certain operations */
873 if (p != NULL && !prsactx->flag_allow_md)
874 return 0;
875 if (p != NULL) {
876 char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname;
877 char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops;
878 const OSSL_PARAM *propsp =
879 OSSL_PARAM_locate_const(params,
880 OSSL_SIGNATURE_PARAM_PROPERTIES);
881
882 if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
883 return 0;
884
885 if (propsp == NULL)
886 pmdprops = NULL;
887 else if (!OSSL_PARAM_get_utf8_string(propsp,
888 &pmdprops, sizeof(mdprops)))
889 return 0;
890
891 /* TODO(3.0) PSS check needs more work */
892 if (rsa_pss_restricted(prsactx)) {
893 /* TODO(3.0) figure out what to do for prsactx->md == NULL */
894 if (prsactx->md == NULL || EVP_MD_is_a(prsactx->md, mdname))
895 return 1;
896 ERR_raise(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED);
897 return 0;
898 }
899
900 /* non-PSS code follows */
901 if (!rsa_setup_md(prsactx, mdname, pmdprops))
902 return 0;
903 }
904
905 p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PAD_MODE);
906 if (p != NULL) {
907 int pad_mode = 0;
908 const char *err_extra_text = NULL;
909
910 switch (p->data_type) {
911 case OSSL_PARAM_INTEGER: /* Support for legacy pad mode number */
912 if (!OSSL_PARAM_get_int(p, &pad_mode))
913 return 0;
914 break;
915 case OSSL_PARAM_UTF8_STRING:
916 {
917 int i;
918
919 if (p->data == NULL)
920 return 0;
921
922 for (i = 0; padding_item[i].id != 0; i++) {
923 if (strcmp(p->data, padding_item[i].ptr) == 0) {
924 pad_mode = padding_item[i].id;
925 break;
926 }
927 }
928 }
929 break;
930 default:
931 return 0;
932 }
933
934 switch (pad_mode) {
935 case RSA_PKCS1_OAEP_PADDING:
936 /*
937 * OAEP padding is for asymmetric cipher only so is not compatible
938 * with signature use.
939 */
940 err_extra_text = "OAEP padding not allowed for signing / verifying";
941 goto bad_pad;
942 case RSA_PKCS1_PSS_PADDING:
943 if ((prsactx->operation
944 & (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY)) == 0) {
945 err_extra_text =
946 "PSS padding only allowed for sign and verify operations";
947 goto bad_pad;
948 }
949 if (prsactx->md == NULL
950 && !rsa_setup_md(prsactx, OSSL_DIGEST_NAME_SHA1, NULL)) {
951 ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST,
952 "%s could not be fetched",
953 OSSL_DIGEST_NAME_SHA1);
954 return 0;
955 }
956 break;
957 case RSA_PKCS1_PADDING:
958 err_extra_text = "PKCS#1 padding not allowed with RSA-PSS";
959 goto cont;
960 case RSA_SSLV23_PADDING:
961 err_extra_text = "SSLv3 padding not allowed with RSA-PSS";
962 goto cont;
963 case RSA_NO_PADDING:
964 err_extra_text = "No padding not allowed with RSA-PSS";
965 goto cont;
966 case RSA_X931_PADDING:
967 err_extra_text = "X.931 padding not allowed with RSA-PSS";
968 cont:
969 if (RSA_get0_pss_params(prsactx->rsa) == NULL)
970 break;
971 /* FALLTHRU */
972 default:
973 bad_pad:
974 if (err_extra_text == NULL)
975 ERR_raise(ERR_LIB_PROV,
976 PROV_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE);
977 else
978 ERR_raise_data(ERR_LIB_PROV,
979 PROV_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE,
980 err_extra_text);
981 return 0;
982 }
983 if (!rsa_check_padding(prsactx->mdnid, pad_mode))
984 return 0;
985 prsactx->pad_mode = pad_mode;
986 }
987
988 p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PSS_SALTLEN);
989 if (p != NULL) {
990 int saltlen;
991
992 if (prsactx->pad_mode != RSA_PKCS1_PSS_PADDING) {
993 ERR_raise_data(ERR_LIB_PROV, PROV_R_NOT_SUPPORTED,
994 "PSS saltlen can only be specified if "
995 "PSS padding has been specified first");
996 return 0;
997 }
998
999 switch (p->data_type) {
1000 case OSSL_PARAM_INTEGER: /* Support for legacy pad mode number */
1001 if (!OSSL_PARAM_get_int(p, &saltlen))
1002 return 0;
1003 break;
1004 case OSSL_PARAM_UTF8_STRING:
1005 if (strcmp(p->data, "digest") == 0)
1006 saltlen = RSA_PSS_SALTLEN_DIGEST;
1007 else if (strcmp(p->data, "max") == 0)
1008 saltlen = RSA_PSS_SALTLEN_MAX;
1009 else if (strcmp(p->data, "auto") == 0)
1010 saltlen = RSA_PSS_SALTLEN_AUTO;
1011 else
1012 saltlen = atoi(p->data);
1013 break;
1014 default:
1015 return 0;
1016 }
1017
1018 /*
1019 * RSA_PSS_SALTLEN_MAX seems curiously named in this check.
1020 * Contrary to what it's name suggests, it's the currently
1021 * lowest saltlen number possible.
1022 */
1023 if (saltlen < RSA_PSS_SALTLEN_MAX) {
1024 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PSS_SALTLEN);
1025 return 0;
1026 }
1027
1028 if (rsa_pss_restricted(prsactx)) {
1029 switch (prsactx->saltlen) {
1030 case RSA_PSS_SALTLEN_AUTO:
1031 if (prsactx->operation == EVP_PKEY_OP_VERIFY) {
1032 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PSS_SALTLEN);
1033 return 0;
1034 }
1035 break;
1036 case RSA_PSS_SALTLEN_DIGEST:
1037 if (prsactx->min_saltlen > EVP_MD_size(prsactx->md)) {
1038 ERR_raise_data(ERR_LIB_PROV,
1039 PROV_R_PSS_SALTLEN_TOO_SMALL,
1040 "Should be more than %d, but would be "
1041 "set to match digest size (%d)",
1042 prsactx->min_saltlen,
1043 EVP_MD_size(prsactx->md));
1044 return 0;
1045 }
1046 /* FALLTHRU */
1047 default:
1048 if (saltlen >= 0 && saltlen < prsactx->min_saltlen) {
1049 ERR_raise_data(ERR_LIB_PROV,
1050 PROV_R_PSS_SALTLEN_TOO_SMALL,
1051 "Should be more than %d, "
1052 "but would be set to %d",
1053 prsactx->min_saltlen, saltlen);
1054 return 0;
1055 }
1056 }
1057 }
1058
1059 prsactx->saltlen = saltlen;
1060 }
1061
1062 p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_MGF1_DIGEST);
1063 if (p != NULL) {
1064 char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname;
1065 char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops;
1066 const OSSL_PARAM *propsp =
1067 OSSL_PARAM_locate_const(params,
1068 OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES);
1069
1070 if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname)))
1071 return 0;
1072
1073 if (propsp == NULL)
1074 pmdprops = NULL;
1075 else if (!OSSL_PARAM_get_utf8_string(propsp,
1076 &pmdprops, sizeof(mdprops)))
1077 return 0;
1078
1079 if (prsactx->pad_mode != RSA_PKCS1_PSS_PADDING) {
1080 ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_MGF1_MD);
1081 return 0;
1082 }
1083
1084 if (rsa_pss_restricted(prsactx)) {
1085 /* TODO(3.0) figure out what to do for prsactx->mgf1_md == NULL */
1086 if (prsactx->mgf1_md == NULL
1087 || EVP_MD_is_a(prsactx->mgf1_md, mdname))
1088 return 1;
1089 ERR_raise(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED);
1090 return 0;
1091 }
1092
1093 /* non-PSS code follows */
1094 if (!rsa_setup_mgf1_md(prsactx, mdname, pmdprops))
1095 return 0;
1096 }
1097
1098 return 1;
1099 }
1100
1101 static const OSSL_PARAM known_settable_ctx_params[] = {
1102 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PAD_MODE, NULL, 0),
1103 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST, NULL, 0),
1104 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES, NULL, 0),
1105 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_DIGEST, NULL, 0),
1106 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES, NULL, 0),
1107 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PSS_SALTLEN, NULL, 0),
1108 OSSL_PARAM_END
1109 };
1110
1111 static const OSSL_PARAM *rsa_settable_ctx_params(void)
1112 {
1113 /*
1114 * TODO(3.0): Should this function return a different set of settable ctx
1115 * params if the ctx is being used for a DigestSign/DigestVerify? In that
1116 * case it is not allowed to set the digest size/digest name because the
1117 * digest is explicitly set as part of the init.
1118 */
1119 return known_settable_ctx_params;
1120 }
1121
1122 static int rsa_get_ctx_md_params(void *vprsactx, OSSL_PARAM *params)
1123 {
1124 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
1125
1126 if (prsactx->mdctx == NULL)
1127 return 0;
1128
1129 return EVP_MD_CTX_get_params(prsactx->mdctx, params);
1130 }
1131
1132 static const OSSL_PARAM *rsa_gettable_ctx_md_params(void *vprsactx)
1133 {
1134 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
1135
1136 if (prsactx->md == NULL)
1137 return 0;
1138
1139 return EVP_MD_gettable_ctx_params(prsactx->md);
1140 }
1141
1142 static int rsa_set_ctx_md_params(void *vprsactx, const OSSL_PARAM params[])
1143 {
1144 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
1145
1146 if (prsactx->mdctx == NULL)
1147 return 0;
1148
1149 return EVP_MD_CTX_set_params(prsactx->mdctx, params);
1150 }
1151
1152 static const OSSL_PARAM *rsa_settable_ctx_md_params(void *vprsactx)
1153 {
1154 PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx;
1155
1156 if (prsactx->md == NULL)
1157 return 0;
1158
1159 return EVP_MD_settable_ctx_params(prsactx->md);
1160 }
1161
1162 const OSSL_DISPATCH rsa_signature_functions[] = {
1163 { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))rsa_newctx },
1164 { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))rsa_sign_init },
1165 { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))rsa_sign },
1166 { OSSL_FUNC_SIGNATURE_VERIFY_INIT, (void (*)(void))rsa_verify_init },
1167 { OSSL_FUNC_SIGNATURE_VERIFY, (void (*)(void))rsa_verify },
1168 { OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT,
1169 (void (*)(void))rsa_verify_recover_init },
1170 { OSSL_FUNC_SIGNATURE_VERIFY_RECOVER,
1171 (void (*)(void))rsa_verify_recover },
1172 { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT,
1173 (void (*)(void))rsa_digest_sign_init },
1174 { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE,
1175 (void (*)(void))rsa_digest_signverify_update },
1176 { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL,
1177 (void (*)(void))rsa_digest_sign_final },
1178 { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT,
1179 (void (*)(void))rsa_digest_verify_init },
1180 { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE,
1181 (void (*)(void))rsa_digest_signverify_update },
1182 { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL,
1183 (void (*)(void))rsa_digest_verify_final },
1184 { OSSL_FUNC_SIGNATURE_FREECTX, (void (*)(void))rsa_freectx },
1185 { OSSL_FUNC_SIGNATURE_DUPCTX, (void (*)(void))rsa_dupctx },
1186 { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS, (void (*)(void))rsa_get_ctx_params },
1187 { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS,
1188 (void (*)(void))rsa_gettable_ctx_params },
1189 { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS, (void (*)(void))rsa_set_ctx_params },
1190 { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS,
1191 (void (*)(void))rsa_settable_ctx_params },
1192 { OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS,
1193 (void (*)(void))rsa_get_ctx_md_params },
1194 { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS,
1195 (void (*)(void))rsa_gettable_ctx_md_params },
1196 { OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS,
1197 (void (*)(void))rsa_set_ctx_md_params },
1198 { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS,
1199 (void (*)(void))rsa_settable_ctx_md_params },
1200 { 0, NULL }
1201 };