diff options
author | Andy Polyakov <appro@openssl.org> | 2005-10-04 06:19:29 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2005-10-04 06:19:29 +0000 |
commit | e738280547e0f7e3cc5756a92ce3c926eb7736ce (patch) | |
tree | 7f7eca3a84bb0f98d1970523ac9b32f9b1616295 /crypto/bn/bn_mont.c | |
parent | 8265328def2eec75a8afda71b38195a342aeecb2 (diff) |
Add reference implementation for bn_[mul|sqr]_mont, new candidates for
assembler implementation.
Diffstat (limited to 'crypto/bn/bn_mont.c')
-rw-r--r-- | crypto/bn/bn_mont.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index 82af91f90d..f70f8ab3ef 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -74,6 +74,22 @@ int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, { BIGNUM *tmp; int ret=0; +#ifdef OPENSSL_BN_ASM_MONT + int num = mont->N.top; + + if (num>1 && a->top==num && b->top==num) + { + if (bn_wexpand(r,num) == NULL) return 0; + r->neg = a->neg^b->neg; + r->top = num; + if (a==b) + bn_sqr_mont(r->d,a->d,mont->N.d,mont->n0,num); + else + bn_mul_mont(r->d,a->d,b->d,mont->N.d,mont->n0,num); + bn_fix_top(r); + return 1; + } +#endif BN_CTX_start(ctx); tmp = BN_CTX_get(ctx); |