Final cleanup after move to leaner EVP_PKEY methods
authorRichard Levitte <levitte@openssl.org>
Thu, 31 Oct 2019 11:10:01 +0000 (12:10 +0100)
committerRichard Levitte <levitte@openssl.org>
Sun, 10 Nov 2019 04:00:28 +0000 (05:00 +0100)
Now that KEYMGMT method pointers have moved away from the diverse
methods that are used with EVP_PKEY_CTX, we no longer need to pass
special argument to evp_generic_fetch() and evp_generic_do_all().

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/10309)

crypto/evp/digest.c
crypto/evp/evp_enc.c
crypto/evp/evp_fetch.c
crypto/evp/evp_local.h
crypto/evp/exchange.c
crypto/evp/kdf_meth.c
crypto/evp/keymgmt_meth.c
crypto/evp/mac_meth.c
crypto/evp/pmeth_fn.c

index 11c334c..bbe637e 100644 (file)
@@ -746,7 +746,7 @@ static void set_legacy_nid(const char *name, void *vlegacy_nid)
 
 static void *evp_md_from_dispatch(int name_id,
                                   const OSSL_DISPATCH *fns,
-                                  OSSL_PROVIDER *prov, void *unused)
+                                  OSSL_PROVIDER *prov)
 {
     EVP_MD *md = NULL;
     int fncnt = 0;
@@ -873,8 +873,7 @@ EVP_MD *EVP_MD_fetch(OPENSSL_CTX *ctx, const char *algorithm,
 {
     EVP_MD *md =
         evp_generic_fetch(ctx, OSSL_OP_DIGEST, algorithm, properties,
-                          evp_md_from_dispatch, NULL, evp_md_up_ref,
-                          evp_md_free);
+                          evp_md_from_dispatch, evp_md_up_ref, evp_md_free);
 
     return md;
 }
@@ -908,5 +907,5 @@ void EVP_MD_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_DIGEST,
                        (void (*)(void *, void *))fn, arg,
-                       evp_md_from_dispatch, NULL, evp_md_free);
+                       evp_md_from_dispatch, evp_md_free);
 }
index 53bd02d..ec02283 100644 (file)
@@ -1360,8 +1360,7 @@ static void set_legacy_nid(const char *name, void *vlegacy_nid)
 
 static void *evp_cipher_from_dispatch(const int name_id,
                                       const OSSL_DISPATCH *fns,
-                                      OSSL_PROVIDER *prov,
-                                      void *unused)
+                                      OSSL_PROVIDER *prov)
 {
     EVP_CIPHER *cipher = NULL;
     int fnciphcnt = 0, fnctxcnt = 0;
@@ -1501,7 +1500,7 @@ EVP_CIPHER *EVP_CIPHER_fetch(OPENSSL_CTX *ctx, const char *algorithm,
 {
     EVP_CIPHER *cipher =
         evp_generic_fetch(ctx, OSSL_OP_CIPHER, algorithm, properties,
-                          evp_cipher_from_dispatch, NULL, evp_cipher_up_ref,
+                          evp_cipher_from_dispatch, evp_cipher_up_ref,
                           evp_cipher_free);
 
     return cipher;
@@ -1536,5 +1535,5 @@ void EVP_CIPHER_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_CIPHER,
                        (void (*)(void *, void *))fn, arg,
-                       evp_cipher_from_dispatch, NULL, evp_cipher_free);
+                       evp_cipher_from_dispatch, evp_cipher_free);
 }
index f0432be..260471a 100644 (file)
@@ -47,8 +47,7 @@ struct evp_method_data_st {
     const char *names;           /* For get_evp_method_from_store() */
     const char *propquery;       /* For get_evp_method_from_store() */
     void *(*method_from_dispatch)(int name_id, const OSSL_DISPATCH *,
-                                  OSSL_PROVIDER *, void *);
-    void *method_data;
+                                  OSSL_PROVIDER *);
     int (*refcnt_up_method)(void *method);
     void (*destruct_method)(void *method);
 };
@@ -254,8 +253,7 @@ static void *construct_evp_method(const char *names, const OSSL_DISPATCH *fns,
 
     if (name_id == 0)
         return NULL;
-    return methdata->method_from_dispatch(name_id, fns, prov,
-                                          methdata->method_data);
+    return methdata->method_from_dispatch(name_id, fns, prov);
 }
 
 static void destruct_evp_method(void *method, void *data)
@@ -271,9 +269,7 @@ inner_evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
                         const char *properties,
                         void *(*new_method)(int name_id,
                                             const OSSL_DISPATCH *fns,
-                                            OSSL_PROVIDER *prov,
-                                            void *method_data),
-                        void *method_data,
+                                            OSSL_PROVIDER *prov),
                         int (*up_ref_method)(void *),
                         void (*free_method)(void *))
 {
@@ -335,7 +331,6 @@ inner_evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
         mcmdata.destruct_method = free_method;
         mcmdata.refcnt_up_method = up_ref_method;
         mcmdata.destruct_method = free_method;
-        mcmdata.method_data = method_data;
         if ((method = ossl_method_construct(libctx, operation_id,
                                             0 /* !force_cache */,
                                             &mcm, &mcmdata)) != NULL) {
@@ -361,16 +356,13 @@ void *evp_generic_fetch(OPENSSL_CTX *libctx, int operation_id,
                         const char *name, const char *properties,
                         void *(*new_method)(int name_id,
                                             const OSSL_DISPATCH *fns,
-                                            OSSL_PROVIDER *prov,
-                                            void *method_data),
-                        void *method_data,
+                                            OSSL_PROVIDER *prov),
                         int (*up_ref_method)(void *),
                         void (*free_method)(void *))
 {
     return inner_evp_generic_fetch(libctx,
                                    operation_id, 0, name, properties,
-                                   new_method, method_data,
-                                   up_ref_method, free_method);
+                                   new_method, up_ref_method, free_method);
 }
 
 /*
@@ -384,16 +376,13 @@ void *evp_generic_fetch_by_number(OPENSSL_CTX *libctx, int operation_id,
                                   int name_id, const char *properties,
                                   void *(*new_method)(int name_id,
                                                       const OSSL_DISPATCH *fns,
-                                                      OSSL_PROVIDER *prov,
-                                                      void *method_data),
-                                  void *method_data,
+                                                      OSSL_PROVIDER *prov),
                                   int (*up_ref_method)(void *),
                                   void (*free_method)(void *))
 {
     return inner_evp_generic_fetch(libctx,
                                    operation_id, name_id, NULL, properties,
-                                   new_method, method_data,
-                                   up_ref_method, free_method);
+                                   new_method, up_ref_method, free_method);
 }
 
 int EVP_set_default_properties(OPENSSL_CTX *libctx, const char *propq)
@@ -410,8 +399,7 @@ struct do_all_data_st {
     void (*user_fn)(void *method, void *arg);
     void *user_arg;
     void *(*new_method)(const int name_id, const OSSL_DISPATCH *fns,
-                        OSSL_PROVIDER *prov, void *method_data);
-    void *method_data;
+                        OSSL_PROVIDER *prov);
     void (*free_method)(void *);
 };
 
@@ -425,8 +413,7 @@ static void do_one(OSSL_PROVIDER *provider, const OSSL_ALGORITHM *algo,
     void *method = NULL;
 
     if (name_id != 0)
-        method = data->new_method(name_id, algo->implementation, provider,
-                                  data->method_data);
+        method = data->new_method(name_id, algo->implementation, provider);
 
     if (method != NULL) {
         data->user_fn(method, data->user_arg);
@@ -439,15 +426,12 @@ void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
                         void *user_arg,
                         void *(*new_method)(int name_id,
                                             const OSSL_DISPATCH *fns,
-                                            OSSL_PROVIDER *prov,
-                                            void *method_data),
-                        void *method_data,
+                                            OSSL_PROVIDER *prov),
                         void (*free_method)(void *))
 {
     struct do_all_data_st data;
 
     data.new_method = new_method;
-    data.method_data = method_data;
     data.free_method = free_method;
     data.user_fn = user_fn;
     data.user_arg = user_arg;
index 259805d..803f786 100644 (file)
@@ -176,18 +176,14 @@ void *evp_generic_fetch(OPENSSL_CTX *ctx, int operation_id,
                         const char *name, const char *properties,
                         void *(*new_method)(int name_id,
                                             const OSSL_DISPATCH *fns,
-                                            OSSL_PROVIDER *prov,
-                                            void *method_data),
-                        void *method_data,
+                                            OSSL_PROVIDER *prov),
                         int (*up_ref_method)(void *),
                         void (*free_method)(void *));
 void *evp_generic_fetch_by_number(OPENSSL_CTX *ctx, int operation_id,
                                   int name_id, const char *properties,
                                   void *(*new_method)(int name_id,
                                                       const OSSL_DISPATCH *fns,
-                                                      OSSL_PROVIDER *prov,
-                                                      void *method_data),
-                                  void *method_data,
+                                                      OSSL_PROVIDER *prov),
                                   int (*up_ref_method)(void *),
                                   void (*free_method)(void *));
 void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
@@ -195,9 +191,7 @@ void evp_generic_do_all(OPENSSL_CTX *libctx, int operation_id,
                         void *user_arg,
                         void *(*new_method)(int name_id,
                                             const OSSL_DISPATCH *fns,
-                                            OSSL_PROVIDER *prov,
-                                            void *method_data),
-                        void *method_data,
+                                            OSSL_PROVIDER *prov),
                         void (*free_method)(void *));
 
 /* Internal fetchers for method types that are to be combined with others */
index 6e1372e..aebfbaf 100644 (file)
@@ -34,8 +34,7 @@ static EVP_KEYEXCH *evp_keyexch_new(OSSL_PROVIDER *prov)
 
 static void *evp_keyexch_from_dispatch(int name_id,
                                        const OSSL_DISPATCH *fns,
-                                       OSSL_PROVIDER *prov,
-                                       void *unused)
+                                       OSSL_PROVIDER *prov)
 {
     EVP_KEYEXCH *exchange = NULL;
     int fncnt = 0, paramfncnt = 0;
@@ -148,14 +147,10 @@ OSSL_PROVIDER *EVP_KEYEXCH_provider(const EVP_KEYEXCH *exchange)
 EVP_KEYEXCH *EVP_KEYEXCH_fetch(OPENSSL_CTX *ctx, const char *algorithm,
                                const char *properties)
 {
-    EVP_KEYEXCH *keyexch = NULL;
-
-    keyexch = evp_generic_fetch(ctx, OSSL_OP_KEYEXCH, algorithm, properties,
-                                evp_keyexch_from_dispatch, NULL,
-                                (int (*)(void *))EVP_KEYEXCH_up_ref,
-                                (void (*)(void *))EVP_KEYEXCH_free);
-
-    return keyexch;
+    return evp_generic_fetch(ctx, OSSL_OP_KEYEXCH, algorithm, properties,
+                             evp_keyexch_from_dispatch,
+                             (int (*)(void *))EVP_KEYEXCH_up_ref,
+                             (void (*)(void *))EVP_KEYEXCH_free);
 }
 
 int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx)
@@ -378,7 +373,7 @@ void EVP_KEYEXCH_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_KEYEXCH,
                        (void (*)(void *, void *))fn, arg,
-                       evp_keyexch_from_dispatch, NULL,
+                       evp_keyexch_from_dispatch,
                        (void (*)(void *))EVP_KEYEXCH_free);
 }
 
index 576dde6..219dbdf 100644 (file)
@@ -54,8 +54,7 @@ static void *evp_kdf_new(void)
 
 static void *evp_kdf_from_dispatch(int name_id,
                                    const OSSL_DISPATCH *fns,
-                                   OSSL_PROVIDER *prov,
-                                   void *method_data)
+                                   OSSL_PROVIDER *prov)
 {
     EVP_KDF *kdf = NULL;
     int fnkdfcnt = 0, fnctxcnt = 0;
@@ -152,7 +151,7 @@ EVP_KDF *EVP_KDF_fetch(OPENSSL_CTX *libctx, const char *algorithm,
                        const char *properties)
 {
     return evp_generic_fetch(libctx, OSSL_OP_KDF, algorithm, properties,
-                             evp_kdf_from_dispatch, NULL, evp_kdf_up_ref,
+                             evp_kdf_from_dispatch, evp_kdf_up_ref,
                              evp_kdf_free);
 }
 
@@ -193,5 +192,5 @@ void EVP_KDF_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_KDF,
                        (void (*)(void *, void *))fn, arg,
-                       evp_kdf_from_dispatch, NULL, evp_kdf_free);
+                       evp_kdf_from_dispatch, evp_kdf_free);
 }
index 9c8d482..8091bca 100644 (file)
@@ -35,8 +35,7 @@ static void *keymgmt_new(void)
 
 static void *keymgmt_from_dispatch(int name_id,
                                    const OSSL_DISPATCH *fns,
-                                   OSSL_PROVIDER *prov,
-                                   void *unused)
+                                   OSSL_PROVIDER *prov)
 {
     EVP_KEYMGMT *keymgmt = NULL;
 
@@ -158,7 +157,7 @@ EVP_KEYMGMT *evp_keymgmt_fetch_by_number(OPENSSL_CTX *ctx, int name_id,
 {
     return evp_generic_fetch_by_number(ctx,
                                        OSSL_OP_KEYMGMT, name_id, properties,
-                                       keymgmt_from_dispatch, NULL,
+                                       keymgmt_from_dispatch,
                                        (int (*)(void *))EVP_KEYMGMT_up_ref,
                                        (void (*)(void *))EVP_KEYMGMT_free);
 }
@@ -167,7 +166,7 @@ EVP_KEYMGMT *EVP_KEYMGMT_fetch(OPENSSL_CTX *ctx, const char *algorithm,
                                const char *properties)
 {
     return evp_generic_fetch(ctx, OSSL_OP_KEYMGMT, algorithm, properties,
-                             keymgmt_from_dispatch, NULL,
+                             keymgmt_from_dispatch,
                              (int (*)(void *))EVP_KEYMGMT_up_ref,
                              (void (*)(void *))EVP_KEYMGMT_free);
 }
@@ -216,7 +215,7 @@ void EVP_KEYMGMT_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_KEYMGMT,
                        (void (*)(void *, void *))fn, arg,
-                       keymgmt_from_dispatch, NULL,
+                       keymgmt_from_dispatch,
                        (void (*)(void *))EVP_KEYMGMT_free);
 }
 
index 2c124ae..b1fadb6 100644 (file)
@@ -48,8 +48,7 @@ static void *evp_mac_new(void)
 
 static void *evp_mac_from_dispatch(int name_id,
                                    const OSSL_DISPATCH *fns,
-                                   OSSL_PROVIDER *prov,
-                                   void *unused)
+                                   OSSL_PROVIDER *prov)
 {
     EVP_MAC *mac = NULL;
     int fnmaccnt = 0, fnctxcnt = 0;
@@ -154,7 +153,7 @@ EVP_MAC *EVP_MAC_fetch(OPENSSL_CTX *libctx, const char *algorithm,
                        const char *properties)
 {
     return evp_generic_fetch(libctx, OSSL_OP_MAC, algorithm, properties,
-                             evp_mac_from_dispatch, NULL, evp_mac_up_ref,
+                             evp_mac_from_dispatch, evp_mac_up_ref,
                              evp_mac_free);
 }
 
@@ -200,5 +199,5 @@ void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_MAC,
                        (void (*)(void *, void *))fn, arg,
-                       evp_mac_from_dispatch, NULL, evp_mac_free);
+                       evp_mac_from_dispatch, evp_mac_free);
 }
index 4a8ece5..d49d80b 100644 (file)
@@ -34,8 +34,7 @@ static EVP_SIGNATURE *evp_signature_new(OSSL_PROVIDER *prov)
 
 static void *evp_signature_from_dispatch(int name_id,
                                          const OSSL_DISPATCH *fns,
-                                         OSSL_PROVIDER *prov,
-                                         void *unused)
+                                         OSSL_PROVIDER *prov)
 {
     EVP_SIGNATURE *signature = NULL;
     int ctxfncnt = 0, signfncnt = 0, verifyfncnt = 0, verifyrecfncnt = 0;
@@ -277,7 +276,7 @@ EVP_SIGNATURE *EVP_SIGNATURE_fetch(OPENSSL_CTX *ctx, const char *algorithm,
                                    const char *properties)
 {
     return evp_generic_fetch(ctx, OSSL_OP_SIGNATURE, algorithm, properties,
-                             evp_signature_from_dispatch, NULL,
+                             evp_signature_from_dispatch,
                              (int (*)(void *))EVP_SIGNATURE_up_ref,
                              (void (*)(void *))EVP_SIGNATURE_free);
 }
@@ -299,7 +298,7 @@ void EVP_SIGNATURE_do_all_provided(OPENSSL_CTX *libctx,
 {
     evp_generic_do_all(libctx, OSSL_OP_SIGNATURE,
                        (void (*)(void *, void *))fn, arg,
-                       evp_signature_from_dispatch, NULL,
+                       evp_signature_from_dispatch,
                        (void (*)(void *))EVP_SIGNATURE_free);
 }