Latest update
This commit is contained in:
+25
-32
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user