Avoid use of ex_data free function in Chil ENGINE so it can be safely
reloaded.
This commit is contained in:
parent
dce2b5a8fc
commit
f0b358e8b9
@ -111,11 +111,10 @@ static int hwcrhk_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
|||||||
#ifndef OPENSSL_NO_RSA
|
#ifndef OPENSSL_NO_RSA
|
||||||
/* RSA stuff */
|
/* RSA stuff */
|
||||||
static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
|
static int hwcrhk_rsa_mod_exp(BIGNUM *r, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
|
||||||
#endif
|
|
||||||
#ifndef OPENSSL_NO_RSA
|
|
||||||
/* This function is aliased to mod_exp (with the mont stuff dropped). */
|
/* This function is aliased to mod_exp (with the mont stuff dropped). */
|
||||||
static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
||||||
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
|
||||||
|
static int hwcrhk_rsa_finish(RSA *rsa);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_DH
|
#ifndef OPENSSL_NO_DH
|
||||||
@ -135,10 +134,6 @@ static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id,
|
|||||||
UI_METHOD *ui_method, void *callback_data);
|
UI_METHOD *ui_method, void *callback_data);
|
||||||
static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
|
static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id,
|
||||||
UI_METHOD *ui_method, void *callback_data);
|
UI_METHOD *ui_method, void *callback_data);
|
||||||
#ifndef OPENSSL_NO_RSA
|
|
||||||
static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
|
|
||||||
int ind,long argl, void *argp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Interaction stuff */
|
/* Interaction stuff */
|
||||||
static int hwcrhk_insert_card(const char *prompt_info,
|
static int hwcrhk_insert_card(const char *prompt_info,
|
||||||
@ -193,7 +188,7 @@ static RSA_METHOD hwcrhk_rsa =
|
|||||||
hwcrhk_rsa_mod_exp,
|
hwcrhk_rsa_mod_exp,
|
||||||
hwcrhk_mod_exp_mont,
|
hwcrhk_mod_exp_mont,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
hwcrhk_rsa_finish,
|
||||||
0,
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@ -602,7 +597,7 @@ static int hwcrhk_init(ENGINE *e)
|
|||||||
if (hndidx_rsa == -1)
|
if (hndidx_rsa == -1)
|
||||||
hndidx_rsa = RSA_get_ex_new_index(0,
|
hndidx_rsa = RSA_get_ex_new_index(0,
|
||||||
"nFast HWCryptoHook RSA key handle",
|
"nFast HWCryptoHook RSA key handle",
|
||||||
NULL, NULL, hwcrhk_ex_free);
|
NULL, NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
err:
|
err:
|
||||||
@ -1078,6 +1073,21 @@ static int hwcrhk_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
|
|||||||
{
|
{
|
||||||
return hwcrhk_mod_exp(r, a, p, m, ctx);
|
return hwcrhk_mod_exp(r, a, p, m, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int hwcrhk_rsa_finish(RSA *rsa)
|
||||||
|
{
|
||||||
|
HWCryptoHook_RSAKeyHandle *hptr;
|
||||||
|
int ret;
|
||||||
|
hptr = RSA_get_ex_data(rsa, hndidx_rsa);
|
||||||
|
if (hptr)
|
||||||
|
{
|
||||||
|
ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
|
||||||
|
OPENSSL_free(hptr);
|
||||||
|
RSA_set_ex_data(rsa, hndidx_rsa, NULL);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_DH
|
#ifndef OPENSSL_NO_DH
|
||||||
@ -1136,34 +1146,6 @@ static int hwcrhk_rand_status(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This cleans up an RSA KM key, called when ex_data is freed */
|
|
||||||
#ifndef OPENSSL_NO_RSA
|
|
||||||
static void hwcrhk_ex_free(void *obj, void *item, CRYPTO_EX_DATA *ad,
|
|
||||||
int ind,long argl, void *argp)
|
|
||||||
{
|
|
||||||
char tempbuf[1024];
|
|
||||||
HWCryptoHook_ErrMsgBuf rmsg;
|
|
||||||
#ifndef OPENSSL_NO_RSA
|
|
||||||
HWCryptoHook_RSAKeyHandle *hptr;
|
|
||||||
#endif
|
|
||||||
#if !defined(OPENSSL_NO_RSA)
|
|
||||||
int ret;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rmsg.buf = tempbuf;
|
|
||||||
rmsg.size = sizeof(tempbuf);
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_RSA
|
|
||||||
hptr = (HWCryptoHook_RSAKeyHandle *) item;
|
|
||||||
if(hptr)
|
|
||||||
{
|
|
||||||
ret = p_hwcrhk_RSAUnloadKey(*hptr, NULL);
|
|
||||||
OPENSSL_free(hptr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
|
/* Mutex calls: since the HWCryptoHook model closely follows the POSIX model
|
||||||
* these just wrap the POSIX functions and add some logging.
|
* these just wrap the POSIX functions and add some logging.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user