Add checking to padding ctrl.
authorDr. Stephen Henson <steve@openssl.org>
Sun, 9 Apr 2006 12:53:55 +0000 (12:53 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Sun, 9 Apr 2006 12:53:55 +0000 (12:53 +0000)
crypto/rsa/rsa.h
crypto/rsa/rsa_pmeth.c

index 2b03ede..09db1c8 100644 (file)
@@ -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
index 5401b05..3552fce 100644 (file)
@@ -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;
        }