diff options
author | Richard Levitte <levitte@openssl.org> | 2000-11-16 21:35:41 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-11-16 21:35:41 +0000 |
commit | 43fcc1b096c47f5d5c10e09cf8a0f75ca4707e35 (patch) | |
tree | 5e0686c15aa26e9b4629105df6e47d3f78c65ba2 /crypto | |
parent | d5695a26a60ea8de12c28a148739e1b00bee0c78 (diff) |
I've checked again and again. There really is no need to expand a to
4 times it's size when bn_sqr_recursive() won't look farther than the
original length. Thereby, constification is no longer a problem.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/bn_sqr.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index 4789f131a1..bbff1ad72a 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -69,7 +69,7 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) BIGNUM *tmp,*rr,*free_a = NULL; #ifdef BN_COUNT -printf("BN_sqr %d * %d\n",a->top,a->top); + fprintf(stderr,"BN_sqr %d * %d\n",a->top,a->top); #endif bn_check_top(a); @@ -124,10 +124,7 @@ printf("BN_sqr %d * %d\n",a->top,a->top); k=j+j; if (al == j) { - BIGNUM *tmp_bn = free_a; - if ((a = free_a = bn_dup_expand(a,k*2)) == NULL) goto err; if (bn_wexpand(tmp,k*2) == NULL) goto err; - if (tmp_bn) BN_free(tmp_bn); bn_sqr_recursive(rr->d,a->d,al,tmp->d); } else @@ -153,10 +150,11 @@ printf("BN_sqr %d * %d\n",a->top,a->top); } /* tmp must have 2*n words */ -void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp) +void bn_sqr_normal(BN_ULONG *r, const BN_ULONG *a, int n, BN_ULONG *tmp) { int i,j,max; - BN_ULONG *ap,*rp; + const BN_ULONG *ap; + BN_ULONG *rp; max=n*2; ap=a; @@ -200,14 +198,14 @@ void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp) * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ -void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *t) +void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t) { int n=n2/2; int zero,c1; BN_ULONG ln,lo,*p; #ifdef BN_COUNT -printf(" bn_sqr_recursive %d * %d\n",n2,n2); + fprintf(stderr," bn_sqr_recursive %d * %d\n",n2,n2); #endif if (n2 == 4) { |