summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_mul.c
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2018-08-10 19:31:22 +0200
committerAndy Polyakov <appro@openssl.org>2018-08-23 22:20:35 +0200
commitfcc4ee09473cac511eca90faa003661c7786e4f9 (patch)
treeb632f6792647ed32472a8d898437553df80a5ba3 /crypto/bn/bn_mul.c
parent0b89db6b2acb6cca36f812ba51119927563b3cac (diff)
crypto/bn: add more fixed-top routines.
Add bn_{mul|sqr}_fixed_top, bn_from_mont_fixed_top, bn_mod_sub_fixed_top. Switch to bn_{mul|sqr}_fixed_top in bn_mul_mont_fixed_top and remove memset in bn_from_montgomery_word. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/6915)
Diffstat (limited to 'crypto/bn/bn_mul.c')
-rw-r--r--crypto/bn/bn_mul.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c
index 07aaf5891f..bbbb84ac30 100644
--- a/crypto/bn/bn_mul.c
+++ b/crypto/bn/bn_mul.c
@@ -496,6 +496,16 @@ void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
+ int ret = bn_mul_fixed_top(r, a, b, ctx);
+
+ bn_correct_top(r);
+ bn_check_top(r);
+
+ return ret;
+}
+
+int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+{
int ret = 0;
int top, al, bl;
BIGNUM *rr;
@@ -598,7 +608,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
end:
#endif
rr->neg = a->neg ^ b->neg;
- bn_correct_top(rr);
+ rr->flags |= BN_FLG_FIXED_TOP;
if (r != rr && BN_copy(r, rr) == NULL)
goto err;