X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=providers%2Fimplementations%2Fsignature%2Frsa.c;h=ca1510e7185a3cbed8bd4411e9625bdd218e6eff;hb=b0aae913246af1d07e728d24f53f55028f61c696;hp=4dc3a89878cb716393e0253e73a0a45b4938d144;hpb=2d5536609ba92481daf42614a36bafb4e1d99293;p=thirdparty%2Fopenssl.git diff --git a/providers/implementations/signature/rsa.c b/providers/implementations/signature/rsa.c index 4dc3a89878..ca1510e718 100644 --- a/providers/implementations/signature/rsa.c +++ b/providers/implementations/signature/rsa.c @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -13,55 +13,57 @@ */ #include "internal/deprecated.h" +#include "e_os.h" /* strcasecmp */ #include #include -#include +#include #include #include #include #include #include +#include #include "internal/cryptlib.h" #include "internal/nelem.h" #include "internal/sizes.h" #include "crypto/rsa.h" -#include "prov/providercommonerr.h" +#include "prov/providercommon.h" #include "prov/implementations.h" #include "prov/provider_ctx.h" #include "prov/der_rsa.h" - -static OSSL_OP_signature_newctx_fn rsa_newctx; -static OSSL_OP_signature_sign_init_fn rsa_sign_init; -static OSSL_OP_signature_verify_init_fn rsa_verify_init; -static OSSL_OP_signature_verify_recover_init_fn rsa_verify_recover_init; -static OSSL_OP_signature_sign_fn rsa_sign; -static OSSL_OP_signature_verify_fn rsa_verify; -static OSSL_OP_signature_verify_recover_fn rsa_verify_recover; -static OSSL_OP_signature_digest_sign_init_fn rsa_digest_sign_init; -static OSSL_OP_signature_digest_sign_update_fn rsa_digest_signverify_update; -static OSSL_OP_signature_digest_sign_final_fn rsa_digest_sign_final; -static OSSL_OP_signature_digest_verify_init_fn rsa_digest_verify_init; -static OSSL_OP_signature_digest_verify_update_fn rsa_digest_signverify_update; -static OSSL_OP_signature_digest_verify_final_fn rsa_digest_verify_final; -static OSSL_OP_signature_freectx_fn rsa_freectx; -static OSSL_OP_signature_dupctx_fn rsa_dupctx; -static OSSL_OP_signature_get_ctx_params_fn rsa_get_ctx_params; -static OSSL_OP_signature_gettable_ctx_params_fn rsa_gettable_ctx_params; -static OSSL_OP_signature_set_ctx_params_fn rsa_set_ctx_params; -static OSSL_OP_signature_settable_ctx_params_fn rsa_settable_ctx_params; -static OSSL_OP_signature_get_ctx_md_params_fn rsa_get_ctx_md_params; -static OSSL_OP_signature_gettable_ctx_md_params_fn rsa_gettable_ctx_md_params; -static OSSL_OP_signature_set_ctx_md_params_fn rsa_set_ctx_md_params; -static OSSL_OP_signature_settable_ctx_md_params_fn rsa_settable_ctx_md_params; +#include "prov/securitycheck.h" + +#define RSA_DEFAULT_DIGEST_NAME OSSL_DIGEST_NAME_SHA1 + +static OSSL_FUNC_signature_newctx_fn rsa_newctx; +static OSSL_FUNC_signature_sign_init_fn rsa_sign_init; +static OSSL_FUNC_signature_verify_init_fn rsa_verify_init; +static OSSL_FUNC_signature_verify_recover_init_fn rsa_verify_recover_init; +static OSSL_FUNC_signature_sign_fn rsa_sign; +static OSSL_FUNC_signature_verify_fn rsa_verify; +static OSSL_FUNC_signature_verify_recover_fn rsa_verify_recover; +static OSSL_FUNC_signature_digest_sign_init_fn rsa_digest_sign_init; +static OSSL_FUNC_signature_digest_sign_update_fn rsa_digest_signverify_update; +static OSSL_FUNC_signature_digest_sign_final_fn rsa_digest_sign_final; +static OSSL_FUNC_signature_digest_verify_init_fn rsa_digest_verify_init; +static OSSL_FUNC_signature_digest_verify_update_fn rsa_digest_signverify_update; +static OSSL_FUNC_signature_digest_verify_final_fn rsa_digest_verify_final; +static OSSL_FUNC_signature_freectx_fn rsa_freectx; +static OSSL_FUNC_signature_dupctx_fn rsa_dupctx; +static OSSL_FUNC_signature_get_ctx_params_fn rsa_get_ctx_params; +static OSSL_FUNC_signature_gettable_ctx_params_fn rsa_gettable_ctx_params; +static OSSL_FUNC_signature_set_ctx_params_fn rsa_set_ctx_params; +static OSSL_FUNC_signature_settable_ctx_params_fn rsa_settable_ctx_params; +static OSSL_FUNC_signature_get_ctx_md_params_fn rsa_get_ctx_md_params; +static OSSL_FUNC_signature_gettable_ctx_md_params_fn rsa_gettable_ctx_md_params; +static OSSL_FUNC_signature_set_ctx_md_params_fn rsa_set_ctx_md_params; +static OSSL_FUNC_signature_settable_ctx_md_params_fn rsa_settable_ctx_md_params; static OSSL_ITEM padding_item[] = { - { RSA_PKCS1_PADDING, "pkcs1" }, - { RSA_SSLV23_PADDING, "sslv23" }, - { RSA_NO_PADDING, "none" }, - { RSA_PKCS1_OAEP_PADDING, "oaep" }, /* Correct spelling first */ - { RSA_PKCS1_OAEP_PADDING, "oeap" }, - { RSA_X931_PADDING, "x931" }, - { RSA_PKCS1_PSS_PADDING, "pss" }, + { RSA_PKCS1_PADDING, OSSL_PKEY_RSA_PAD_MODE_PKCSV15 }, + { RSA_NO_PADDING, OSSL_PKEY_RSA_PAD_MODE_NONE }, + { RSA_X931_PADDING, OSSL_PKEY_RSA_PAD_MODE_X931 }, + { RSA_PKCS1_PSS_PADDING, OSSL_PKEY_RSA_PAD_MODE_PSS }, { 0, NULL } }; @@ -72,7 +74,7 @@ static OSSL_ITEM padding_item[] = { */ typedef struct { - OPENSSL_CTX *libctx; + OSSL_LIB_CTX *libctx; char *propq; RSA *rsa; int operation; @@ -84,11 +86,7 @@ typedef struct { * by their Final function. */ unsigned int flag_allow_md : 1; - - /* The Algorithm Identifier of the combined signature agorithm */ - unsigned char aid_buf[128]; - unsigned char *aid; - size_t aid_len; + unsigned int mgf1_md_set : 1; /* main digest */ EVP_MD *md; @@ -100,6 +98,7 @@ typedef struct { int pad_mode; /* message digest for MGF1 */ EVP_MD *mgf1_md; + int mgf1_mdnid; char mgf1_mdname[OSSL_MAX_NAME_SIZE]; /* Purely informational */ /* PSS salt length */ int saltlen; @@ -111,6 +110,9 @@ typedef struct { } PROV_RSA_CTX; +/* True if PSS parameters are restricted */ +#define rsa_pss_restricted(prsactx) (prsactx->min_saltlen != -1) + static size_t rsa_get_md_size(const PROV_RSA_CTX *prsactx) { if (prsactx->md != NULL) @@ -118,79 +120,50 @@ static size_t rsa_get_md_size(const PROV_RSA_CTX *prsactx) return 0; } -static int rsa_get_md_nid(const EVP_MD *md) +static int rsa_check_padding(const PROV_RSA_CTX *prsactx, + const char *mdname, const char *mgf1_mdname, + int mdnid) { - /* - * Because the RSA library deals with NIDs, we need to translate. - * We do so using EVP_MD_is_a(), and therefore need a name to NID - * map. - */ - static const OSSL_ITEM name_to_nid[] = { - { NID_sha1, OSSL_DIGEST_NAME_SHA1 }, - { NID_sha224, OSSL_DIGEST_NAME_SHA2_224 }, - { NID_sha256, OSSL_DIGEST_NAME_SHA2_256 }, - { NID_sha384, OSSL_DIGEST_NAME_SHA2_384 }, - { NID_sha512, OSSL_DIGEST_NAME_SHA2_512 }, - { NID_sha512_224, OSSL_DIGEST_NAME_SHA2_512_224 }, - { NID_sha512_256, OSSL_DIGEST_NAME_SHA2_512_256 }, - { NID_md5, OSSL_DIGEST_NAME_MD5 }, - { NID_md5_sha1, OSSL_DIGEST_NAME_MD5_SHA1 }, - { NID_md2, OSSL_DIGEST_NAME_MD2 }, - { NID_md4, OSSL_DIGEST_NAME_MD4 }, - { NID_mdc2, OSSL_DIGEST_NAME_MDC2 }, - { NID_ripemd160, OSSL_DIGEST_NAME_RIPEMD160 }, - { NID_sha3_224, OSSL_DIGEST_NAME_SHA3_224 }, - { NID_sha3_256, OSSL_DIGEST_NAME_SHA3_256 }, - { NID_sha3_384, OSSL_DIGEST_NAME_SHA3_384 }, - { NID_sha3_512, OSSL_DIGEST_NAME_SHA3_512 }, - }; - size_t i; - int mdnid = NID_undef; - - if (md == NULL) - goto end; - - for (i = 0; i < OSSL_NELEM(name_to_nid); i++) { - if (EVP_MD_is_a(md, name_to_nid[i].ptr)) { - mdnid = (int)name_to_nid[i].id; - break; - } - } - - end: - return mdnid; -} - -static int rsa_check_padding(int mdnid, int padding) -{ - if (padding == RSA_NO_PADDING) { - ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE); - return 0; - } - - if (padding == RSA_X931_PADDING) { - if (RSA_X931_hash_id(mdnid) == -1) { - ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_X931_DIGEST); + switch(prsactx->pad_mode) { + case RSA_NO_PADDING: + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PADDING_MODE); return 0; - } + case RSA_X931_PADDING: + if (RSA_X931_hash_id(mdnid) == -1) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_X931_DIGEST); + return 0; + } + break; + case RSA_PKCS1_PSS_PADDING: + if (rsa_pss_restricted(prsactx)) + if ((mdname != NULL && !EVP_MD_is_a(prsactx->md, mdname)) + || (mgf1_mdname != NULL + && !EVP_MD_is_a(prsactx->mgf1_md, mgf1_mdname))) { + ERR_raise(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED); + return 0; + } + break; + default: + break; } return 1; } -static int rsa_check_parameters(EVP_MD *md, PROV_RSA_CTX *prsactx) +static int rsa_check_parameters(PROV_RSA_CTX *prsactx, int min_saltlen) { if (prsactx->pad_mode == RSA_PKCS1_PSS_PADDING) { int max_saltlen; /* See if minimum salt length exceeds maximum possible */ - max_saltlen = RSA_size(prsactx->rsa) - EVP_MD_size(md); + max_saltlen = RSA_size(prsactx->rsa) - EVP_MD_size(prsactx->md); if ((RSA_bits(prsactx->rsa) & 0x7) == 1) max_saltlen--; - if (prsactx->min_saltlen > max_saltlen) { + if (min_saltlen < 0 || min_saltlen > max_saltlen) { ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH); return 0; } + prsactx->min_saltlen = min_saltlen; } return 1; } @@ -200,6 +173,9 @@ static void *rsa_newctx(void *provctx, const char *propq) PROV_RSA_CTX *prsactx = NULL; char *propq_copy = NULL; + if (!ossl_prov_is_running()) + return NULL; + if ((prsactx = OPENSSL_zalloc(sizeof(PROV_RSA_CTX))) == NULL || (propq != NULL && (propq_copy = OPENSSL_strdup(propq)) == NULL)) { @@ -208,14 +184,87 @@ static void *rsa_newctx(void *provctx, const char *propq) return NULL; } - prsactx->libctx = PROV_LIBRARY_CONTEXT_OF(provctx); + prsactx->libctx = PROV_LIBCTX_OF(provctx); prsactx->flag_allow_md = 1; prsactx->propq = propq_copy; return prsactx; } -/* True if PSS parameters are restricted */ -#define rsa_pss_restricted(prsactx) (prsactx->min_saltlen != -1) +static int rsa_pss_compute_saltlen(PROV_RSA_CTX *ctx) +{ + int saltlen = ctx->saltlen; + + if (saltlen == RSA_PSS_SALTLEN_DIGEST) { + saltlen = EVP_MD_size(ctx->md); + } else if (saltlen == RSA_PSS_SALTLEN_AUTO || saltlen == RSA_PSS_SALTLEN_MAX) { + saltlen = RSA_size(ctx->rsa) - EVP_MD_size(ctx->md) - 2; + if ((RSA_bits(ctx->rsa) & 0x7) == 1) + saltlen--; + } + if (saltlen < 0) { + ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR); + return -1; + } else if (saltlen < ctx->min_saltlen) { + ERR_raise_data(ERR_LIB_PROV, PROV_R_PSS_SALTLEN_TOO_SMALL, + "minimum salt length: %d, actual salt length: %d", + ctx->min_saltlen, saltlen); + return -1; + } + return saltlen; +} + +static unsigned char *rsa_generate_signature_aid(PROV_RSA_CTX *ctx, + unsigned char *aid_buf, + size_t buf_len, + size_t *aid_len) +{ + WPACKET pkt; + unsigned char *aid = NULL; + int saltlen; + RSA_PSS_PARAMS_30 pss_params; + + if (!WPACKET_init_der(&pkt, aid_buf, buf_len)) { + ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); + return NULL; + } + + switch(ctx->pad_mode) { + case RSA_PKCS1_PADDING: + if (!ossl_DER_w_algorithmIdentifier_MDWithRSAEncryption(&pkt, -1, + ctx->mdnid)) { + ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR); + goto cleanup; + } + break; + case RSA_PKCS1_PSS_PADDING: + saltlen = rsa_pss_compute_saltlen(ctx); + if (saltlen < 0) + goto cleanup; + if (!ossl_rsa_pss_params_30_set_defaults(&pss_params) + || !ossl_rsa_pss_params_30_set_hashalg(&pss_params, ctx->mdnid) + || !ossl_rsa_pss_params_30_set_maskgenhashalg(&pss_params, + ctx->mgf1_mdnid) + || !ossl_rsa_pss_params_30_set_saltlen(&pss_params, saltlen) + || !ossl_DER_w_algorithmIdentifier_RSA_PSS(&pkt, -1, + RSA_FLAG_TYPE_RSASSAPSS, + &pss_params)) { + ERR_raise(ERR_LIB_PROV, ERR_R_INTERNAL_ERROR); + goto cleanup; + } + break; + default: + ERR_raise_data(ERR_LIB_PROV, ERR_R_UNSUPPORTED, + "Algorithm ID generation"); + goto cleanup; + } + if (WPACKET_finish(&pkt)) { + WPACKET_get_total_written(&pkt, aid_len); + aid = WPACKET_get_curr(&pkt); + } + cleanup: + WPACKET_cleanup(&pkt); + return aid; +} static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname, const char *mdprops) @@ -225,42 +274,41 @@ static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname, if (mdname != NULL) { EVP_MD *md = EVP_MD_fetch(ctx->libctx, mdname, mdprops); - int md_nid = rsa_get_md_nid(md); - WPACKET pkt; + int sha1_allowed = (ctx->operation != EVP_PKEY_OP_SIGN); + int md_nid = ossl_digest_rsa_sign_get_md_nid(md, sha1_allowed); + size_t mdname_len = strlen(mdname); if (md == NULL || md_nid == NID_undef - || !rsa_check_padding(md_nid, ctx->pad_mode) - || !rsa_check_parameters(md, ctx)) { + || !rsa_check_padding(ctx, mdname, NULL, md_nid) + || mdname_len >= sizeof(ctx->mdname)) { if (md == NULL) ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, "%s could not be fetched", mdname); if (md_nid == NID_undef) ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED, "digest=%s", mdname); + if (mdname_len >= sizeof(ctx->mdname)) + ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, + "%s exceeds name buffer length", mdname); EVP_MD_free(md); return 0; } + if (!ctx->mgf1_md_set) { + if (!EVP_MD_up_ref(md)) { + EVP_MD_free(md); + return 0; + } + EVP_MD_free(ctx->mgf1_md); + ctx->mgf1_md = md; + ctx->mgf1_mdnid = md_nid; + OPENSSL_strlcpy(ctx->mgf1_mdname, mdname, sizeof(ctx->mgf1_mdname)); + } + EVP_MD_CTX_free(ctx->mdctx); EVP_MD_free(ctx->md); - /* - * TODO(3.0) Should we care about DER writing errors? - * All it really means is that for some reason, there's no - * AlgorithmIdentifier to be had (consider RSA with MD5-SHA1), - * but the operation itself is still valid, just as long as it's - * not used to construct anything that needs an AlgorithmIdentifier. - */ - ctx->aid_len = 0; - if (WPACKET_init_der(&pkt, ctx->aid_buf, sizeof(ctx->aid_buf)) - && DER_w_algorithmIdentifier_RSA_with(&pkt, -1, ctx->rsa, md_nid) - && WPACKET_finish(&pkt)) { - WPACKET_get_total_written(&pkt, &ctx->aid_len); - ctx->aid = WPACKET_get_curr(&pkt); - } - WPACKET_cleanup(&pkt); - ctx->mdctx = NULL; ctx->md = md; ctx->mdnid = md_nid; @@ -273,26 +321,49 @@ static int rsa_setup_md(PROV_RSA_CTX *ctx, const char *mdname, static int rsa_setup_mgf1_md(PROV_RSA_CTX *ctx, const char *mdname, const char *mdprops) { + size_t len; + EVP_MD *md = NULL; + int mdnid; + if (mdprops == NULL) mdprops = ctx->propq; - if (ctx->mgf1_mdname[0] != '\0') - EVP_MD_free(ctx->mgf1_md); - - if ((ctx->mgf1_md = EVP_MD_fetch(ctx->libctx, mdname, mdprops)) == NULL) { + if ((md = EVP_MD_fetch(ctx->libctx, mdname, mdprops)) == NULL) { ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, "%s could not be fetched", mdname); return 0; } - OPENSSL_strlcpy(ctx->mgf1_mdname, mdname, sizeof(ctx->mgf1_mdname)); + /* The default for mgf1 is SHA1 - so allow SHA1 */ + if ((mdnid = ossl_digest_rsa_sign_get_md_nid(md, 1)) == NID_undef + || !rsa_check_padding(ctx, NULL, mdname, mdnid)) { + if (mdnid == NID_undef) + ERR_raise_data(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED, + "digest=%s", mdname); + EVP_MD_free(md); + return 0; + } + len = OPENSSL_strlcpy(ctx->mgf1_mdname, mdname, sizeof(ctx->mgf1_mdname)); + if (len >= sizeof(ctx->mgf1_mdname)) { + ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, + "%s exceeds name buffer length", mdname); + EVP_MD_free(md); + return 0; + } + EVP_MD_free(ctx->mgf1_md); + ctx->mgf1_md = md; + ctx->mgf1_mdnid = mdnid; + ctx->mgf1_md_set = 1; return 1; } -static int rsa_signature_init(void *vprsactx, void *vrsa, int operation) +static int rsa_signverify_init(void *vprsactx, void *vrsa, int operation) { PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; + if (!ossl_prov_is_running()) + return 0; + if (prsactx == NULL || vrsa == NULL || !RSA_up_ref(vrsa)) return 0; @@ -300,6 +371,11 @@ static int rsa_signature_init(void *vprsactx, void *vrsa, int operation) prsactx->rsa = vrsa; prsactx->operation = operation; + if (!ossl_rsa_check_key(vrsa, operation == EVP_PKEY_OP_SIGN)) { + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_KEY_LENGTH); + return 0; + } + /* Maximum for sign, auto for verify */ prsactx->saltlen = RSA_PSS_SALTLEN_AUTO; prsactx->min_saltlen = -1; @@ -313,17 +389,17 @@ static int rsa_signature_init(void *vprsactx, void *vrsa, int operation) { const RSA_PSS_PARAMS_30 *pss = - rsa_get0_pss_params_30(prsactx->rsa); + ossl_rsa_get0_pss_params_30(prsactx->rsa); - if (!rsa_pss_params_30_is_unrestricted(pss)) { - int md_nid = rsa_pss_params_30_hashalg(pss); - int mgf1md_nid = rsa_pss_params_30_maskgenhashalg(pss); - int min_saltlen = rsa_pss_params_30_saltlen(pss); + if (!ossl_rsa_pss_params_30_is_unrestricted(pss)) { + int md_nid = ossl_rsa_pss_params_30_hashalg(pss); + int mgf1md_nid = ossl_rsa_pss_params_30_maskgenhashalg(pss); + int min_saltlen = ossl_rsa_pss_params_30_saltlen(pss); const char *mdname, *mgf1mdname; + size_t len; - mdname = rsa_oaeppss_nid2name(md_nid); - mgf1mdname = rsa_oaeppss_nid2name(mgf1md_nid); - prsactx->min_saltlen = min_saltlen; + mdname = ossl_rsa_oaeppss_nid2name(md_nid); + mgf1mdname = ossl_rsa_oaeppss_nid2name(mgf1md_nid); if (mdname == NULL) { ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, @@ -336,13 +412,26 @@ static int rsa_signature_init(void *vprsactx, void *vrsa, int operation) return 0; } - strncpy(prsactx->mdname, mdname, sizeof(prsactx->mdname)); - strncpy(prsactx->mgf1_mdname, mgf1mdname, - sizeof(prsactx->mgf1_mdname)); + len = OPENSSL_strlcpy(prsactx->mdname, mdname, + sizeof(prsactx->mdname)); + if (len >= sizeof(prsactx->mdname)) { + ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, + "hash algorithm name too long"); + return 0; + } + len = OPENSSL_strlcpy(prsactx->mgf1_mdname, mgf1mdname, + sizeof(prsactx->mgf1_mdname)); + if (len >= sizeof(prsactx->mgf1_mdname)) { + ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_DIGEST, + "MGF1 hash algorithm name too long"); + return 0; + } prsactx->saltlen = min_saltlen; - return rsa_setup_md(prsactx, mdname, prsactx->propq) - && rsa_setup_mgf1_md(prsactx, mgf1mdname, prsactx->propq); + /* call rsa_setup_mgf1_md before rsa_setup_md to avoid duplication */ + return rsa_setup_mgf1_md(prsactx, mgf1mdname, prsactx->propq) + && rsa_setup_md(prsactx, mdname, prsactx->propq) + && rsa_check_parameters(prsactx, min_saltlen); } } @@ -381,7 +470,9 @@ static void free_tbuf(PROV_RSA_CTX *ctx) static int rsa_sign_init(void *vprsactx, void *vrsa) { - return rsa_signature_init(vprsactx, vrsa, EVP_PKEY_OP_SIGN); + if (!ossl_prov_is_running()) + return 0; + return rsa_signverify_init(vprsactx, vrsa, EVP_PKEY_OP_SIGN); } static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, @@ -392,6 +483,9 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, size_t rsasize = RSA_size(prsactx->rsa); size_t mdsize = rsa_get_md_size(prsactx); + if (!ossl_prov_is_running()) + return 0; + if (sig == NULL) { *siglen = rsasize; return 1; @@ -422,7 +516,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, prsactx->rsa); if (ret <= 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } ret = sltmp; @@ -455,7 +549,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, ret = RSA_sign(prsactx->mdnid, tbs, tbslen, sig, &sltmp, prsactx->rsa); if (ret <= 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } ret = sltmp; @@ -497,7 +591,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, prsactx->tbuf, tbs, prsactx->md, prsactx->mgf1_md, prsactx->saltlen)) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } ret = RSA_private_encrypt(RSA_size(prsactx->rsa), prsactx->tbuf, @@ -519,7 +613,7 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, end: #endif if (ret <= 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } @@ -529,7 +623,9 @@ static int rsa_sign(void *vprsactx, unsigned char *sig, size_t *siglen, static int rsa_verify_recover_init(void *vprsactx, void *vrsa) { - return rsa_signature_init(vprsactx, vrsa, EVP_PKEY_OP_VERIFYRECOVER); + if (!ossl_prov_is_running()) + return 0; + return rsa_signverify_init(vprsactx, vrsa, EVP_PKEY_OP_VERIFYRECOVER); } static int rsa_verify_recover(void *vprsactx, @@ -542,6 +638,9 @@ static int rsa_verify_recover(void *vprsactx, PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; int ret; + if (!ossl_prov_is_running()) + return 0; + if (rout == NULL) { *routlen = RSA_size(prsactx->rsa); return 1; @@ -555,7 +654,7 @@ static int rsa_verify_recover(void *vprsactx, ret = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa, RSA_X931_PADDING); if (ret < 1) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } ret--; @@ -571,13 +670,15 @@ static int rsa_verify_recover(void *vprsactx, } *routlen = ret; - if (routsize < (size_t)ret) { - ERR_raise_data(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL, - "buffer size is %d, should be %d", - routsize, ret); - return 0; + if (rout != prsactx->tbuf) { + if (routsize < (size_t)ret) { + ERR_raise_data(ERR_LIB_PROV, PROV_R_OUTPUT_BUFFER_TOO_SMALL, + "buffer size is %d, should be %d", + routsize, ret); + return 0; + } + memcpy(rout, prsactx->tbuf, ret); } - memcpy(rout, prsactx->tbuf, ret); break; case RSA_PKCS1_PADDING: @@ -587,7 +688,7 @@ static int rsa_verify_recover(void *vprsactx, ret = int_rsa_verify(prsactx->mdnid, NULL, 0, rout, &sltmp, sig, siglen, prsactx->rsa); if (ret <= 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } ret = sltmp; @@ -603,7 +704,7 @@ static int rsa_verify_recover(void *vprsactx, ret = RSA_public_decrypt(siglen, sig, rout, prsactx->rsa, prsactx->pad_mode); if (ret < 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } } @@ -613,7 +714,9 @@ static int rsa_verify_recover(void *vprsactx, static int rsa_verify_init(void *vprsactx, void *vrsa) { - return rsa_signature_init(vprsactx, vrsa, EVP_PKEY_OP_VERIFY); + if (!ossl_prov_is_running()) + return 0; + return rsa_signverify_init(vprsactx, vrsa, EVP_PKEY_OP_VERIFY); } static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen, @@ -622,17 +725,22 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen, PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; size_t rslen; + if (!ossl_prov_is_running()) + return 0; if (prsactx->md != NULL) { switch (prsactx->pad_mode) { case RSA_PKCS1_PADDING: if (!RSA_verify(prsactx->mdnid, tbs, tbslen, sig, siglen, prsactx->rsa)) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } return 1; case RSA_X931_PADDING: - if (rsa_verify_recover(prsactx, NULL, &rslen, 0, sig, siglen) <= 0) + if (!setup_tbuf(prsactx)) + return 0; + if (rsa_verify_recover(prsactx, prsactx->tbuf, &rslen, 0, + sig, siglen) <= 0) return 0; break; case RSA_PKCS1_PSS_PADDING: @@ -657,7 +765,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen, ret = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa, RSA_NO_PADDING); if (ret <= 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } ret = RSA_verify_PKCS1_PSS_mgf1(prsactx->rsa, tbs, @@ -665,7 +773,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen, prsactx->tbuf, prsactx->saltlen); if (ret <= 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } return 1; @@ -681,7 +789,7 @@ static int rsa_verify(void *vprsactx, const unsigned char *sig, size_t siglen, rslen = RSA_public_decrypt(siglen, sig, prsactx->tbuf, prsactx->rsa, prsactx->pad_mode); if (rslen == 0) { - ERR_raise(ERR_LIB_PROV, ERR_LIB_RSA); + ERR_raise(ERR_LIB_PROV, ERR_R_RSA_LIB); return 0; } } @@ -697,9 +805,17 @@ static int rsa_digest_signverify_init(void *vprsactx, const char *mdname, { PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; - prsactx->flag_allow_md = 0; - if (!rsa_signature_init(vprsactx, vrsa, operation) - || !rsa_setup_md(prsactx, mdname, NULL)) /* TODO RL */ + if (!ossl_prov_is_running()) + return 0; + + if (prsactx != NULL) + prsactx->flag_allow_md = 0; + if (!rsa_signverify_init(vprsactx, vrsa, operation)) + return 0; + if (mdname != NULL + /* was rsa_setup_md already called in rsa_signverify_init()? */ + && (mdname[0] == '\0' || strcasecmp(prsactx->mdname, mdname) != 0) + && !rsa_setup_md(prsactx, mdname, prsactx->propq)) return 0; prsactx->mdctx = EVP_MD_CTX_new(); @@ -736,6 +852,8 @@ static int rsa_digest_signverify_update(void *vprsactx, static int rsa_digest_sign_init(void *vprsactx, const char *mdname, void *vrsa) { + if (!ossl_prov_is_running()) + return 0; return rsa_digest_signverify_init(vprsactx, mdname, vrsa, EVP_PKEY_OP_SIGN); } @@ -747,19 +865,19 @@ static int rsa_digest_sign_final(void *vprsactx, unsigned char *sig, unsigned char digest[EVP_MAX_MD_SIZE]; unsigned int dlen = 0; + if (!ossl_prov_is_running() || prsactx == NULL) + return 0; prsactx->flag_allow_md = 1; - if (prsactx == NULL || prsactx->mdctx == NULL) + if (prsactx->mdctx == NULL) return 0; - /* * If sig is NULL then we're just finding out the sig size. Other fields * are ignored. Defer to rsa_sign. */ if (sig != NULL) { /* - * TODO(3.0): There is the possibility that some externally provided - * digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow - - * but that problem is much larger than just in RSA. + * The digests used here are all known (see rsa_get_md_nid()), so they + * should not exceed the internal buffer size of EVP_MAX_MD_SIZE. */ if (!EVP_DigestFinal_ex(prsactx->mdctx, digest, &dlen)) return 0; @@ -771,6 +889,8 @@ static int rsa_digest_sign_final(void *vprsactx, unsigned char *sig, static int rsa_digest_verify_init(void *vprsactx, const char *mdname, void *vrsa) { + if (!ossl_prov_is_running()) + return 0; return rsa_digest_signverify_init(vprsactx, mdname, vrsa, EVP_PKEY_OP_VERIFY); } @@ -782,14 +902,18 @@ int rsa_digest_verify_final(void *vprsactx, const unsigned char *sig, unsigned char digest[EVP_MAX_MD_SIZE]; unsigned int dlen = 0; + if (!ossl_prov_is_running()) + return 0; + + if (prsactx == NULL) + return 0; prsactx->flag_allow_md = 1; - if (prsactx == NULL || prsactx->mdctx == NULL) + if (prsactx->mdctx == NULL) return 0; /* - * TODO(3.0): There is the possibility that some externally provided - * digests exceed EVP_MAX_MD_SIZE. We should probably handle that somehow - - * but that problem is much larger than just in RSA. + * The digests used here are all known (see rsa_get_md_nid()), so they + * should not exceed the internal buffer size of EVP_MAX_MD_SIZE. */ if (!EVP_DigestFinal_ex(prsactx->mdctx, digest, &dlen)) return 0; @@ -804,14 +928,14 @@ static void rsa_freectx(void *vprsactx) if (prsactx == NULL) return; - RSA_free(prsactx->rsa); EVP_MD_CTX_free(prsactx->mdctx); EVP_MD_free(prsactx->md); EVP_MD_free(prsactx->mgf1_md); OPENSSL_free(prsactx->propq); free_tbuf(prsactx); + RSA_free(prsactx->rsa); - OPENSSL_clear_free(prsactx, sizeof(prsactx)); + OPENSSL_clear_free(prsactx, sizeof(*prsactx)); } static void *rsa_dupctx(void *vprsactx) @@ -819,6 +943,9 @@ static void *rsa_dupctx(void *vprsactx) PROV_RSA_CTX *srcctx = (PROV_RSA_CTX *)vprsactx; PROV_RSA_CTX *dstctx; + if (!ossl_prov_is_running()) + return NULL; + dstctx = OPENSSL_zalloc(sizeof(*srcctx)); if (dstctx == NULL) { ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); @@ -830,6 +957,7 @@ static void *rsa_dupctx(void *vprsactx) dstctx->md = NULL; dstctx->mdctx = NULL; dstctx->tbuf = NULL; + dstctx->propq = NULL; if (srcctx->rsa != NULL && !RSA_up_ref(srcctx->rsa)) goto err; @@ -850,6 +978,12 @@ static void *rsa_dupctx(void *vprsactx) goto err; } + if (srcctx->propq != NULL) { + dstctx->propq = OPENSSL_strdup(srcctx->propq); + if (dstctx->propq == NULL) + goto err; + } + return dstctx; err: rsa_freectx(dstctx); @@ -865,9 +999,17 @@ static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params) return 0; p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_ALGORITHM_ID); - if (p != NULL - && !OSSL_PARAM_set_octet_string(p, prsactx->aid, prsactx->aid_len)) - return 0; + if (p != NULL) { + /* The Algorithm Identifier of the combined signature algorithm */ + unsigned char aid_buf[128]; + unsigned char *aid; + size_t aid_len; + + aid = rsa_generate_signature_aid(prsactx, aid_buf, + sizeof(aid_buf), &aid_len); + if (aid == NULL || !OSSL_PARAM_set_octet_string(p, aid, aid_len)) + return 0; + } p = OSSL_PARAM_locate(params, OSSL_SIGNATURE_PARAM_PAD_MODE); if (p != NULL) @@ -914,25 +1056,32 @@ static int rsa_get_ctx_params(void *vprsactx, OSSL_PARAM *params) if (!OSSL_PARAM_set_int(p, prsactx->saltlen)) return 0; } else if (p->data_type == OSSL_PARAM_UTF8_STRING) { + const char *value = NULL; + switch (prsactx->saltlen) { case RSA_PSS_SALTLEN_DIGEST: - if (!OSSL_PARAM_set_utf8_string(p, "digest")) - return 0; + value = OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST; break; case RSA_PSS_SALTLEN_MAX: - if (!OSSL_PARAM_set_utf8_string(p, "max")) - return 0; + value = OSSL_PKEY_RSA_PSS_SALT_LEN_MAX; break; case RSA_PSS_SALTLEN_AUTO: - if (!OSSL_PARAM_set_utf8_string(p, "auto")) - return 0; + value = OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO; break; default: - if (BIO_snprintf(p->data, p->data_size, "%d", prsactx->saltlen) - <= 0) - return 0; - break; + { + int len = BIO_snprintf(p->data, p->data_size, "%d", + prsactx->saltlen); + + if (len <= 0) + return 0; + p->return_size = len; + break; + } } + if (value != NULL + && !OSSL_PARAM_set_utf8_string(p, value)) + return 0; } } @@ -948,7 +1097,7 @@ static const OSSL_PARAM known_gettable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *rsa_gettable_ctx_params(void) +static const OSSL_PARAM *rsa_gettable_ctx_params(ossl_unused void *vctx) { return known_gettable_ctx_params; } @@ -957,46 +1106,41 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) { PROV_RSA_CTX *prsactx = (PROV_RSA_CTX *)vprsactx; const OSSL_PARAM *p; + int pad_mode; + int saltlen; + char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = NULL; + char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = NULL; + char mgf1mdname[OSSL_MAX_NAME_SIZE] = "", *pmgf1mdname = NULL; + char mgf1mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmgf1mdprops = NULL; if (prsactx == NULL || params == NULL) return 0; + pad_mode = prsactx->pad_mode; + saltlen = prsactx->saltlen; p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_DIGEST); /* Not allowed during certain operations */ if (p != NULL && !prsactx->flag_allow_md) return 0; if (p != NULL) { - char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname; - char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops; const OSSL_PARAM *propsp = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PROPERTIES); + pmdname = mdname; if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname))) return 0; - if (propsp == NULL) - pmdprops = NULL; - else if (!OSSL_PARAM_get_utf8_string(propsp, - &pmdprops, sizeof(mdprops))) - return 0; - - if (rsa_pss_restricted(prsactx)) { - /* TODO(3.0) figure out what to do for prsactx->md == NULL */ - if (prsactx->md == NULL || EVP_MD_is_a(prsactx->md, mdname)) - return 1; - ERR_raise(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED); - return 0; + if (propsp != NULL) { + pmdprops = mdprops; + if (!OSSL_PARAM_get_utf8_string(propsp, + &pmdprops, sizeof(mdprops))) + return 0; } - - /* non-PSS code follows */ - if (!rsa_setup_md(prsactx, mdname, pmdprops)) - return 0; } p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PAD_MODE); if (p != NULL) { - int pad_mode = 0; const char *err_extra_text = NULL; switch (p->data_type) { @@ -1038,17 +1182,10 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) "PSS padding only allowed for sign and verify operations"; goto bad_pad; } - if (prsactx->md == NULL - && !rsa_setup_md(prsactx, OSSL_DIGEST_NAME_SHA1, NULL)) { - return 0; - } break; case RSA_PKCS1_PADDING: err_extra_text = "PKCS#1 padding not allowed with RSA-PSS"; goto cont; - case RSA_SSLV23_PADDING: - err_extra_text = "SSLv3 padding not allowed with RSA-PSS"; - goto cont; case RSA_NO_PADDING: err_extra_text = "No padding not allowed with RSA-PSS"; goto cont; @@ -1070,16 +1207,11 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) err_extra_text); return 0; } - if (!rsa_check_padding(prsactx->mdnid, pad_mode)) - return 0; - prsactx->pad_mode = pad_mode; } p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_PSS_SALTLEN); if (p != NULL) { - int saltlen; - - if (prsactx->pad_mode != RSA_PKCS1_PSS_PADDING) { + if (pad_mode != RSA_PKCS1_PSS_PADDING) { ERR_raise_data(ERR_LIB_PROV, PROV_R_NOT_SUPPORTED, "PSS saltlen can only be specified if " "PSS padding has been specified first"); @@ -1092,11 +1224,11 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) return 0; break; case OSSL_PARAM_UTF8_STRING: - if (strcmp(p->data, "digest") == 0) + if (strcmp(p->data, OSSL_PKEY_RSA_PSS_SALT_LEN_DIGEST) == 0) saltlen = RSA_PSS_SALTLEN_DIGEST; - else if (strcmp(p->data, "max") == 0) + else if (strcmp(p->data, OSSL_PKEY_RSA_PSS_SALT_LEN_MAX) == 0) saltlen = RSA_PSS_SALTLEN_MAX; - else if (strcmp(p->data, "auto") == 0) + else if (strcmp(p->data, OSSL_PKEY_RSA_PSS_SALT_LEN_AUTO) == 0) saltlen = RSA_PSS_SALTLEN_AUTO; else saltlen = atoi(p->data); @@ -1111,15 +1243,16 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) * lowest saltlen number possible. */ if (saltlen < RSA_PSS_SALTLEN_MAX) { - ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PSS_SALTLEN); + ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH); return 0; } if (rsa_pss_restricted(prsactx)) { - switch (prsactx->saltlen) { + switch (saltlen) { case RSA_PSS_SALTLEN_AUTO: if (prsactx->operation == EVP_PKEY_OP_VERIFY) { - ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_PSS_SALTLEN); + ERR_raise_data(ERR_LIB_PROV, PROV_R_INVALID_SALT_LENGTH, + "Cannot use autodetected salt length"); return 0; } break; @@ -1133,7 +1266,7 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) EVP_MD_size(prsactx->md)); return 0; } - /* FALLTHRU */ + break; default: if (saltlen >= 0 && saltlen < prsactx->min_saltlen) { ERR_raise_data(ERR_LIB_PROV, @@ -1145,46 +1278,49 @@ static int rsa_set_ctx_params(void *vprsactx, const OSSL_PARAM params[]) } } } - - prsactx->saltlen = saltlen; } p = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_MGF1_DIGEST); if (p != NULL) { - char mdname[OSSL_MAX_NAME_SIZE] = "", *pmdname = mdname; - char mdprops[OSSL_MAX_PROPQUERY_SIZE] = "", *pmdprops = mdprops; const OSSL_PARAM *propsp = OSSL_PARAM_locate_const(params, OSSL_SIGNATURE_PARAM_MGF1_PROPERTIES); - if (!OSSL_PARAM_get_utf8_string(p, &pmdname, sizeof(mdname))) + pmgf1mdname = mgf1mdname; + if (!OSSL_PARAM_get_utf8_string(p, &pmgf1mdname, sizeof(mgf1mdname))) return 0; - if (propsp == NULL) - pmdprops = NULL; - else if (!OSSL_PARAM_get_utf8_string(propsp, - &pmdprops, sizeof(mdprops))) - return 0; + if (propsp != NULL) { + pmgf1mdprops = mgf1mdprops; + if (!OSSL_PARAM_get_utf8_string(propsp, + &pmgf1mdprops, sizeof(mgf1mdprops))) + return 0; + } - if (prsactx->pad_mode != RSA_PKCS1_PSS_PADDING) { + if (pad_mode != RSA_PKCS1_PSS_PADDING) { ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_MGF1_MD); return 0; } + } - if (rsa_pss_restricted(prsactx)) { - /* TODO(3.0) figure out what to do for prsactx->mgf1_md == NULL */ - if (prsactx->mgf1_md == NULL - || EVP_MD_is_a(prsactx->mgf1_md, mdname)) - return 1; - ERR_raise(ERR_LIB_PROV, PROV_R_DIGEST_NOT_ALLOWED); - return 0; - } + prsactx->saltlen = saltlen; + prsactx->pad_mode = pad_mode; + + if (prsactx->md == NULL && pmdname == NULL + && pad_mode == RSA_PKCS1_PSS_PADDING) + pmdname = RSA_DEFAULT_DIGEST_NAME; - /* non-PSS code follows */ - if (!rsa_setup_mgf1_md(prsactx, mdname, pmdprops)) + if (pmgf1mdname != NULL + && !rsa_setup_mgf1_md(prsactx, pmgf1mdname, pmgf1mdprops)) + return 0; + + if (pmdname != NULL) { + if (!rsa_setup_md(prsactx, pmdname, pmdprops)) + return 0; + } else { + if (!rsa_check_padding(prsactx, NULL, NULL, prsactx->mdnid)) return 0; } - return 1; } @@ -1198,7 +1334,7 @@ static const OSSL_PARAM known_settable_ctx_params[] = { OSSL_PARAM_END }; -static const OSSL_PARAM *rsa_settable_ctx_params(void) +static const OSSL_PARAM *rsa_settable_ctx_params(ossl_unused void *provctx) { /* * TODO(3.0): Should this function return a different set of settable ctx @@ -1249,7 +1385,7 @@ static const OSSL_PARAM *rsa_settable_ctx_md_params(void *vprsactx) return EVP_MD_settable_ctx_params(prsactx->md); } -const OSSL_DISPATCH rsa_signature_functions[] = { +const OSSL_DISPATCH ossl_rsa_signature_functions[] = { { OSSL_FUNC_SIGNATURE_NEWCTX, (void (*)(void))rsa_newctx }, { OSSL_FUNC_SIGNATURE_SIGN_INIT, (void (*)(void))rsa_sign_init }, { OSSL_FUNC_SIGNATURE_SIGN, (void (*)(void))rsa_sign },