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 <rsalz@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2177)
This commit is contained in:
Dr. Stephen Henson 2016-11-30 18:26:10 +00:00
parent e64b2b5c83
commit a300c7256e
2 changed files with 4 additions and 4 deletions

View file

@ -388,6 +388,8 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2)
goto bad_pad; goto bad_pad;
if (!rctx->md) if (!rctx->md)
rctx->md = EVP_sha1(); rctx->md = EVP_sha1();
} else if (ctx->pmeth->pkey_id == EVP_PKEY_RSA_PSS) {
goto bad_pad;
} }
if (p1 == RSA_PKCS1_OAEP_PADDING) { if (p1 == RSA_PKCS1_OAEP_PADDING) {
if (!(ctx->operation & EVP_PKEY_OP_TYPE_CRYPT)) if (!(ctx->operation & EVP_PKEY_OP_TYPE_CRYPT))

View file

@ -86,12 +86,10 @@ extern "C" {
# endif # endif
# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \ # define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \ RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_RSA_PADDING, pad, NULL)
pad, NULL)
# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \ # define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \
EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \ RSA_pkey_ctx_ctrl(ctx, -1, EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad)
# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \ # define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \
RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ RSA_pkey_ctx_ctrl(ctx, (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \