From: Richard Levitte Date: Thu, 29 Jun 2000 16:33:59 +0000 (+0000) Subject: Give the programmer of extra engines the possibility to actually make X-Git-Tag: OpenSSL-engine-0_9_6-beta1~37 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2a7619d762abf10056d0f6c33f537e111d819e80;p=oweals%2Fopenssl.git Give the programmer of extra engines the possibility to actually make it functional :-). --- diff --git a/crypto/engine/engine.h b/crypto/engine/engine.h index 7c7f181f15..6797a356cf 100644 --- a/crypto/engine/engine.h +++ b/crypto/engine/engine.h @@ -104,6 +104,13 @@ typedef int (*BN_MOD_EXP_CRT)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx); +/* Generic function pointer */ +typedef void (*ENGINE_GEN_FUNC_PTR)(); +/* Generic function pointer taking no arguments */ +typedef void (*ENGINE_GEN_INT_FUNC_PTR)(void); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR)(int cmd, long i, void *p, void (*f)()); + /* The list of "engine" types is a static array of (const ENGINE*) * pointers (not dynamic because static is fine for now and we otherwise * have to hook an appropriate load/unload function in to initialise and @@ -160,6 +167,9 @@ int ENGINE_set_DH(ENGINE *e, DH_METHOD *dh_meth); int ENGINE_set_RAND(ENGINE *e, RAND_METHOD *rand_meth); int ENGINE_set_BN_mod_exp(ENGINE *e, BN_MOD_EXP bn_mod_exp); int ENGINE_set_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt); +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); /* These return values from within the ENGINE structure. These can * be useful with functional references as well as structural @@ -174,6 +184,9 @@ DH_METHOD *ENGINE_get_DH(ENGINE *e); RAND_METHOD *ENGINE_get_RAND(ENGINE *e); BN_MOD_EXP ENGINE_get_BN_mod_exp(ENGINE *e); BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(ENGINE *e); +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(ENGINE *e); +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(ENGINE *e); /* ENGINE_new is normally passed a NULL in the first parameter because * the calling code doesn't have access to the definition of the ENGINE @@ -283,9 +296,12 @@ void ERR_load_ENGINE_strings(void); #define ENGINE_F_ENGINE_FREE 108 #define ENGINE_F_ENGINE_GET_BN_MOD_EXP 109 #define ENGINE_F_ENGINE_GET_BN_MOD_EXP_CRT 110 +#define ENGINE_F_ENGINE_GET_CTRL_FUNCTION 144 #define ENGINE_F_ENGINE_GET_DH 111 #define ENGINE_F_ENGINE_GET_DSA 112 +#define ENGINE_F_ENGINE_GET_FINISH_FUNCTION 145 #define ENGINE_F_ENGINE_GET_ID 113 +#define ENGINE_F_ENGINE_GET_INIT_FUNCTION 146 #define ENGINE_F_ENGINE_GET_NAME 114 #define ENGINE_F_ENGINE_GET_NEXT 115 #define ENGINE_F_ENGINE_GET_PREV 116 @@ -298,10 +314,13 @@ void ERR_load_ENGINE_strings(void); #define ENGINE_F_ENGINE_REMOVE 123 #define ENGINE_F_ENGINE_SET_BN_MOD_EXP 124 #define ENGINE_F_ENGINE_SET_BN_MOD_EXP_CRT 125 +#define ENGINE_F_ENGINE_SET_CTRL_FUNCTION 147 #define ENGINE_F_ENGINE_SET_DEFAULT_TYPE 126 #define ENGINE_F_ENGINE_SET_DH 127 #define ENGINE_F_ENGINE_SET_DSA 128 +#define ENGINE_F_ENGINE_SET_FINISH_FUNCTION 148 #define ENGINE_F_ENGINE_SET_ID 129 +#define ENGINE_F_ENGINE_SET_INIT_FUNCTION 149 #define ENGINE_F_ENGINE_SET_NAME 130 #define ENGINE_F_ENGINE_SET_RAND 131 #define ENGINE_F_ENGINE_SET_RSA 132 diff --git a/crypto/engine/engine_err.c b/crypto/engine/engine_err.c index a250367c3b..01c382f5ba 100644 --- a/crypto/engine/engine_err.c +++ b/crypto/engine/engine_err.c @@ -84,9 +84,12 @@ static ERR_STRING_DATA ENGINE_str_functs[]= {ERR_PACK(0,ENGINE_F_ENGINE_FREE,0), "ENGINE_free"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_BN_MOD_EXP,0), "ENGINE_get_BN_mod_exp"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_BN_MOD_EXP_CRT,0), "ENGINE_get_BN_mod_exp_crt"}, +{ERR_PACK(0,ENGINE_F_ENGINE_GET_CTRL_FUNCTION,0), "ENGINE_get_ctrl_function"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_DH,0), "ENGINE_get_DH"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_DSA,0), "ENGINE_get_DSA"}, +{ERR_PACK(0,ENGINE_F_ENGINE_GET_FINISH_FUNCTION,0), "ENGINE_get_finish_function"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_ID,0), "ENGINE_get_id"}, +{ERR_PACK(0,ENGINE_F_ENGINE_GET_INIT_FUNCTION,0), "ENGINE_get_init_function"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_NAME,0), "ENGINE_get_name"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_NEXT,0), "ENGINE_get_next"}, {ERR_PACK(0,ENGINE_F_ENGINE_GET_PREV,0), "ENGINE_get_prev"}, @@ -99,10 +102,13 @@ static ERR_STRING_DATA ENGINE_str_functs[]= {ERR_PACK(0,ENGINE_F_ENGINE_REMOVE,0), "ENGINE_remove"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_BN_MOD_EXP,0), "ENGINE_set_BN_mod_exp"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_BN_MOD_EXP_CRT,0), "ENGINE_set_BN_mod_exp_crt"}, +{ERR_PACK(0,ENGINE_F_ENGINE_SET_CTRL_FUNCTION,0), "ENGINE_set_ctrl_function"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_DEFAULT_TYPE,0), "ENGINE_SET_DEFAULT_TYPE"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_DH,0), "ENGINE_set_DH"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_DSA,0), "ENGINE_set_DSA"}, +{ERR_PACK(0,ENGINE_F_ENGINE_SET_FINISH_FUNCTION,0), "ENGINE_set_finish_function"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_ID,0), "ENGINE_set_id"}, +{ERR_PACK(0,ENGINE_F_ENGINE_SET_INIT_FUNCTION,0), "ENGINE_set_init_function"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_NAME,0), "ENGINE_set_name"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_RAND,0), "ENGINE_set_RAND"}, {ERR_PACK(0,ENGINE_F_ENGINE_SET_RSA,0), "ENGINE_set_RSA"}, diff --git a/crypto/engine/engine_int.h b/crypto/engine/engine_int.h index fc9291dea2..aedf6617f6 100644 --- a/crypto/engine/engine_int.h +++ b/crypto/engine/engine_int.h @@ -86,6 +86,13 @@ typedef int (*BN_MOD_EXP_CRT)(BIGNUM *r, BIGNUM *a, const BIGNUM *p, const BIGNUM *q, const BIGNUM *dmp1, const BIGNUM *dmq1, const BIGNUM *iqmp, BN_CTX *ctx); +/* Generic function pointer */ +typedef int (*ENGINE_GEN_FUNC_PTR)(); +/* Generic function pointer taking no arguments */ +typedef int (*ENGINE_GEN_INT_FUNC_PTR)(void); +/* Specific control function pointer */ +typedef int (*ENGINE_CTRL_FUNC_PTR)(int cmd, long i, void *p, void (*f)()); + #endif /* This is a structure for storing implementations of various crypto diff --git a/crypto/engine/engine_list.c b/crypto/engine/engine_list.c index 20833ac20e..0e50497145 100644 --- a/crypto/engine/engine_list.c +++ b/crypto/engine/engine_list.c @@ -514,6 +514,42 @@ int ENGINE_set_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt) return 1; } +int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f) + { + if((e == NULL) || (init_f == NULL)) + { + ENGINEerr(ENGINE_F_ENGINE_SET_INIT_FUNCTION, + ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + e->init = init_f; + return 1; + } + +int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f) + { + if((e == NULL) || (finish_f == NULL)) + { + ENGINEerr(ENGINE_F_ENGINE_SET_FINISH_FUNCTION, + ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + e->finish = finish_f; + return 1; + } + +int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f) + { + if((e == NULL) || (ctrl_f == NULL)) + { + ENGINEerr(ENGINE_F_ENGINE_SET_CTRL_FUNCTION, + ERR_R_PASSED_NULL_PARAMETER); + return 0; + } + e->ctrl = ctrl_f; + return 1; + } + const char *ENGINE_get_id(ENGINE *e) { if(e == NULL) @@ -601,3 +637,37 @@ BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(ENGINE *e) } return e->bn_mod_exp_crt; } + +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(ENGINE *e) + { + if(e == NULL) + { + ENGINEerr(ENGINE_F_ENGINE_GET_INIT_FUNCTION, + ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + return e->init; + } + +ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(ENGINE *e) + { + if(e == NULL) + { + ENGINEerr(ENGINE_F_ENGINE_GET_FINISH_FUNCTION, + ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + return e->finish; + } + +ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(ENGINE *e) + { + if(e == NULL) + { + ENGINEerr(ENGINE_F_ENGINE_GET_CTRL_FUNCTION, + ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + return e->ctrl; + } + diff --git a/util/libeay.num b/util/libeay.num index 3c593f1a01..33cb311459 100755 --- a/util/libeay.num +++ b/util/libeay.num @@ -1890,3 +1890,9 @@ ENGINE_add 2465 DH_set_default_openssl_method 2466 ENGINE_get_DSA 2467 ENGINE_ctrl 2468 +ENGINE_get_finish_function 2469 +ENGINE_get_init_function 2470 +ENGINE_set_init_function 2471 +ENGINE_set_finish_function 2472 +ENGINE_get_ctrl_function 2473 +ENGINE_set_ctrl_function 2474