]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Expanding trace of providers algorithms fetching/caching/etc
authorDmitry Belyavskiy <beldmit@gmail.com>
Thu, 23 Jan 2025 16:27:31 +0000 (17:27 +0100)
committerTomas Mraz <tomas@openssl.org>
Mon, 27 Jan 2025 08:07:48 +0000 (09:07 +0100)
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/26543)

crypto/context.c
crypto/core_fetch.c
crypto/evp/evp_fetch.c
crypto/property/property.c

index 9bb0577adfd8a50b11a9622625d08cb17210e464..5ff8b069080e62833b3d1f76197edc0b222ae6ea 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "crypto/cryptlib.h"
 #include <openssl/conf.h>
+#include <openssl/trace.h>
 #include "internal/thread_once.h"
 #include "internal/property.h"
 #include "internal/cryptlib.h"
@@ -107,6 +108,7 @@ static int context_init(OSSL_LIB_CTX *ctx)
     ctx->evp_method_store = ossl_method_store_new(ctx);
     if (ctx->evp_method_store == NULL)
         goto err;
+    OSSL_TRACE1(QUERY, "context_init: allocating store %p\n", ctx->evp_method_store);
 
 #ifndef FIPS_MODULE
     /* P2. Must be freed before the provider store is freed */
index 70715e7d6a99c4ef632b1dacfc71f231e0a6345d..9c028a0b95f053982162db70ff7a46d43d6a2ca8 100644 (file)
@@ -10,6 +10,7 @@
 #include <stddef.h>
 
 #include <openssl/core.h>
+#include <openssl/trace.h>
 #include "internal/cryptlib.h"
 #include "internal/core.h"
 #include "internal/property.h"
@@ -110,6 +111,9 @@ static void ossl_method_construct_this(OSSL_PROVIDER *provider,
         == NULL)
         return;
 
+    OSSL_TRACE2(QUERY,
+                "ossl_method_construct_this: putting an algo to the store %p with no_store %d\n",
+                (void *)data->store, no_store);
     /*
      * Note regarding putting the method in stores:
      *
index 408b3897c994af9d64528c8c5f4bf8172047dd74..915d55c983022c5c58214f13ee27c6e68c12857a 100644 (file)
@@ -48,13 +48,18 @@ static void *get_tmp_evp_method_store(void *data)
 {
     struct evp_method_data_st *methdata = data;
 
-    if (methdata->tmp_store == NULL)
+    if (methdata->tmp_store == NULL) {
         methdata->tmp_store = ossl_method_store_new(methdata->libctx);
+        OSSL_TRACE1(QUERY, "Allocating a new tmp_store %p\n", (void *)methdata->tmp_store);
+    } else {
+        OSSL_TRACE1(QUERY, "Using the existing tmp_store %p\n", (void *)methdata->tmp_store);
+    }
     return methdata->tmp_store;
 }
 
  static void dealloc_tmp_evp_method_store(void *store)
 {
+    OSSL_TRACE1(QUERY, "Deallocating the tmp_store %p\n", store);
     if (store != NULL)
         ossl_method_store_free(store);
 }
@@ -184,10 +189,15 @@ static int put_evp_method_in_store(void *store, void *method,
         || (meth_id = evp_method_id(name_id, methdata->operation_id)) == 0)
         return 0;
 
+    OSSL_TRACE1(QUERY, "put_evp_method_in_store: original store: %p\n", store);
     if (store == NULL
         && (store = get_evp_method_store(methdata->libctx)) == NULL)
         return 0;
 
+    OSSL_TRACE5(QUERY,
+                "put_evp_method_in_store: "
+                "store: %p, names: %s, operation_id %d, method_id: %d, properties: %s\n",
+                store, names, methdata->operation_id, meth_id, propdef ? propdef : "<null>");
     return ossl_method_store_add(store, prov, meth_id, propdef, method,
                                  methdata->refcnt_up_method,
                                  methdata->destruct_method);
@@ -357,6 +367,11 @@ inner_evp_generic_fetch(struct evp_method_data_st *methdata,
                        ossl_lib_ctx_get_descriptor(methdata->libctx),
                        name == NULL ? "<null>" : name, name_id,
                        properties == NULL ? "<null>" : properties);
+    } else {
+        OSSL_TRACE4(QUERY, "%s, Algorithm (%s : %d), Properties (%s)\n",
+                    ossl_lib_ctx_get_descriptor(methdata->libctx),
+                    name == NULL ? "<null>" : name, name_id,
+                    properties == NULL ? "<null>" : properties);
     }
 
     return method;
index 4916ea450d277adc9f1a6b100165235b4c137ede..b177689e9b18c2db133c75c76f89c47707a8d843 100644 (file)
@@ -394,6 +394,7 @@ int ossl_method_store_add(OSSL_METHOD_STORE *store, const OSSL_PROVIDER *prov,
         alg->nid = nid;
         if (!ossl_method_store_insert(store, alg))
             goto err;
+        OSSL_TRACE2(QUERY, "Inserted an alg with nid %d into the store %p\n", nid, (void *)store);
     }
 
     /* Push onto stack if there isn't one there already */
@@ -639,11 +640,14 @@ int ossl_method_store_fetch(OSSL_METHOD_STORE *store,
     if (!ossl_property_read_lock(store))
         return 0;
 
+    OSSL_TRACE2(QUERY, "Retrieving by nid %d from store %p\n", nid, (void *)store);
     alg = ossl_method_store_retrieve(store, nid);
     if (alg == NULL) {
         ossl_property_unlock(store);
+        OSSL_TRACE2(QUERY, "Failed to retrieve by nid %d from store %p\n", nid, (void *)store);
         return 0;
     }
+    OSSL_TRACE2(QUERY, "Retrieved by nid %d from store %p\n", nid, (void *)store);
 
     /*
      * If a property query string is provided, convert it to an