ENGINE's init() and finish() handler functions are used when the ENGINE is
being enabled or disabled (respectively) for operation. Additionally, each ENGINE has a constructor function where it can do more 'structural' level intialisations such as loading error strings, creating "ex_data" indices, etc. This change introduces a handler function that gives an ENGINE a corresponding opportunity to cleanup when the ENGINE is being destroyed. It also adds the "get/set" API functions that control this "destroy" handler function in an ENGINE.
This commit is contained in:
parent
541814c403
commit
f524ddbe04
@ -371,6 +371,7 @@ int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth);
|
|||||||
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
|
int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth);
|
||||||
int ENGINE_set_BN_mod_exp(ENGINE *e, BN_MOD_EXP bn_mod_exp);
|
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_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt);
|
||||||
|
int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f);
|
||||||
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f);
|
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_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f);
|
||||||
int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
|
int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f);
|
||||||
@ -409,6 +410,7 @@ int ENGINE_cipher_num(const ENGINE *e);
|
|||||||
const EVP_CIPHER *ENGINE_get_cipher(const ENGINE *e, int n);
|
const EVP_CIPHER *ENGINE_get_cipher(const ENGINE *e, int n);
|
||||||
BN_MOD_EXP ENGINE_get_BN_mod_exp(const ENGINE *e);
|
BN_MOD_EXP ENGINE_get_BN_mod_exp(const ENGINE *e);
|
||||||
BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(const ENGINE *e);
|
BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(const ENGINE *e);
|
||||||
|
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e);
|
||||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
|
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e);
|
||||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
|
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e);
|
||||||
ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
|
ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e);
|
||||||
|
@ -112,6 +112,7 @@ struct engine_st
|
|||||||
|
|
||||||
BN_MOD_EXP bn_mod_exp;
|
BN_MOD_EXP bn_mod_exp;
|
||||||
BN_MOD_EXP_CRT bn_mod_exp_crt;
|
BN_MOD_EXP_CRT bn_mod_exp_crt;
|
||||||
|
ENGINE_GEN_INT_FUNC_PTR destroy;
|
||||||
ENGINE_GEN_INT_FUNC_PTR init;
|
ENGINE_GEN_INT_FUNC_PTR init;
|
||||||
ENGINE_GEN_INT_FUNC_PTR finish;
|
ENGINE_GEN_INT_FUNC_PTR finish;
|
||||||
ENGINE_CTRL_FUNC_PTR ctrl;
|
ENGINE_CTRL_FUNC_PTR ctrl;
|
||||||
|
@ -415,6 +415,10 @@ static int ENGINE_free_util(ENGINE *e, int locked)
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/* Give the ENGINE a chance to do any structural cleanup corresponding
|
||||||
|
* to allocation it did in its constructor (eg. unload error strings) */
|
||||||
|
if(e->destroy)
|
||||||
|
e->destroy(e);
|
||||||
sk_ENGINE_EVP_CIPHER_pop_free(e->ciphers,ENGINE_free_engine_cipher);
|
sk_ENGINE_EVP_CIPHER_pop_free(e->ciphers,ENGINE_free_engine_cipher);
|
||||||
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data);
|
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ENGINE, e, &e->ex_data);
|
||||||
OPENSSL_free(e);
|
OPENSSL_free(e);
|
||||||
@ -532,6 +536,12 @@ int ENGINE_set_BN_mod_exp_crt(ENGINE *e, BN_MOD_EXP_CRT bn_mod_exp_crt)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f)
|
||||||
|
{
|
||||||
|
e->destroy = destroy_f;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f)
|
int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f)
|
||||||
{
|
{
|
||||||
e->init = init_f;
|
e->init = init_f;
|
||||||
@ -648,6 +658,11 @@ BN_MOD_EXP_CRT ENGINE_get_BN_mod_exp_crt(const ENGINE *e)
|
|||||||
return e->bn_mod_exp_crt;
|
return e->bn_mod_exp_crt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e)
|
||||||
|
{
|
||||||
|
return e->destroy;
|
||||||
|
}
|
||||||
|
|
||||||
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e)
|
ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e)
|
||||||
{
|
{
|
||||||
return e->init;
|
return e->init;
|
||||||
|
Loading…
Reference in New Issue
Block a user