From 6471c9f4787d64c2942ea75073374d86f5aa6517 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sun, 9 Apr 2006 12:53:55 +0000 Subject: [PATCH] Add checking to padding ctrl. --- crypto/rsa/rsa.h | 2 +- crypto/rsa/rsa_pmeth.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crypto/rsa/rsa.h b/crypto/rsa/rsa.h index 2b03ede5fd..09db1c88de 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 5401b0544a..3552fce8d9 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; } -- GitLab