From: Dr. Stephen Henson Date: Wed, 30 Nov 2016 18:26:10 +0000 (+0000) Subject: Support pad mode get/set for PSS keys. X-Git-Tag: OpenSSL_1_1_1-pre1~2773 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a300c7256e14527e3c4804b34824835db42fce54;p=oweals%2Fopenssl.git Support pad mode get/set for PSS keys. Pad mode setting returns an error if the mode is anything other then PSS. Reviewed-by: Rich Salz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/2177) --- diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c index f226c055dc..a1c65ef87e 100644 --- a/crypto/rsa/rsa_pmeth.c +++ b/crypto/rsa/rsa_pmeth.c @@ -388,6 +388,8 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) goto bad_pad; if (!rctx->md) rctx->md = EVP_sha1(); + } else if (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) { + goto bad_pad; } if (p1 == RSA_PKCS1_OAEP_PADDING) { if (!(ctx->operation & EVP_PKEY_OP_TYPE_CRYPT)) diff --git a/include/openssl/rsa.h b/include/openssl/rsa.h index ededce089a..d9c15b0d50 100644 --- a/include/openssl/rsa.h +++ b/include/openssl/rsa.h @@ -86,12 +86,10 @@ extern "C" { # endif # define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \ - pad, NULL) + RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL) # define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \ - EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad) + RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad) # define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \ RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \