[openssl] master update

Richard Levitte levitte at openssl.org
Sun Feb 2 11:02:03 UTC 2020


The branch master has been updated
       via  658608c471a6e1f9b6d7f88c060a7adb77d7d334 (commit)
      from  4bf3e989fef9268507ba02744e7f71ee5637681c (commit)


- Log -----------------------------------------------------------------
commit 658608c471a6e1f9b6d7f88c060a7adb77d7d334
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Jan 28 16:51:01 2020 +0100

    EVP: Small refactor of keymgmt library code
    
    Some functions went directly on keymgmt function pointers instead of
    going through the internal KEYMGMT API, which makes for a confusing
    read.
    
    Related to #10962
    
    Reviewed-by: Matt Caswell <matt at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/10963)

-----------------------------------------------------------------------

Summary of changes:
 crypto/evp/keymgmt_lib.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/crypto/evp/keymgmt_lib.c b/crypto/evp/keymgmt_lib.c
index 1f4b4a104f..5e208b21b8 100644
--- a/crypto/evp/keymgmt_lib.c
+++ b/crypto/evp/keymgmt_lib.c
@@ -18,7 +18,7 @@
 
 struct import_data_st {
     void *provctx;
-    void *(*importfn)(void *provctx, const OSSL_PARAM params[]);
+    void *(*importfn)(const EVP_KEYMGMT *keymgmt, const OSSL_PARAM params[]);
 
     /* Result */
     void *provdata;
@@ -92,7 +92,9 @@ void *evp_keymgmt_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt,
         struct import_data_st import_data;
 
         import_data.importfn =
-            want_domainparams ? keymgmt->importdomparams : keymgmt->importkey;
+            want_domainparams
+            ? evp_keymgmt_importdomparams
+            : evp_keymgmt_importkey;
         import_data.provdata = NULL;
 
         /*
@@ -102,10 +104,11 @@ void *evp_keymgmt_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt,
             return NULL;
 
         for (j = 0; j < i && pk->pkeys[j].keymgmt != NULL; j++) {
-            int (*exportfn)(void *provctx, OSSL_CALLBACK *cb, void *cbarg) =
+            int (*exportfn)(const EVP_KEYMGMT *keymgmt, void *provdata,
+                            OSSL_CALLBACK *cb, void *cbarg) =
                 want_domainparams
-                ? pk->pkeys[j].keymgmt->exportdomparams
-                : pk->pkeys[j].keymgmt->exportkey;
+                ? evp_keymgmt_exportdomparams
+                : evp_keymgmt_exportkey;
 
             if (exportfn != NULL) {
                 import_data.provctx =
@@ -119,7 +122,8 @@ void *evp_keymgmt_export_to_provider(EVP_PKEY *pk, EVP_KEYMGMT *keymgmt,
                  * forgets to check the return value.
 
                  */
-                if (exportfn(pk->pkeys[j].provdata, &try_import, &import_data)
+                if (exportfn(pk->pkeys[j].keymgmt, pk->pkeys[j].provdata,
+                             &try_import, &import_data)
                     && (provdata = import_data.provdata) != NULL)
                     break;
             }
@@ -152,9 +156,9 @@ void evp_keymgmt_clear_pkey_cache(EVP_PKEY *pk)
             pk->pkeys[i].keymgmt = NULL;
             pk->pkeys[i].provdata = NULL;
             if (pk->pkeys[i].domainparams)
-                keymgmt->freedomparams(provdata);
+                evp_keymgmt_freedomparams(keymgmt, provdata);
             else
-                keymgmt->freekey(provdata);
+                evp_keymgmt_freekey(keymgmt, provdata);
             EVP_KEYMGMT_free(keymgmt);
         }
 
@@ -206,10 +210,9 @@ void evp_keymgmt_cache_pkey(EVP_PKEY *pk, size_t index, EVP_KEYMGMT *keymgmt,
 void *evp_keymgmt_fromdata(EVP_PKEY *target, EVP_KEYMGMT *keymgmt,
                            const OSSL_PARAM params[], int domainparams)
 {
-    void *provctx = ossl_provider_ctx(EVP_KEYMGMT_provider(keymgmt));
     void *provdata = domainparams
-        ? keymgmt->importdomparams(provctx, params)
-        : keymgmt->importkey(provctx, params);
+        ? evp_keymgmt_importdomparams(keymgmt, params)
+        : evp_keymgmt_importkey(keymgmt, params);
 
     evp_keymgmt_clear_pkey_cache(target);
     evp_keymgmt_cache_pkey(target, 0, keymgmt, provdata, domainparams);


More information about the openssl-commits mailing list