Latest update

This commit is contained in:
2019-03-07 13:14:32 +09:00
parent 25fbda8e8b
commit ee0cf37f98
226 changed files with 20407 additions and 2210 deletions
+6 -13
View File
@@ -9,8 +9,7 @@
#include "eng_int.h"
#include <openssl/conf.h>
/* #define ENGINE_CONF_DEBUG */
#include <openssl/trace.h>
/* ENGINE config module */
@@ -50,9 +49,7 @@ static int int_engine_configure(const char *name, const char *value, const CONF
int soft = 0;
name = skip_dot(name);
#ifdef ENGINE_CONF_DEBUG
fprintf(stderr, "Configuring engine %s\n", name);
#endif
OSSL_TRACE1(ENGINE_CONF, "Configuring engine %s\n", name);
/* Value is a section containing ENGINE commands */
ecmds = NCONF_get_section(cnf, value);
@@ -66,10 +63,8 @@ static int int_engine_configure(const char *name, const char *value, const CONF
ecmd = sk_CONF_VALUE_value(ecmds, i);
ctrlname = skip_dot(ecmd->name);
ctrlvalue = ecmd->value;
#ifdef ENGINE_CONF_DEBUG
fprintf(stderr, "ENGINE conf: doing ctrl(%s,%s)\n", ctrlname,
ctrlvalue);
#endif
OSSL_TRACE2(ENGINE_CONF, "ENGINE conf: doing ctrl(%s,%s)\n",
ctrlname, ctrlvalue);
/* First handle some special pseudo ctrls */
@@ -153,10 +148,8 @@ static int int_engine_module_init(CONF_IMODULE *md, const CONF *cnf)
STACK_OF(CONF_VALUE) *elist;
CONF_VALUE *cval;
int i;
#ifdef ENGINE_CONF_DEBUG
fprintf(stderr, "Called engine module: name %s, value %s\n",
CONF_imodule_get_name(md), CONF_imodule_get_value(md));
#endif
OSSL_TRACE2(ENGINE_CONF, "Called engine module: name %s, value %s\n",
CONF_imodule_get_name(md), CONF_imodule_get_value(md));
/* Value is a section containing ENGINEs to configure */
elist = NCONF_get_section(cnf, CONF_imodule_get_value(md));
+17 -34
View File
@@ -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"
@@ -19,27 +20,20 @@
extern CRYPTO_RWLOCK *global_engine_lock;
/*
* If we compile with this symbol defined, then both reference counts in the
* ENGINE structure will be monitored with a line of output on stderr for
* each change. This prints the engine's pointer address (truncated to
* unsigned int), "struct" or "funct" to indicate the reference type, the
* before and after reference count, and the file:line-number pair. The
* "engine_ref_debug" statements must come *after* the change.
* This prints the engine's pointer address (truncated to unsigned int),
* "struct" or "funct" to indicate the reference type, the before and after
* reference count, and the file:line-number pair. The "engine_ref_debug"
* statements must come *after* the change.
*/
# ifdef ENGINE_REF_COUNT_DEBUG
# define engine_ref_debug(e, isfunct, diff) \
fprintf(stderr, "engine: %08x %s from %d to %d (%s:%d)\n", \
(unsigned int)(e), (isfunct ? "funct" : "struct"), \
((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
(OPENSSL_FILE), (OPENSSL_LINE))
# else
# define engine_ref_debug(e, isfunct, diff)
# endif
# define engine_ref_debug(e, isfunct, diff) \
OSSL_TRACE6(ENGINE_REF_COUNT, \
"engine: %p %s from %d to %d (%s:%d)\n", \
(void *)(e), (isfunct ? "funct" : "struct"), \
((isfunct) \
? ((e)->funct_ref - (diff)) \
: ((e)->struct_ref - (diff))), \
((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
(OPENSSL_FILE), (OPENSSL_LINE))
/*
* Any code that will need cleanup operations should use these functions to
@@ -58,14 +52,6 @@ void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);
/* We need stacks of ENGINEs for use in eng_table.c */
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 +62,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,
+25 -32
View File
@@ -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