diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/evp/pmeth_lib.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/libcrypto/evp/pmeth_lib.c b/src/lib/libcrypto/evp/pmeth_lib.c index 6b86a0ecfb..ea9b8fed0c 100644 --- a/src/lib/libcrypto/evp/pmeth_lib.c +++ b/src/lib/libcrypto/evp/pmeth_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: pmeth_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */ | 1 | /* $OpenBSD: pmeth_lib.c,v 1.15 2019/10/29 07:52:17 jsing Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2006. | 3 | * project 2006. |
| 4 | */ | 4 | */ |
| @@ -438,17 +438,25 @@ EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value) | |||
| 438 | return -2; | 438 | return -2; |
| 439 | } | 439 | } |
| 440 | if (!strcmp(name, "digest")) { | 440 | if (!strcmp(name, "digest")) { |
| 441 | const EVP_MD *md; | 441 | return EVP_PKEY_CTX_md(ctx, EVP_PKEY_OP_TYPE_SIG, |
| 442 | if (!value || !(md = EVP_get_digestbyname(value))) { | 442 | EVP_PKEY_CTRL_MD, value); |
| 443 | EVPerror(EVP_R_INVALID_DIGEST); | ||
| 444 | return 0; | ||
| 445 | } | ||
| 446 | return EVP_PKEY_CTX_set_signature_md(ctx, md); | ||
| 447 | } | 443 | } |
| 448 | return ctx->pmeth->ctrl_str(ctx, name, value); | 444 | return ctx->pmeth->ctrl_str(ctx, name, value); |
| 449 | } | 445 | } |
| 450 | 446 | ||
| 451 | int | 447 | int |
| 448 | EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name) | ||
| 449 | { | ||
| 450 | const EVP_MD *md; | ||
| 451 | |||
| 452 | if ((md = EVP_get_digestbyname(md_name)) == NULL) { | ||
| 453 | EVPerror(EVP_R_INVALID_DIGEST); | ||
| 454 | return 0; | ||
| 455 | } | ||
| 456 | return EVP_PKEY_CTX_ctrl(ctx, -1, optype, cmd, 0, (void *)md); | ||
| 457 | } | ||
| 458 | |||
| 459 | int | ||
| 452 | EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx) | 460 | EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx) |
| 453 | { | 461 | { |
| 454 | return ctx->operation; | 462 | return ctx->operation; |
