]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
CORE: pass the full algorithm definition to the method constructor
authorRichard Levitte <levitte@openssl.org>
Tue, 19 Nov 2019 08:55:56 +0000 (09:55 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 29 Nov 2019 19:42:12 +0000 (20:42 +0100)
So far, the API level method constructors that are called by
ossl_method_construct_this() were passed the algorithm name string and
the dispatch table and had no access to anything else.

This change gives them access to the full OSSL_ALGORITHM item, thereby
giving them access to the property definition.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/10394)

crypto/core_fetch.c
crypto/evp/evp_fetch.c
include/internal/core.h

index ed50bb87d53c6c1d247a6371a0466fd525781aa0..7f815a50acb06106dd582b183d3aecb591d08394 100644 (file)
@@ -31,9 +31,8 @@ static void ossl_method_construct_this(OSSL_PROVIDER *provider,
     struct construct_data_st *data = cbdata;
     void *method = NULL;
 
-    if ((method = data->mcm->construct(algo->algorithm_names,
-                                       algo->implementation, provider,
-                                       data->mcm_data)) == NULL)
+    if ((method = data->mcm->construct(algo, provider, data->mcm_data))
+        == NULL)
         return;
 
     /*
index ff4e96a8237f98f6a9e08db0de762ec6683b9148..b2040e06f48a82fd16e76267aef166ef8f8ca0a2 100644 (file)
@@ -233,7 +233,7 @@ static int put_evp_method_in_store(OPENSSL_CTX *libctx, void *store,
  * The core fetching functionality passes the name of the implementation.
  * This function is responsible to getting an identity number for it.
  */
-static void *construct_evp_method(const char *names, const OSSL_DISPATCH *fns,
+static void *construct_evp_method(const OSSL_ALGORITHM *algodef,
                                   OSSL_PROVIDER *prov, void *data)
 {
     /*
@@ -246,11 +246,13 @@ static void *construct_evp_method(const char *names, const OSSL_DISPATCH *fns,
     struct evp_method_data_st *methdata = data;
     OPENSSL_CTX *libctx = ossl_provider_library_context(prov);
     OSSL_NAMEMAP *namemap = ossl_namemap_stored(libctx);
+    const char *names = algodef->algorithm_names;
     int name_id = ossl_namemap_add_names(namemap, 0, names, NAME_SEPARATOR);
 
     if (name_id == 0)
         return NULL;
-    return methdata->method_from_dispatch(name_id, fns, prov);
+    return methdata->method_from_dispatch(name_id, algodef->implementation,
+                                          prov);
 }
 
 static void destruct_evp_method(void *method, void *data)
index d2229e173b2c4f3f47fc87d02923a4b7e6034fa1..ca043334867642e67e838abf5200b1b21d72ab5a 100644 (file)
@@ -38,8 +38,8 @@ typedef struct ossl_method_construct_method_st {
                const OSSL_PROVIDER *prov, int operation_id, const char *name,
                const char *propdef, void *data);
     /* Construct a new method */
-    void *(*construct)(const char *name, const OSSL_DISPATCH *fns,
-                       OSSL_PROVIDER *prov, void *data);
+    void *(*construct)(const OSSL_ALGORITHM *algodef, OSSL_PROVIDER *prov,
+                       void *data);
     /* Destruct a method */
     void (*destruct)(void *method, void *data);
 } OSSL_METHOD_CONSTRUCT_METHOD;