summaryrefslogtreecommitdiffstats
path: root/crypto/engine
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-12-13 01:42:07 +0100
committerRichard Levitte <levitte@openssl.org>2019-03-06 11:15:14 +0100
commitf272be676b5462db641897057a4feaa9e8f35c1d (patch)
tree46869fc351b22e04e8286767237ef7276d77a26a /crypto/engine
parentf4db05df0e0bc665b98e7cda33d4572071884d03 (diff)
Adapt ENGINE_TABLE_DEBUG to the new generic trace API
Co-authored-by: Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8198)
Diffstat (limited to 'crypto/engine')
-rw-r--r--crypto/engine/eng_int.h18
-rw-r--r--crypto/engine/eng_table.c57
2 files changed, 29 insertions, 46 deletions
diff --git a/crypto/engine/eng_int.h b/crypto/engine/eng_int.h
index 2a32411a16..7bb1d73680 100644
--- a/crypto/engine/eng_int.h
+++ b/crypto/engine/eng_int.h
@@ -11,6 +11,7 @@
#ifndef HEADER_ENGINE_INT_H
# define HEADER_ENGINE_INT_H
+# include <openssl/trace.h>
# include "internal/cryptlib.h"
# include "internal/engine.h"
# include "internal/thread_once.h"
@@ -59,14 +60,6 @@ void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
DEFINE_STACK_OF(ENGINE)
/*
- * If this symbol is defined then engine_table_select(), the function that is
- * used by RSA, DSA (etc) code to select registered ENGINEs, cache defaults
- * and functional references (etc), will display debugging summaries to
- * stderr.
- */
-/* #define ENGINE_TABLE_DEBUG */
-
-/*
* This represents an implementation table. Dependent code should instantiate
* it as a (ENGINE_TABLE *) pointer value set initially to NULL.
*/
@@ -76,13 +69,10 @@ int engine_table_register(ENGINE_TABLE **table, ENGINE_CLEANUP_CB *cleanup,
int setdefault);
void engine_table_unregister(ENGINE_TABLE **table, ENGINE *e);
void engine_table_cleanup(ENGINE_TABLE **table);
-# ifndef ENGINE_TABLE_DEBUG
-ENGINE *engine_table_select(ENGINE_TABLE **table, int nid);
-# else
-ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
+ENGINE *engine_table_select_int(ENGINE_TABLE **table, int nid, const char *f,
int l);
-# define engine_table_select(t,n) engine_table_select_tmp(t,n,OPENSSL_FILE,OPENSSL_LINE)
-# endif
+# define engine_table_select(t,n) \
+ engine_table_select_int(t,n,OPENSSL_FILE,OPENSSL_LINE)
typedef void (engine_table_doall_cb) (int nid, STACK_OF(ENGINE) *sk,
ENGINE *def, void *arg);
void engine_table_doall(ENGINE_TABLE *table, engine_table_doall_cb *cb,
diff --git a/crypto/engine/eng_table.c b/crypto/engine/eng_table.c
index b0e3ebbbc9..c3afa583d0 100644
--- a/crypto/engine/eng_table.c
+++ b/crypto/engine/eng_table.c
@@ -10,6 +10,7 @@
#include "internal/cryptlib.h"
#include <openssl/evp.h>
#include <openssl/lhash.h>
+#include <openssl/trace.h>
#include "eng_int.h"
/* The type of the items in the table */
@@ -189,29 +190,24 @@ void engine_table_cleanup(ENGINE_TABLE **table)
}
/* return a functional reference for a given 'nid' */
-#ifndef ENGINE_TABLE_DEBUG
-ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)
-#else
-ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
+ENGINE *engine_table_select_int(ENGINE_TABLE **table, int nid, const char *f,
int l)
-#endif
{
ENGINE *ret = NULL;
ENGINE_PILE tmplate, *fnd = NULL;
int initres, loop = 0;
if (!(*table)) {
-#ifdef ENGINE_TABLE_DEBUG
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, nothing "
- "registered!\n", f, l, nid);
-#endif
+ OSSL_TRACE3(ENGINE_TABLE,
+ "%s:%d, nid=%d, nothing registered!\n",
+ f, l, nid);
return NULL;
}
ERR_set_mark();
CRYPTO_THREAD_write_lock(global_engine_lock);
/*
* Check again inside the lock otherwise we could race against cleanup
- * operations. But don't worry about a fprintf(stderr).
+ * operations. But don't worry about a debug printout
*/
if (!int_table_check(table, 0))
goto end;
@@ -220,10 +216,9 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
if (!fnd)
goto end;
if (fnd->funct && engine_unlocked_init(fnd->funct)) {
-#ifdef ENGINE_TABLE_DEBUG
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "
- "ENGINE '%s' cached\n", f, l, nid, fnd->funct->id);
-#endif
+ OSSL_TRACE4(ENGINE_TABLE,
+ "%s:%d, nid=%d, using ENGINE '%s' cached\n",
+ f, l, nid, fnd->funct->id);
ret = fnd->funct;
goto end;
}
@@ -234,10 +229,10 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
trynext:
ret = sk_ENGINE_value(fnd->sk, loop++);
if (!ret) {
-#ifdef ENGINE_TABLE_DEBUG
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "
- "registered implementations would initialise\n", f, l, nid);
-#endif
+ OSSL_TRACE3(ENGINE_TABLE,
+ "%s:%d, nid=%d, "
+ "no registered implementations would initialise\n",
+ f, l, nid);
goto end;
}
/* Try to initialise the ENGINE? */
@@ -252,15 +247,13 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
if (fnd->funct)
engine_unlocked_finish(fnd->funct, 0);
fnd->funct = ret;
-#ifdef ENGINE_TABLE_DEBUG
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, "
- "setting default to '%s'\n", f, l, nid, ret->id);
-#endif
+ OSSL_TRACE4(ENGINE_TABLE,
+ "%s:%d, nid=%d, setting default to '%s'\n",
+ f, l, nid, ret->id);
}
-#ifdef ENGINE_TABLE_DEBUG
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "
- "newly initialised '%s'\n", f, l, nid, ret->id);
-#endif
+ OSSL_TRACE4(ENGINE_TABLE,
+ "%s:%d, nid=%d, using newly initialised '%s'\n",
+ f, l, nid, ret->id);
goto end;
}
goto trynext;
@@ -271,14 +264,14 @@ ENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f,
*/
if (fnd)
fnd->uptodate = 1;
-#ifdef ENGINE_TABLE_DEBUG
if (ret)
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
- "ENGINE '%s'\n", f, l, nid, ret->id);
+ OSSL_TRACE4(ENGINE_TABLE,
+ "%s:%d, nid=%d, caching ENGINE '%s'\n",
+ f, l, nid, ret->id);
else
- fprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "
- "'no matching ENGINE'\n", f, l, nid);
-#endif
+ OSSL_TRACE3(ENGINE_TABLE,
+ "%s:%d, nid=%d, caching 'no matching ENGINE'\n",
+ f, l, nid);
CRYPTO_THREAD_unlock(global_engine_lock);
/*
* Whatever happened, any failed init()s are not failures in this