From 020fc820dc90dbbcf0d7e3f3345af9e44cf905a7 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Mon, 6 Nov 2000 21:15:54 +0000 Subject: Constify the BIGNUM routines a bit more. The only trouble were the two functions that did expansion on in parameters (BN_mul() and BN_sqr()). The problem was solved by making bn_dup_expand() which is a mix of bn_expand2() and BN_dup(). --- crypto/bn/bn_sqr.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'crypto/bn/bn_sqr.c') diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index 75f4f38392..4789f131a1 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -62,11 +62,11 @@ /* r must not be a */ /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */ -int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx) +int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) { int max,al; int ret = 0; - BIGNUM *tmp,*rr; + BIGNUM *tmp,*rr,*free_a = NULL; #ifdef BN_COUNT printf("BN_sqr %d * %d\n",a->top,a->top); @@ -124,8 +124,10 @@ printf("BN_sqr %d * %d\n",a->top,a->top); k=j+j; if (al == j) { - if (bn_wexpand(a,k*2) == NULL) goto err; + 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 @@ -145,6 +147,7 @@ printf("BN_sqr %d * %d\n",a->top,a->top); if (rr != r) BN_copy(r,rr); ret = 1; err: + if (free_a) BN_free(free_a); BN_CTX_end(ctx); return(ret); } -- cgit v1.2.3