Change operation values so they can be used as a mask.
authorDr. Stephen Henson <steve@openssl.org>
Mon, 10 Apr 2006 11:16:11 +0000 (11:16 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Mon, 10 Apr 2006 11:16:11 +0000 (11:16 +0000)
Fix rsa_pkey_method.

crypto/evp/evp.h
crypto/evp/pmeth_lib.c
crypto/rsa/rsa_pmeth.c

index a9a2f6a..52f41c2 100644 (file)
@@ -904,15 +904,31 @@ void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
 
 
 #define EVP_PKEY_OP_UNDEFINED          0
-#define EVP_PKEY_OP_PARAMGEN           1
-#define EVP_PKEY_OP_KEYGEN             2
-#define EVP_PKEY_OP_SIGN               3
-#define EVP_PKEY_OP_VERIFY             4
-#define EVP_PKEY_OP_VERIFYRECOVER      5
-#define EVP_PKEY_OP_SIGNCTX            6
-#define EVP_PKEY_OP_VERIFYCTX          7
-#define EVP_PKEY_OP_ENCRYPT            8
-#define EVP_PKEY_OP_DECRYPT            9
+#define EVP_PKEY_OP_PARAMGEN           (1<<1)
+#define EVP_PKEY_OP_KEYGEN             (1<<2)
+#define EVP_PKEY_OP_SIGN               (1<<3)
+#define EVP_PKEY_OP_VERIFY             (1<<4)
+#define EVP_PKEY_OP_VERIFYRECOVER      (1<<5)
+#define EVP_PKEY_OP_SIGNCTX            (1<<6)
+#define EVP_PKEY_OP_VERIFYCTX          (1<<7)
+#define EVP_PKEY_OP_ENCRYPT            (1<<8)
+#define EVP_PKEY_OP_DECRYPT            (1<<9)
+#define EVP_PKEY_OP_DERIVE             (1<<10)
+
+#define EVP_PKEY_OP_TYPE_SIGNATURE     \
+       (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \
+               | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)
+
+#define EVP_PKEY_OP_TYPE_CRYPTO \
+       (EVP_PKEY_OP_SIGNATURE | EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT \
+               | EVP_PKEY_OP_DERIVE)
+
+#define EVP_PKEY_OP_TYPE_GENERATE \
+               (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
+
+#define         EVP_PKEY_CTX_set_signature_md(ctx, md) \
+               EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIGNATURE,  \
+                                       EVP_PKEY_CTRL_MD, 0, (void *)md)
 
 #define EVP_PKEY_CTRL_MD               1
 
index a76e88b..26a5504 100644 (file)
@@ -156,7 +156,7 @@ int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
                return -1;
                }
 
-       if ((optype != -1) && (ctx->operation != optype))
+       if ((optype != -1) && !(ctx->operation & optype))
                {
                EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_INVALID_OPERATION);
                return -1;
@@ -187,8 +187,7 @@ int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx,
                        EVPerr(EVP_F_EVP_PKEY_CTX_CTRL, EVP_R_INVALID_DIGEST);
                        return 0;
                        }
-               return EVP_PKEY_CTX_ctrl(ctx, -1, -1, EVP_PKEY_CTRL_MD,
-                                                               0, (void *)md);
+               return EVP_PKEY_CTX_set_signature_md(ctx, md);
                }
        return ctx->pmeth->ctrl_str(ctx, name, value);
        }
index 5501965..696eef9 100644 (file)
@@ -212,6 +212,7 @@ static int pkey_rsa_verifyrecover(EVP_PKEY_CTX *ctx,
                        ret = int_rsa_verify(EVP_MD_type(rctx->md),
                                                NULL, 0, rout, &sltmp,
                                        sig, siglen, ctx->pkey->pkey.rsa);
+                       ret = sltmp;
                        }
                else
                        return -1;