summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-09-03 07:22:00 +0200
committerRichard Levitte <levitte@openssl.org>2020-09-08 12:07:36 +0200
commitb968945204130620b1328f585610cbe1d6b5a69e (patch)
tree7d023da0175f9f3de0f9a40654daa7a316b4045e /crypto/evp
parent86df26b3943509219057ae87f8764b3c15e0d8b8 (diff)
EVP: Expand the use of EVP_PKEY_CTX_md()
Setting a hash function was reserved for signature operations. However, it turns out that SM2 uses a hash function for encryption and decryption as well. Therefore, EVP_PKEY_CTX_md() must be called with an expanded operation type combination that includes EVP_PKEY_OP_TYPE_CRYPT when used in a generic way. For SM2, test/recipes/30-test_evp_data/evppkey_sm2.txt is expanded to test decryption both with an implicit and an explicit digest. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/12789)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/pmeth_lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index bf8af22a47..94148850a0 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -1516,7 +1516,8 @@ static int evp_pkey_ctx_ctrl_str_int(EVP_PKEY_CTX *ctx,
return -2;
}
if (strcmp(name, "digest") == 0)
- ret = EVP_PKEY_CTX_md(ctx, EVP_PKEY_OP_TYPE_SIG,
+ ret = EVP_PKEY_CTX_md(ctx,
+ EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT,
EVP_PKEY_CTRL_MD, value);
else
ret = ctx->pmeth->ctrl_str(ctx, name, value);