/* RSA stuff */
#ifndef OPENSSL_NO_RSA
-static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa);
+static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx);
#endif
/* This function is aliased to mod_exp (with the mont stuff dropped). */
#endif
#ifndef OPENSSL_NO_RSA
-static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)
+static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx)
{
- BN_CTX *ctx = NULL;
int to_return = 0;
AEP_RV rv = AEP_R_OK;
- if ((ctx = BN_CTX_new()) == NULL)
- goto err;
-
if (!aep_dso)
{
AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_NOT_LOADED);
if (rv == FAIL_TO_SW){
const RSA_METHOD *meth = RSA_PKCS1_SSLeay();
- to_return = (*meth->rsa_mod_exp)(r0, I, rsa);
+ to_return = (*meth->rsa_mod_exp)(r0, I, rsa, ctx);
goto err;
}
else if (rv != AEP_R_OK)
to_return = 1;
err:
- if(ctx)
- BN_CTX_free(ctx);
return to_return;
}
#endif