summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2019-10-29 07:52:18 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2019-10-29 07:52:18 +0000
commita33f242ca5415644acbc08c2651ca4079240ee25 (patch)
tree1a92b99da75c829435c69c338a608a0b0093c3ac /lib
parent2138861da89cfa18272142d0f20eb5dd151136b5 (diff)
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')
-rw-r--r--lib/libcrypto/evp/evp_locl.h4
-rw-r--r--lib/libcrypto/evp/pmeth_lib.c22
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/libcrypto/evp/evp_locl.h b/lib/libcrypto/evp/evp_locl.h
index 0b1bea9583c..8df61354930 100644
--- a/lib/libcrypto/evp/evp_locl.h
+++ b/lib/libcrypto/evp/evp_locl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp_locl.h,v 1.15 2018/11/24 11:16:44 tb Exp $ */
+/* $OpenBSD: evp_locl.h,v 1.16 2019/10/29 07:52:17 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 2000.
*/
@@ -367,4 +367,6 @@ struct evp_aead_st {
const unsigned char *ad, size_t ad_len);
};
+int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name);
+
__END_HIDDEN_DECLS
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;