diff --git a/crypto/rsa/rsa.h b/crypto/rsa/rsa.h index 2b03ede5fdf0c3595f6719e6e704674728d11110..09db1c88dedd784b322503884d972758d2bf0219 100644 --- a/crypto/rsa/rsa.h +++ b/crypto/rsa/rsa.h @@ -193,7 +193,7 @@ struct rsa_st */ #define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_CTRL_RSA_PADDING, \ + EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \ pad, NULL) #define EVP_PKEY_CTRL_RSA_PADDING 1 diff --git a/crypto/rsa/rsa_pmeth.c b/crypto/rsa/rsa_pmeth.c index 5401b0544a0ff8edfd7a6516cf02162ead168188..3552fce8d9015f674ccad56d1cfcd3505ce347d0 100644 --- a/crypto/rsa/rsa_pmeth.c +++ b/crypto/rsa/rsa_pmeth.c @@ -161,10 +161,12 @@ static int pkey_rsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) /* TODO: add PSS support */ if ((p1 >= RSA_PKCS1_PADDING) && (p1 <= RSA_X931_PADDING)) { + if (ctx->operation == EVP_PKEY_OP_KEYGEN) + return -2; rctx->pad_mode = p1; return 1; } - return 0; + return -2; default: return -2; @@ -192,7 +194,7 @@ static int pkey_rsa_ctrl_str(EVP_PKEY_CTX *ctx, pm = RSA_X931_PADDING; else return -2; - return pkey_rsa_ctrl(ctx, EVP_PKEY_CTRL_RSA_PADDING, pm, NULL); + return EVP_PKEY_CTX_set_rsa_padding(ctx, pm); } return -2; }