e_sureware.c 30.5 KB
Newer Older
					  (unsigned long *)psign->s->d,
					  hptr);
		surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_DSA_DO_SIGN,ret);
	}
	psign->r->top=20/sizeof(BN_ULONG);
	bn_fix_top(psign->r);
	psign->s->top=20/sizeof(BN_ULONG);
	bn_fix_top(psign->s);

err:	
	if (psign)
	{
		DSA_SIG_free(psign);
		psign=NULL;
	}
	return psign;
}
#endif

static int surewarehk_modexp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
			     const BIGNUM *m, BN_CTX *ctx)
{
	int ret=0;
	char msg[64]="ENGINE_modexp";
	if (!p_surewarehk_Mod_Exp)
	{
		SUREWAREerr(SUREWARE_F_SUREWAREHK_MODEXP,ENGINE_R_NOT_INITIALISED);
	}
	else
	{
		bn_expand2(r,m->top);
		if (r && r->dmax==m->top)
		{
			/* do it*/
			ret=p_surewarehk_Mod_Exp(msg,
						 m->top*sizeof(BN_ULONG),
						 (unsigned long *)m->d,
						 p->top*sizeof(BN_ULONG),
						 (unsigned long *)p->d,
						 a->top*sizeof(BN_ULONG),
						 (unsigned long *)a->d,
						 (unsigned long *)r->d);
			surewarehk_error_handling(msg,SUREWARE_F_SUREWAREHK_MODEXP,ret);
			if (ret==1)
			{
				/* normalise result */
				r->top=m->top;
				bn_fix_top(r);
			}
		}
	}
	return ret;
}
#endif /* !OPENSSL_NO_HW_SureWare */
#endif /* !OPENSSL_NO_HW */