summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-10-31 11:43:31 +0100
committerRichard Levitte <levitte@openssl.org>2019-11-03 18:33:43 +0100
commit60653e5b25242555446f8acf0abd5ab9ff83010c (patch)
tree5fd87b1d333800c472267394f202a8b6fe515335 /crypto
parente774adb593e7bf9057775d85ecc7c24e9bacee12 (diff)
Make EVP_PKEY_CTX initialization more precise
There is a vagueness around how the provider data (algorithm name and property query string) is initialized in the presence of an engine. This change modifies this slightly so that the algorithm name for use with providers is never set if the initilization was given an engine. This makes it easier for other functions to simply check ctx->algorithm to see if the context is meant to be used for strictly legacy stuff or not. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10308)
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/pmeth_lib.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/crypto/evp/pmeth_lib.c b/crypto/evp/pmeth_lib.c
index 350d963086..5ba844f53e 100644
--- a/crypto/evp/pmeth_lib.c
+++ b/crypto/evp/pmeth_lib.c
@@ -132,8 +132,24 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e,
return 0;
id = pkey->type;
}
- name = OBJ_nid2sn(id);
+
+ /*
+ * Here, we extract what information we can for the purpose of
+ * supporting usage with implementations from providers, to make
+ * for a smooth transition from legacy stuff to provider based stuff.
+ *
+ * If an engine is given, this is entirely legacy, and we should not
+ * pretend anything else, so we only set the name when no engine is
+ * given. If both are already given, someone made a mistake, and
+ * since that can only happen internally, it's safe to make an
+ * assertion.
+ */
+ if (!ossl_assert(e == NULL || name == NULL))
+ return NULL;
+ if (e == NULL)
+ name = OBJ_nid2sn(id);
propquery = NULL;
+
#ifndef OPENSSL_NO_ENGINE
if (e == NULL && pkey != NULL)
e = pkey->pmeth_engine != NULL ? pkey->pmeth_engine : pkey->engine;