if(ctx) BN_CTX_free(ctx);
static int aep_rsa_mod_exp(BIGNUM *r0, const BIGNUM *I, RSA *rsa)	{	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);		goto err;		}	/*See if we have all the necessary bits for a crt*/	if (rsa->q && rsa->dmp1 && rsa->dmq1 && rsa->iqmp)		{		rv =  aep_mod_exp_crt(r0,I,rsa->p,rsa->q, rsa->dmp1,rsa->dmq1,rsa->iqmp,ctx);		if (rv == FAIL_TO_SW){			const RSA_METHOD *meth = RSA_PKCS1_SSLeay();			to_return = (*meth->rsa_mod_exp)(r0, I, rsa);			goto err;		}		else if (rv != AEP_R_OK)			goto err;		}	else		{		if (!rsa->d || !rsa->n)			{			AEPHKerr(AEPHK_F_AEP_RSA_MOD_EXP,AEPHK_R_MISSING_KEY_COMPONENTS);			goto err;			} 		rv = aep_mod_exp(r0,I,rsa->d,rsa->n,ctx);		if  (rv != AEP_R_OK)			goto err;			}	to_return = 1; err:	if(ctx)		BN_CTX_free(ctx);	return to_return;}