2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
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
11 * RSA low level APIs are deprecated for public use, but still ok for
14 #include "internal/deprecated.h"
17 #include <openssl/crypto.h>
18 #include <openssl/core_dispatch.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/providercommon.h"
29 #include "prov/providercommonerr.h"
30 #include "prov/implementations.h"
31 #include "prov/provider_ctx.h"
32 #include "prov/der_rsa.h"
34 static OSSL_FUNC_signature_newctx_fn rsa_newctx
;
35 static OSSL_FUNC_signature_sign_init_fn rsa_sign_init
;
36 static OSSL_FUNC_signature_verify_init_fn rsa_verify_init
;
37 static OSSL_FUNC_signature_verify_recover_init_fn rsa_verify_recover_init
;
38 static OSSL_FUNC_signature_sign_fn rsa_sign
;
39 static OSSL_FUNC_signature_verify_fn rsa_verify
;
40 static OSSL_FUNC_signature_verify_recover_fn rsa_verify_recover
;
41 static OSSL_FUNC_signature_digest_sign_init_fn rsa_digest_sign_init
;
42 static OSSL_FUNC_signature_digest_sign_update_fn rsa_digest_signverify_update
;
43 static OSSL_FUNC_signature_digest_sign_final_fn rsa_digest_sign_final
;
44 static OSSL_FUNC_signature_digest_verify_init_fn rsa_digest_verify_init
;
45 static OSSL_FUNC_signature_digest_verify_update_fn rsa_digest_signverify_update
;
46 static OSSL_FUNC_signature_digest_verify_final_fn rsa_digest_verify_final
;
47 static OSSL_FUNC_signature_freectx_fn rsa_freectx
;
48 static OSSL_FUNC_signature_dupctx_fn rsa_dupctx
;
49 static OSSL_FUNC_signature_get_ctx_params_fn rsa_get_ctx_params
;
50 static OSSL_FUNC_signature_gettable_ctx_params_fn rsa_gettable_ctx_params
;
51 static OSSL_FUNC_signature_set_ctx_params_fn rsa_set_ctx_params
;
52 static OSSL_FUNC_signature_settable_ctx_params_fn rsa_settable_ctx_params
;
53 static OSSL_FUNC_signature_get_ctx_md_params_fn rsa_get_ctx_md_params
;
54 static OSSL_FUNC_signature_gettable_ctx_md_params_fn rsa_gettable_ctx_md_params
;
55 static OSSL_FUNC_signature_set_ctx_md_params_fn rsa_set_ctx_md_params
;
56 static OSSL_FUNC_signature_settable_ctx_md_params_fn rsa_settable_ctx_md_params
;
58 static OSSL_ITEM padding_item
[] = {
59 { RSA_PKCS1_PADDING
, OSSL_PKEY_RSA_PAD_MODE_PKCSV15
},
60 { RSA_SSLV23_PADDING
, OSSL_PKEY_RSA_PAD_MODE_SSLV23
},
61 { RSA_NO_PADDING
, OSSL_PKEY_RSA_PAD_MODE_NONE
},
62 { RSA_X931_PADDING
, OSSL_PKEY_RSA_PAD_MODE_X931
},
63 { RSA_PKCS1_PSS_PADDING
, OSSL_PKEY_RSA_PAD_MODE_PSS
},
68 * What's passed as an actual key is defined by the KEYMGMT interface.
69 * We happen to know that our KEYMGMT simply passes RSA structures, so
70 * we use that here too.
80 * Flag to determine if the hash function can be changed (1) or not (0)
81 * Because it's dangerous to change during a DigestSign or DigestVerify
82 * operation, this flag is cleared by their Init function, and set again
83 * by their Final function.
85 unsigned int flag_allow_md
: 1;
87 /* The Algorithm Identifier of the combined signature agorithm */
88 unsigned char aid_buf
[128];
96 char mdname
[OSSL_MAX_NAME_SIZE
]; /* Purely informational */
98 /* RSA padding mode */
100 /* message digest for MGF1 */
102 char mgf1_mdname
[OSSL_MAX_NAME_SIZE
]; /* Purely informational */
103 /* PSS salt length */
105 /* Minimum salt length or -1 if no PSS parameter restriction */
113 static size_t rsa_get_md_size(const PROV_RSA_CTX
*prsactx
)
115 if (prsactx
->md
!= NULL
)
116 return EVP_MD_size(prsactx
->md
);
120 static int rsa_get_md_nid(const EVP_MD
*md
)
123 * Because the RSA library deals with NIDs, we need to translate.
124 * We do so using EVP_MD_is_a(), and therefore need a name to NID
127 static const OSSL_ITEM name_to_nid
[] = {
128 { NID_sha1
, OSSL_DIGEST_NAME_SHA1
},
129 { NID_sha224
, OSSL_DIGEST_NAME_SHA2_224
},
130 { NID_sha256
, OSSL_DIGEST_NAME_SHA2_256
},
131 { NID_sha384
, OSSL_DIGEST_NAME_SHA2_384
},
132 { NID_sha512
, OSSL_DIGEST_NAME_SHA2_512
},
133 { NID_sha512_224
, OSSL_DIGEST_NAME_SHA2_512_224
},
134 { NID_sha512_256
, OSSL_DIGEST_NAME_SHA2_512_256
},
135 { NID_md5
, OSSL_DIGEST_NAME_MD5
},
136 { NID_md5_sha1
, OSSL_DIGEST_NAME_MD5_SHA1
},
137 { NID_md2
, OSSL_DIGEST_NAME_MD2
},
138 { NID_md4
, OSSL_DIGEST_NAME_MD4
},
139 { NID_mdc2
, OSSL_DIGEST_NAME_MDC2
},
140 { NID_ripemd160
, OSSL_DIGEST_NAME_RIPEMD160
},
141 { NID_sha3_224
, OSSL_DIGEST_NAME_SHA3_224
},
142 { NID_sha3_256
, OSSL_DIGEST_NAME_SHA3_256
},
143 { NID_sha3_384
, OSSL_DIGEST_NAME_SHA3_384
},
144 { NID_sha3_512
, OSSL_DIGEST_NAME_SHA3_512
},
147 int mdnid
= NID_undef
;
152 for (i
= 0; i
< OSSL_NELEM(name_to_nid
); i
++) {
153 if (EVP_MD_is_a(md
, name_to_nid
[i
].ptr
)) {
154 mdnid
= (int)name_to_nid
[i
].id
;
163 static int rsa_check_padding(int mdnid
, int padding
)
165 if (padding
== RSA_NO_PADDING
) {
166 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_PADDING_MODE
);
170 if (padding
== RSA_X931_PADDING
) {
171 if (RSA_X931_hash_id(mdnid
) == -1) {
172 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_X931_DIGEST
);
180 static int rsa_check_parameters(PROV_RSA_CTX
*prsactx
)
182 if (prsactx
->pad_mode
== RSA_PKCS1_PSS_PADDING
) {
185 /* See if minimum salt length exceeds maximum possible */
186 max_saltlen
= RSA_size(prsactx
->rsa
) - EVP_MD_size(prsactx
->md
);
187 if ((RSA_bits(prsactx
->rsa
) & 0x7) == 1)
189 if (prsactx
->min_saltlen
< 0 || prsactx
->min_saltlen
> max_saltlen
) {
190 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_SALT_LENGTH
);
197 static void *rsa_newctx(void *provctx
, const char *propq
)
199 PROV_RSA_CTX
*prsactx
= NULL
;
200 char *propq_copy
= NULL
;
202 if (!ossl_prov_is_running())
205 if ((prsactx
= OPENSSL_zalloc(sizeof(PROV_RSA_CTX
))) == NULL
207 && (propq_copy
= OPENSSL_strdup(propq
)) == NULL
)) {
208 OPENSSL_free(prsactx
);
209 ERR_raise(ERR_LIB_PROV
, ERR_R_MALLOC_FAILURE
);
213 prsactx
->libctx
= PROV_LIBRARY_CONTEXT_OF(provctx
);
214 prsactx
->flag_allow_md
= 1;
215 prsactx
->propq
= propq_copy
;
219 /* True if PSS parameters are restricted */
220 #define rsa_pss_restricted(prsactx) (prsactx->min_saltlen != -1)
222 static int rsa_setup_md(PROV_RSA_CTX
*ctx
, const char *mdname
,
226 mdprops
= ctx
->propq
;
228 if (mdname
!= NULL
) {
229 EVP_MD
*md
= EVP_MD_fetch(ctx
->libctx
, mdname
, mdprops
);
230 int md_nid
= rsa_get_md_nid(md
);
232 size_t mdname_len
= strlen(mdname
);
235 || md_nid
== NID_undef
236 || !rsa_check_padding(md_nid
, ctx
->pad_mode
)
237 || mdname_len
>= sizeof(ctx
->mdname
)) {
239 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
240 "%s could not be fetched", mdname
);
241 if (md_nid
== NID_undef
)
242 ERR_raise_data(ERR_LIB_PROV
, PROV_R_DIGEST_NOT_ALLOWED
,
243 "digest=%s", mdname
);
244 if (mdname_len
>= sizeof(ctx
->mdname
))
245 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
246 "%s exceeds name buffer length", mdname
);
251 EVP_MD_CTX_free(ctx
->mdctx
);
252 EVP_MD_free(ctx
->md
);
255 * TODO(3.0) Should we care about DER writing errors?
256 * All it really means is that for some reason, there's no
257 * AlgorithmIdentifier to be had (consider RSA with MD5-SHA1),
258 * but the operation itself is still valid, just as long as it's
259 * not used to construct anything that needs an AlgorithmIdentifier.
262 if (WPACKET_init_der(&pkt
, ctx
->aid_buf
, sizeof(ctx
->aid_buf
))
263 && DER_w_algorithmIdentifier_MDWithRSAEncryption(&pkt
, -1, ctx
->rsa
,
265 && WPACKET_finish(&pkt
)) {
266 WPACKET_get_total_written(&pkt
, &ctx
->aid_len
);
267 ctx
->aid
= WPACKET_get_curr(&pkt
);
269 WPACKET_cleanup(&pkt
);
274 OPENSSL_strlcpy(ctx
->mdname
, mdname
, sizeof(ctx
->mdname
));
280 static int rsa_setup_mgf1_md(PROV_RSA_CTX
*ctx
, const char *mdname
,
286 mdprops
= ctx
->propq
;
288 if (ctx
->mgf1_mdname
[0] != '\0')
289 EVP_MD_free(ctx
->mgf1_md
);
291 if ((ctx
->mgf1_md
= EVP_MD_fetch(ctx
->libctx
, mdname
, mdprops
)) == NULL
) {
292 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
293 "%s could not be fetched", mdname
);
296 len
= OPENSSL_strlcpy(ctx
->mgf1_mdname
, mdname
, sizeof(ctx
->mgf1_mdname
));
297 if (len
>= sizeof(ctx
->mgf1_mdname
)) {
298 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
299 "%s exceeds name buffer length", mdname
);
306 static int rsa_signature_init(void *vprsactx
, void *vrsa
, int operation
)
308 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
310 if (!ossl_prov_is_running())
313 if (prsactx
== NULL
|| vrsa
== NULL
|| !RSA_up_ref(vrsa
))
316 RSA_free(prsactx
->rsa
);
318 prsactx
->operation
= operation
;
320 /* Maximum for sign, auto for verify */
321 prsactx
->saltlen
= RSA_PSS_SALTLEN_AUTO
;
322 prsactx
->min_saltlen
= -1;
324 switch (RSA_test_flags(prsactx
->rsa
, RSA_FLAG_TYPE_MASK
)) {
325 case RSA_FLAG_TYPE_RSA
:
326 prsactx
->pad_mode
= RSA_PKCS1_PADDING
;
328 case RSA_FLAG_TYPE_RSASSAPSS
:
329 prsactx
->pad_mode
= RSA_PKCS1_PSS_PADDING
;
332 const RSA_PSS_PARAMS_30
*pss
=
333 rsa_get0_pss_params_30(prsactx
->rsa
);
335 if (!rsa_pss_params_30_is_unrestricted(pss
)) {
336 int md_nid
= rsa_pss_params_30_hashalg(pss
);
337 int mgf1md_nid
= rsa_pss_params_30_maskgenhashalg(pss
);
338 int min_saltlen
= rsa_pss_params_30_saltlen(pss
);
339 const char *mdname
, *mgf1mdname
;
342 mdname
= rsa_oaeppss_nid2name(md_nid
);
343 mgf1mdname
= rsa_oaeppss_nid2name(mgf1md_nid
);
344 prsactx
->min_saltlen
= min_saltlen
;
346 if (mdname
== NULL
) {
347 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
348 "PSS restrictions lack hash algorithm");
351 if (mgf1mdname
== NULL
) {
352 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
353 "PSS restrictions lack MGF1 hash algorithm");
357 len
= OPENSSL_strlcpy(prsactx
->mdname
, mdname
,
358 sizeof(prsactx
->mdname
));
359 if (len
>= sizeof(prsactx
->mdname
)) {
360 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
361 "hash algorithm name too long");
364 len
= OPENSSL_strlcpy(prsactx
->mgf1_mdname
, mgf1mdname
,
365 sizeof(prsactx
->mgf1_mdname
));
366 if (len
>= sizeof(prsactx
->mgf1_mdname
)) {
367 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST
,
368 "MGF1 hash algorithm name too long");
371 prsactx
->saltlen
= min_saltlen
;
373 return rsa_setup_md(prsactx
, mdname
, prsactx
->propq
)
374 && rsa_setup_mgf1_md(prsactx
, mgf1mdname
, prsactx
->propq
)
375 && rsa_check_parameters(prsactx
);
381 ERR_raise(ERR_LIB_RSA
, PROV_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE
);
388 static int setup_tbuf(PROV_RSA_CTX
*ctx
)
390 if (ctx
->tbuf
!= NULL
)
392 if ((ctx
->tbuf
= OPENSSL_malloc(RSA_size(ctx
->rsa
))) == NULL
) {
393 ERR_raise(ERR_LIB_PROV
, ERR_R_MALLOC_FAILURE
);
399 static void clean_tbuf(PROV_RSA_CTX
*ctx
)
401 if (ctx
->tbuf
!= NULL
)
402 OPENSSL_cleanse(ctx
->tbuf
, RSA_size(ctx
->rsa
));
405 static void free_tbuf(PROV_RSA_CTX
*ctx
)
408 OPENSSL_free(ctx
->tbuf
);
412 static int rsa_sign_init(void *vprsactx
, void *vrsa
)
414 if (!ossl_prov_is_running())
416 return rsa_signature_init(vprsactx
, vrsa
, EVP_PKEY_OP_SIGN
);
419 static int rsa_sign(void *vprsactx
, unsigned char *sig
, size_t *siglen
,
420 size_t sigsize
, const unsigned char *tbs
, size_t tbslen
)
422 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
424 size_t rsasize
= RSA_size(prsactx
->rsa
);
425 size_t mdsize
= rsa_get_md_size(prsactx
);
427 if (!ossl_prov_is_running())
435 if (sigsize
< rsasize
) {
436 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_SIGNATURE_SIZE
,
437 "is %zu, should be at least %zu", sigsize
, rsasize
);
442 if (tbslen
!= mdsize
) {
443 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST_LENGTH
);
448 if (EVP_MD_is_a(prsactx
->md
, OSSL_DIGEST_NAME_MDC2
)) {
451 if (prsactx
->pad_mode
!= RSA_PKCS1_PADDING
) {
452 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_PADDING_MODE
,
453 "only PKCS#1 padding supported with MDC2");
456 ret
= RSA_sign_ASN1_OCTET_STRING(0, tbs
, tbslen
, sig
, &sltmp
,
460 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
467 switch (prsactx
->pad_mode
) {
468 case RSA_X931_PADDING
:
469 if ((size_t)RSA_size(prsactx
->rsa
) < tbslen
+ 1) {
470 ERR_raise_data(ERR_LIB_PROV
, PROV_R_KEY_SIZE_TOO_SMALL
,
471 "RSA key size = %d, expected minimum = %d",
472 RSA_size(prsactx
->rsa
), tbslen
+ 1);
475 if (!setup_tbuf(prsactx
)) {
476 ERR_raise(ERR_LIB_PROV
, ERR_R_MALLOC_FAILURE
);
479 memcpy(prsactx
->tbuf
, tbs
, tbslen
);
480 prsactx
->tbuf
[tbslen
] = RSA_X931_hash_id(prsactx
->mdnid
);
481 ret
= RSA_private_encrypt(tbslen
+ 1, prsactx
->tbuf
,
482 sig
, prsactx
->rsa
, RSA_X931_PADDING
);
486 case RSA_PKCS1_PADDING
:
490 ret
= RSA_sign(prsactx
->mdnid
, tbs
, tbslen
, sig
, &sltmp
,
493 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
500 case RSA_PKCS1_PSS_PADDING
:
501 /* Check PSS restrictions */
502 if (rsa_pss_restricted(prsactx
)) {
503 switch (prsactx
->saltlen
) {
504 case RSA_PSS_SALTLEN_DIGEST
:
505 if (prsactx
->min_saltlen
> EVP_MD_size(prsactx
->md
)) {
506 ERR_raise_data(ERR_LIB_PROV
,
507 PROV_R_PSS_SALTLEN_TOO_SMALL
,
508 "minimum salt length set to %d, "
509 "but the digest only gives %d",
510 prsactx
->min_saltlen
,
511 EVP_MD_size(prsactx
->md
));
516 if (prsactx
->saltlen
>= 0
517 && prsactx
->saltlen
< prsactx
->min_saltlen
) {
518 ERR_raise_data(ERR_LIB_PROV
,
519 PROV_R_PSS_SALTLEN_TOO_SMALL
,
520 "minimum salt length set to %d, but the"
521 "actual salt length is only set to %d",
522 prsactx
->min_saltlen
,
529 if (!setup_tbuf(prsactx
))
531 if (!RSA_padding_add_PKCS1_PSS_mgf1(prsactx
->rsa
,
533 prsactx
->md
, prsactx
->mgf1_md
,
535 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
538 ret
= RSA_private_encrypt(RSA_size(prsactx
->rsa
), prsactx
->tbuf
,
539 sig
, prsactx
->rsa
, RSA_NO_PADDING
);
544 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_PADDING_MODE
,
545 "Only X.931, PKCS#1 v1.5 or PSS padding allowed");
549 ret
= RSA_private_encrypt(tbslen
, tbs
, sig
, prsactx
->rsa
,
557 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
565 static int rsa_verify_recover_init(void *vprsactx
, void *vrsa
)
567 if (!ossl_prov_is_running())
569 return rsa_signature_init(vprsactx
, vrsa
, EVP_PKEY_OP_VERIFYRECOVER
);
572 static int rsa_verify_recover(void *vprsactx
,
576 const unsigned char *sig
,
579 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
582 if (!ossl_prov_is_running())
586 *routlen
= RSA_size(prsactx
->rsa
);
590 if (prsactx
->md
!= NULL
) {
591 switch (prsactx
->pad_mode
) {
592 case RSA_X931_PADDING
:
593 if (!setup_tbuf(prsactx
))
595 ret
= RSA_public_decrypt(siglen
, sig
, prsactx
->tbuf
, prsactx
->rsa
,
598 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
602 if (prsactx
->tbuf
[ret
] != RSA_X931_hash_id(prsactx
->mdnid
)) {
603 ERR_raise(ERR_LIB_PROV
, PROV_R_ALGORITHM_MISMATCH
);
606 if (ret
!= EVP_MD_size(prsactx
->md
)) {
607 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST_LENGTH
,
608 "Should be %d, but got %d",
609 EVP_MD_size(prsactx
->md
), ret
);
614 if (rout
!= prsactx
->tbuf
) {
615 if (routsize
< (size_t)ret
) {
616 ERR_raise_data(ERR_LIB_PROV
, PROV_R_OUTPUT_BUFFER_TOO_SMALL
,
617 "buffer size is %d, should be %d",
621 memcpy(rout
, prsactx
->tbuf
, ret
);
625 case RSA_PKCS1_PADDING
:
629 ret
= int_rsa_verify(prsactx
->mdnid
, NULL
, 0, rout
, &sltmp
,
630 sig
, siglen
, prsactx
->rsa
);
632 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
640 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_PADDING_MODE
,
641 "Only X.931 or PKCS#1 v1.5 padding allowed");
645 ret
= RSA_public_decrypt(siglen
, sig
, rout
, prsactx
->rsa
,
648 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
656 static int rsa_verify_init(void *vprsactx
, void *vrsa
)
658 if (!ossl_prov_is_running())
660 return rsa_signature_init(vprsactx
, vrsa
, EVP_PKEY_OP_VERIFY
);
663 static int rsa_verify(void *vprsactx
, const unsigned char *sig
, size_t siglen
,
664 const unsigned char *tbs
, size_t tbslen
)
666 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
669 if (!ossl_prov_is_running())
671 if (prsactx
->md
!= NULL
) {
672 switch (prsactx
->pad_mode
) {
673 case RSA_PKCS1_PADDING
:
674 if (!RSA_verify(prsactx
->mdnid
, tbs
, tbslen
, sig
, siglen
,
676 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
680 case RSA_X931_PADDING
:
681 if (!setup_tbuf(prsactx
))
683 if (rsa_verify_recover(prsactx
, prsactx
->tbuf
, &rslen
, 0,
687 case RSA_PKCS1_PSS_PADDING
:
693 * We need to check this for the RSA_verify_PKCS1_PSS_mgf1()
696 mdsize
= rsa_get_md_size(prsactx
);
697 if (tbslen
!= mdsize
) {
698 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_DIGEST_LENGTH
,
699 "Should be %d, but got %d",
704 if (!setup_tbuf(prsactx
))
706 ret
= RSA_public_decrypt(siglen
, sig
, prsactx
->tbuf
,
707 prsactx
->rsa
, RSA_NO_PADDING
);
709 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
712 ret
= RSA_verify_PKCS1_PSS_mgf1(prsactx
->rsa
, tbs
,
713 prsactx
->md
, prsactx
->mgf1_md
,
717 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
723 ERR_raise_data(ERR_LIB_PROV
, PROV_R_INVALID_PADDING_MODE
,
724 "Only X.931, PKCS#1 v1.5 or PSS padding allowed");
728 if (!setup_tbuf(prsactx
))
730 rslen
= RSA_public_decrypt(siglen
, sig
, prsactx
->tbuf
, prsactx
->rsa
,
733 ERR_raise(ERR_LIB_PROV
, ERR_LIB_RSA
);
738 if ((rslen
!= tbslen
) || memcmp(tbs
, prsactx
->tbuf
, rslen
))
744 static int rsa_digest_signverify_init(void *vprsactx
, const char *mdname
,
745 void *vrsa
, int operation
)
747 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
749 if (!ossl_prov_is_running())
753 prsactx
->flag_allow_md
= 0;
754 if (!rsa_signature_init(vprsactx
, vrsa
, operation
)
755 || !rsa_setup_md(prsactx
, mdname
, NULL
)) /* TODO RL */
758 prsactx
->mdctx
= EVP_MD_CTX_new();
759 if (prsactx
->mdctx
== NULL
) {
760 ERR_raise(ERR_LIB_PROV
, ERR_R_MALLOC_FAILURE
);
764 if (!EVP_DigestInit_ex(prsactx
->mdctx
, prsactx
->md
, NULL
))
770 EVP_MD_CTX_free(prsactx
->mdctx
);
771 EVP_MD_free(prsactx
->md
);
772 prsactx
->mdctx
= NULL
;
777 static int rsa_digest_signverify_update(void *vprsactx
,
778 const unsigned char *data
,
781 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
783 if (prsactx
== NULL
|| prsactx
->mdctx
== NULL
)
786 return EVP_DigestUpdate(prsactx
->mdctx
, data
, datalen
);
789 static int rsa_digest_sign_init(void *vprsactx
, const char *mdname
,
792 if (!ossl_prov_is_running())
794 return rsa_digest_signverify_init(vprsactx
, mdname
, vrsa
,
798 static int rsa_digest_sign_final(void *vprsactx
, unsigned char *sig
,
799 size_t *siglen
, size_t sigsize
)
801 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
802 unsigned char digest
[EVP_MAX_MD_SIZE
];
803 unsigned int dlen
= 0;
805 if (!ossl_prov_is_running() || prsactx
== NULL
)
807 prsactx
->flag_allow_md
= 1;
808 if (prsactx
->mdctx
== NULL
)
811 * If sig is NULL then we're just finding out the sig size. Other fields
812 * are ignored. Defer to rsa_sign.
816 * TODO(3.0): There is the possibility that some externally provided
817 * digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow -
818 * but that problem is much larger than just in RSA.
820 if (!EVP_DigestFinal_ex(prsactx
->mdctx
, digest
, &dlen
))
824 return rsa_sign(vprsactx
, sig
, siglen
, sigsize
, digest
, (size_t)dlen
);
827 static int rsa_digest_verify_init(void *vprsactx
, const char *mdname
,
830 if (!ossl_prov_is_running())
832 return rsa_digest_signverify_init(vprsactx
, mdname
, vrsa
,
836 int rsa_digest_verify_final(void *vprsactx
, const unsigned char *sig
,
839 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
840 unsigned char digest
[EVP_MAX_MD_SIZE
];
841 unsigned int dlen
= 0;
843 if (!ossl_prov_is_running())
848 prsactx
->flag_allow_md
= 1;
849 if (prsactx
->mdctx
== NULL
)
853 * TODO(3.0): There is the possibility that some externally provided
854 * digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow -
855 * but that problem is much larger than just in RSA.
857 if (!EVP_DigestFinal_ex(prsactx
->mdctx
, digest
, &dlen
))
860 return rsa_verify(vprsactx
, sig
, siglen
, digest
, (size_t)dlen
);
863 static void rsa_freectx(void *vprsactx
)
865 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
870 EVP_MD_CTX_free(prsactx
->mdctx
);
871 EVP_MD_free(prsactx
->md
);
872 EVP_MD_free(prsactx
->mgf1_md
);
873 OPENSSL_free(prsactx
->propq
);
875 RSA_free(prsactx
->rsa
);
877 OPENSSL_clear_free(prsactx
, sizeof(*prsactx
));
880 static void *rsa_dupctx(void *vprsactx
)
882 PROV_RSA_CTX
*srcctx
= (PROV_RSA_CTX
*)vprsactx
;
883 PROV_RSA_CTX
*dstctx
;
885 if (!ossl_prov_is_running())
888 dstctx
= OPENSSL_zalloc(sizeof(*srcctx
));
889 if (dstctx
== NULL
) {
890 ERR_raise(ERR_LIB_PROV
, ERR_R_MALLOC_FAILURE
);
897 dstctx
->mdctx
= NULL
;
900 if (srcctx
->rsa
!= NULL
&& !RSA_up_ref(srcctx
->rsa
))
902 dstctx
->rsa
= srcctx
->rsa
;
904 if (srcctx
->md
!= NULL
&& !EVP_MD_up_ref(srcctx
->md
))
906 dstctx
->md
= srcctx
->md
;
908 if (srcctx
->mgf1_md
!= NULL
&& !EVP_MD_up_ref(srcctx
->mgf1_md
))
910 dstctx
->mgf1_md
= srcctx
->mgf1_md
;
912 if (srcctx
->mdctx
!= NULL
) {
913 dstctx
->mdctx
= EVP_MD_CTX_new();
914 if (dstctx
->mdctx
== NULL
915 || !EVP_MD_CTX_copy_ex(dstctx
->mdctx
, srcctx
->mdctx
))
925 static int rsa_get_ctx_params(void *vprsactx
, OSSL_PARAM
*params
)
927 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
930 if (prsactx
== NULL
|| params
== NULL
)
933 p
= OSSL_PARAM_locate(params
, OSSL_SIGNATURE_PARAM_ALGORITHM_ID
);
935 && !OSSL_PARAM_set_octet_string(p
, prsactx
->aid
, prsactx
->aid_len
))
938 p
= OSSL_PARAM_locate(params
, OSSL_SIGNATURE_PARAM_PAD_MODE
);
940 switch (p
->data_type
) {
941 case OSSL_PARAM_INTEGER
:
942 if (!OSSL_PARAM_set_int(p
, prsactx
->pad_mode
))
945 case OSSL_PARAM_UTF8_STRING
:
948 const char *word
= NULL
;
950 for (i
= 0; padding_item
[i
].id
!= 0; i
++) {
951 if (prsactx
->pad_mode
== (int)padding_item
[i
].id
) {
952 word
= padding_item
[i
].ptr
;
958 if (!OSSL_PARAM_set_utf8_string(p
, word
))
961 ERR_raise(ERR_LIB_PROV
, ERR_R_INTERNAL_ERROR
);
969 p
= OSSL_PARAM_locate(params
, OSSL_SIGNATURE_PARAM_DIGEST
);
970 if (p
!= NULL
&& !OSSL_PARAM_set_utf8_string(p
, prsactx
->mdname
))
973 p
= OSSL_PARAM_locate(params
, OSSL_SIGNATURE_PARAM_MGF1_DIGEST
);
974 if (p
!= NULL
&& !OSSL_PARAM_set_utf8_string(p
, prsactx
->mgf1_mdname
))
977 p
= OSSL_PARAM_locate(params
, OSSL_SIGNATURE_PARAM_PSS_SALTLEN
);
979 if (p
->data_type
== OSSL_PARAM_INTEGER
) {
980 if (!OSSL_PARAM_set_int(p
, prsactx
->saltlen
))
982 } else if (p
->data_type
== OSSL_PARAM_UTF8_STRING
) {
983 const char *value
= NULL
;
985 switch (prsactx
->saltlen
) {
986 case RSA_PSS_SALTLEN_DIGEST
:
987 value
= OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST
;
989 case RSA_PSS_SALTLEN_MAX
:
990 value
= OSSL_PKEY_RSA_PSS_SALT_LEN_MAX
;
992 case RSA_PSS_SALTLEN_AUTO
:
993 value
= OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO
;
997 int len
= BIO_snprintf(p
->data
, p
->data_size
, "%d",
1002 p
->return_size
= len
;
1007 && !OSSL_PARAM_set_utf8_string(p
, value
))
1015 static const OSSL_PARAM known_gettable_ctx_params
[] = {
1016 OSSL_PARAM_octet_string(OSSL_SIGNATURE_PARAM_ALGORITHM_ID
, NULL
, 0),
1017 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PAD_MODE
, NULL
, 0),
1018 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST
, NULL
, 0),
1019 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_DIGEST
, NULL
, 0),
1020 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PSS_SALTLEN
, NULL
, 0),
1024 static const OSSL_PARAM
*rsa_gettable_ctx_params(ossl_unused
void *provctx
)
1026 return known_gettable_ctx_params
;
1029 static int rsa_set_ctx_params(void *vprsactx
, const OSSL_PARAM params
[])
1031 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
1032 const OSSL_PARAM
*p
;
1034 if (prsactx
== NULL
|| params
== NULL
)
1037 p
= OSSL_PARAM_locate_const(params
, OSSL_SIGNATURE_PARAM_DIGEST
);
1038 /* Not allowed during certain operations */
1039 if (p
!= NULL
&& !prsactx
->flag_allow_md
)
1042 char mdname
[OSSL_MAX_NAME_SIZE
] = "", *pmdname
= mdname
;
1043 char mdprops
[OSSL_MAX_PROPQUERY_SIZE
] = "", *pmdprops
= mdprops
;
1044 const OSSL_PARAM
*propsp
=
1045 OSSL_PARAM_locate_const(params
,
1046 OSSL_SIGNATURE_PARAM_PROPERTIES
);
1048 if (!OSSL_PARAM_get_utf8_string(p
, &pmdname
, sizeof(mdname
)))
1053 else if (!OSSL_PARAM_get_utf8_string(propsp
,
1054 &pmdprops
, sizeof(mdprops
)))
1057 if (rsa_pss_restricted(prsactx
)) {
1058 /* TODO(3.0) figure out what to do for prsactx->md == NULL */
1059 if (prsactx
->md
== NULL
|| EVP_MD_is_a(prsactx
->md
, mdname
))
1061 ERR_raise(ERR_LIB_PROV
, PROV_R_DIGEST_NOT_ALLOWED
);
1065 /* non-PSS code follows */
1066 if (!rsa_setup_md(prsactx
, mdname
, pmdprops
))
1070 p
= OSSL_PARAM_locate_const(params
, OSSL_SIGNATURE_PARAM_PAD_MODE
);
1073 const char *err_extra_text
= NULL
;
1075 switch (p
->data_type
) {
1076 case OSSL_PARAM_INTEGER
: /* Support for legacy pad mode number */
1077 if (!OSSL_PARAM_get_int(p
, &pad_mode
))
1080 case OSSL_PARAM_UTF8_STRING
:
1084 if (p
->data
== NULL
)
1087 for (i
= 0; padding_item
[i
].id
!= 0; i
++) {
1088 if (strcmp(p
->data
, padding_item
[i
].ptr
) == 0) {
1089 pad_mode
= padding_item
[i
].id
;
1100 case RSA_PKCS1_OAEP_PADDING
:
1102 * OAEP padding is for asymmetric cipher only so is not compatible
1103 * with signature use.
1105 err_extra_text
= "OAEP padding not allowed for signing / verifying";
1107 case RSA_PKCS1_PSS_PADDING
:
1108 if ((prsactx
->operation
1109 & (EVP_PKEY_OP_SIGN
| EVP_PKEY_OP_VERIFY
)) == 0) {
1111 "PSS padding only allowed for sign and verify operations";
1114 if (prsactx
->md
== NULL
1115 && !rsa_setup_md(prsactx
, OSSL_DIGEST_NAME_SHA1
, NULL
)) {
1119 case RSA_PKCS1_PADDING
:
1120 err_extra_text
= "PKCS#1 padding not allowed with RSA-PSS";
1122 case RSA_SSLV23_PADDING
:
1123 err_extra_text
= "SSLv3 padding not allowed with RSA-PSS";
1125 case RSA_NO_PADDING
:
1126 err_extra_text
= "No padding not allowed with RSA-PSS";
1128 case RSA_X931_PADDING
:
1129 err_extra_text
= "X.931 padding not allowed with RSA-PSS";
1131 if (RSA_test_flags(prsactx
->rsa
,
1132 RSA_FLAG_TYPE_MASK
) == RSA_FLAG_TYPE_RSA
)
1137 if (err_extra_text
== NULL
)
1138 ERR_raise(ERR_LIB_PROV
,
1139 PROV_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE
);
1141 ERR_raise_data(ERR_LIB_PROV
,
1142 PROV_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE
,
1146 if (!rsa_check_padding(prsactx
->mdnid
, pad_mode
))
1148 prsactx
->pad_mode
= pad_mode
;
1151 p
= OSSL_PARAM_locate_const(params
, OSSL_SIGNATURE_PARAM_PSS_SALTLEN
);
1155 if (prsactx
->pad_mode
!= RSA_PKCS1_PSS_PADDING
) {
1156 ERR_raise_data(ERR_LIB_PROV
, PROV_R_NOT_SUPPORTED
,
1157 "PSS saltlen can only be specified if "
1158 "PSS padding has been specified first");
1162 switch (p
->data_type
) {
1163 case OSSL_PARAM_INTEGER
: /* Support for legacy pad mode number */
1164 if (!OSSL_PARAM_get_int(p
, &saltlen
))
1167 case OSSL_PARAM_UTF8_STRING
:
1168 if (strcmp(p
->data
, OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST
) == 0)
1169 saltlen
= RSA_PSS_SALTLEN_DIGEST
;
1170 else if (strcmp(p
->data
, OSSL_PKEY_RSA_PSS_SALT_LEN_MAX
) == 0)
1171 saltlen
= RSA_PSS_SALTLEN_MAX
;
1172 else if (strcmp(p
->data
, OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO
) == 0)
1173 saltlen
= RSA_PSS_SALTLEN_AUTO
;
1175 saltlen
= atoi(p
->data
);
1182 * RSA_PSS_SALTLEN_MAX seems curiously named in this check.
1183 * Contrary to what it's name suggests, it's the currently
1184 * lowest saltlen number possible.
1186 if (saltlen
< RSA_PSS_SALTLEN_MAX
) {
1187 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_PSS_SALTLEN
);
1191 if (rsa_pss_restricted(prsactx
)) {
1193 case RSA_PSS_SALTLEN_AUTO
:
1194 if (prsactx
->operation
== EVP_PKEY_OP_VERIFY
) {
1195 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_PSS_SALTLEN
);
1199 case RSA_PSS_SALTLEN_DIGEST
:
1200 if (prsactx
->min_saltlen
> EVP_MD_size(prsactx
->md
)) {
1201 ERR_raise_data(ERR_LIB_PROV
,
1202 PROV_R_PSS_SALTLEN_TOO_SMALL
,
1203 "Should be more than %d, but would be "
1204 "set to match digest size (%d)",
1205 prsactx
->min_saltlen
,
1206 EVP_MD_size(prsactx
->md
));
1211 if (saltlen
>= 0 && saltlen
< prsactx
->min_saltlen
) {
1212 ERR_raise_data(ERR_LIB_PROV
,
1213 PROV_R_PSS_SALTLEN_TOO_SMALL
,
1214 "Should be more than %d, "
1215 "but would be set to %d",
1216 prsactx
->min_saltlen
, saltlen
);
1222 prsactx
->saltlen
= saltlen
;
1225 p
= OSSL_PARAM_locate_const(params
, OSSL_SIGNATURE_PARAM_MGF1_DIGEST
);
1227 char mdname
[OSSL_MAX_NAME_SIZE
] = "", *pmdname
= mdname
;
1228 char mdprops
[OSSL_MAX_PROPQUERY_SIZE
] = "", *pmdprops
= mdprops
;
1229 const OSSL_PARAM
*propsp
=
1230 OSSL_PARAM_locate_const(params
,
1231 OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES
);
1233 if (!OSSL_PARAM_get_utf8_string(p
, &pmdname
, sizeof(mdname
)))
1238 else if (!OSSL_PARAM_get_utf8_string(propsp
,
1239 &pmdprops
, sizeof(mdprops
)))
1242 if (prsactx
->pad_mode
!= RSA_PKCS1_PSS_PADDING
) {
1243 ERR_raise(ERR_LIB_PROV
, PROV_R_INVALID_MGF1_MD
);
1247 if (rsa_pss_restricted(prsactx
)) {
1248 /* TODO(3.0) figure out what to do for prsactx->mgf1_md == NULL */
1249 if (prsactx
->mgf1_md
== NULL
1250 || EVP_MD_is_a(prsactx
->mgf1_md
, mdname
))
1252 ERR_raise(ERR_LIB_PROV
, PROV_R_DIGEST_NOT_ALLOWED
);
1256 /* non-PSS code follows */
1257 if (!rsa_setup_mgf1_md(prsactx
, mdname
, pmdprops
))
1264 static const OSSL_PARAM known_settable_ctx_params
[] = {
1265 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PAD_MODE
, NULL
, 0),
1266 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_DIGEST
, NULL
, 0),
1267 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PROPERTIES
, NULL
, 0),
1268 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_DIGEST
, NULL
, 0),
1269 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES
, NULL
, 0),
1270 OSSL_PARAM_utf8_string(OSSL_SIGNATURE_PARAM_PSS_SALTLEN
, NULL
, 0),
1274 static const OSSL_PARAM
*rsa_settable_ctx_params(ossl_unused
void *provctx
)
1277 * TODO(3.0): Should this function return a different set of settable ctx
1278 * params if the ctx is being used for a DigestSign/DigestVerify? In that
1279 * case it is not allowed to set the digest size/digest name because the
1280 * digest is explicitly set as part of the init.
1282 return known_settable_ctx_params
;
1285 static int rsa_get_ctx_md_params(void *vprsactx
, OSSL_PARAM
*params
)
1287 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
1289 if (prsactx
->mdctx
== NULL
)
1292 return EVP_MD_CTX_get_params(prsactx
->mdctx
, params
);
1295 static const OSSL_PARAM
*rsa_gettable_ctx_md_params(void *vprsactx
)
1297 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
1299 if (prsactx
->md
== NULL
)
1302 return EVP_MD_gettable_ctx_params(prsactx
->md
);
1305 static int rsa_set_ctx_md_params(void *vprsactx
, const OSSL_PARAM params
[])
1307 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
1309 if (prsactx
->mdctx
== NULL
)
1312 return EVP_MD_CTX_set_params(prsactx
->mdctx
, params
);
1315 static const OSSL_PARAM
*rsa_settable_ctx_md_params(void *vprsactx
)
1317 PROV_RSA_CTX
*prsactx
= (PROV_RSA_CTX
*)vprsactx
;
1319 if (prsactx
->md
== NULL
)
1322 return EVP_MD_settable_ctx_params(prsactx
->md
);
1325 const OSSL_DISPATCH rsa_signature_functions
[] = {
1326 { OSSL_FUNC_SIGNATURE_NEWCTX
, (void (*)(void))rsa_newctx
},
1327 { OSSL_FUNC_SIGNATURE_SIGN_INIT
, (void (*)(void))rsa_sign_init
},
1328 { OSSL_FUNC_SIGNATURE_SIGN
, (void (*)(void))rsa_sign
},
1329 { OSSL_FUNC_SIGNATURE_VERIFY_INIT
, (void (*)(void))rsa_verify_init
},
1330 { OSSL_FUNC_SIGNATURE_VERIFY
, (void (*)(void))rsa_verify
},
1331 { OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT
,
1332 (void (*)(void))rsa_verify_recover_init
},
1333 { OSSL_FUNC_SIGNATURE_VERIFY_RECOVER
,
1334 (void (*)(void))rsa_verify_recover
},
1335 { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT
,
1336 (void (*)(void))rsa_digest_sign_init
},
1337 { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE
,
1338 (void (*)(void))rsa_digest_signverify_update
},
1339 { OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL
,
1340 (void (*)(void))rsa_digest_sign_final
},
1341 { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT
,
1342 (void (*)(void))rsa_digest_verify_init
},
1343 { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE
,
1344 (void (*)(void))rsa_digest_signverify_update
},
1345 { OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL
,
1346 (void (*)(void))rsa_digest_verify_final
},
1347 { OSSL_FUNC_SIGNATURE_FREECTX
, (void (*)(void))rsa_freectx
},
1348 { OSSL_FUNC_SIGNATURE_DUPCTX
, (void (*)(void))rsa_dupctx
},
1349 { OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS
, (void (*)(void))rsa_get_ctx_params
},
1350 { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS
,
1351 (void (*)(void))rsa_gettable_ctx_params
},
1352 { OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS
, (void (*)(void))rsa_set_ctx_params
},
1353 { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS
,
1354 (void (*)(void))rsa_settable_ctx_params
},
1355 { OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS
,
1356 (void (*)(void))rsa_get_ctx_md_params
},
1357 { OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS
,
1358 (void (*)(void))rsa_gettable_ctx_md_params
},
1359 { OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS
,
1360 (void (*)(void))rsa_set_ctx_md_params
},
1361 { OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS
,
1362 (void (*)(void))rsa_settable_ctx_md_params
},