diff options
author | Richard Levitte <levitte@openssl.org> | 2000-11-06 22:15:54 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2000-11-06 22:15:54 +0100 |
commit | 020fc820dc90dbbcf0d7e3f3345af9e44cf905a7 (patch) | |
tree | 43557879bf9ba3fd467211edf75155c45a51fd6f /crypto/bn/bn_sqr.c | |
parent | mode used too early in EVP_PKEY_save_parameters. (diff) | |
download | openssl-020fc820dc90dbbcf0d7e3f3345af9e44cf905a7.tar.xz openssl-020fc820dc90dbbcf0d7e3f3345af9e44cf905a7.zip |
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().
Diffstat (limited to 'crypto/bn/bn_sqr.c')
-rw-r--r-- | crypto/bn/bn_sqr.c | 9 |
1 files changed, 6 insertions, 3 deletions
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); } |