summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/evp/pmeth_lib.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2019-10-29 07:52:17 +0000
committerjsing <jsing@openbsd.org>2019-10-29 07:52:17 +0000
commit26d133994eeac070bbd4fced57104ed8fb0e0ef9 (patch)
tree55eeb36d958b784e66e785499b70d47d44428c1f /lib/libcrypto/evp/pmeth_lib.c
parentSignal handler cleanup: remove leftover support for unreliable signals (diff)
downloadwireguard-openbsd-26d133994eeac070bbd4fced57104ed8fb0e0ef9.tar.xz
wireguard-openbsd-26d133994eeac070bbd4fced57104ed8fb0e0ef9.zip
Provide EVP_PKEY_CTX_md().
This handles controls with a message digest by name, looks up the message digest and then proxies the control through with the EVP_MD *. This is internal only for now and will be used in upcoming RSA related changes. Based on OpenSSL 1.1.1d. ok inoguchi@ tb@
Diffstat (limited to 'lib/libcrypto/evp/pmeth_lib.c')
-rw-r--r--lib/libcrypto/evp/pmeth_lib.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/libcrypto/evp/pmeth_lib.c b/lib/libcrypto/evp/pmeth_lib.c
index 6b86a0ecfb0..ea9b8fed0cd 100644
--- a/lib/libcrypto/evp/pmeth_lib.c
+++ b/lib/libcrypto/evp/pmeth_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmeth_lib.c,v 1.14 2018/04/14 07:09:21 tb Exp $ */
+/* $OpenBSD: pmeth_lib.c,v 1.15 2019/10/29 07:52:17 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2006.
*/
@@ -438,17 +438,25 @@ EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *name, const char *value)
return -2;
}
if (!strcmp(name, "digest")) {
- const EVP_MD *md;
- if (!value || !(md = EVP_get_digestbyname(value))) {
- EVPerror(EVP_R_INVALID_DIGEST);
- return 0;
- }
- return EVP_PKEY_CTX_set_signature_md(ctx, md);
+ return EVP_PKEY_CTX_md(ctx, EVP_PKEY_OP_TYPE_SIG,
+ EVP_PKEY_CTRL_MD, value);
}
return ctx->pmeth->ctrl_str(ctx, name, value);
}
int
+EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name)
+{
+ const EVP_MD *md;
+
+ if ((md = EVP_get_digestbyname(md_name)) == NULL) {
+ EVPerror(EVP_R_INVALID_DIGEST);
+ return 0;
+ }
+ return EVP_PKEY_CTX_ctrl(ctx, -1, optype, cmd, 0, (void *)md);
+}
+
+int
EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx)
{
return ctx->operation;