diff options
author | Ulf Möller <ulf@openssl.org> | 2000-02-05 14:17:32 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2000-02-05 14:17:32 +0000 |
commit | 9b141126d4b6f0636bc047e81b846c193ae26611 (patch) | |
tree | c8786c99bfccc8b9899cad5c3aa30f29ada5e1b9 /crypto/bn/bn_mul.c | |
parent | 7e708ebee066d0308a335579b546326220dc8317 (diff) | |
download | openssl-9b141126d4b6f0636bc047e81b846c193ae26611.tar.gz |
New functions BN_CTX_start(), BN_CTX_get(), BN_CTX_end() to access
temporary BIGNUMs. BN_CTX still uses a fixed number of BIGNUMs, but
the BN_CTX implementation could now easily be changed.
Diffstat (limited to 'crypto/bn/bn_mul.c')
-rw-r--r-- | crypto/bn/bn_mul.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c index 54414993db..36e9c4d9ff 100644 --- a/crypto/bn/bn_mul.c +++ b/crypto/bn/bn_mul.c @@ -585,10 +585,13 @@ printf("BN_mul %d * %d\n",a->top,b->top); } top=al+bl; + BN_CTX_start(ctx); if ((r == a) || (r == b)) - rr= &(ctx->bn[ctx->tos+1]); + { + if ((rr = BN_CTX_get(ctx)) == NULL) goto err; + } else - rr=r; + rr = r; #if defined(BN_MUL_COMBA) || defined(BN_RECURSION) if (al == bl) @@ -596,14 +599,14 @@ printf("BN_mul %d * %d\n",a->top,b->top); # ifdef BN_MUL_COMBA /* if (al == 4) { - if (bn_wexpand(rr,8) == NULL) return(0); + if (bn_wexpand(rr,8) == NULL) goto err; rr->top=8; bn_mul_comba4(rr->d,a->d,b->d); goto end; } else */ if (al == 8) { - if (bn_wexpand(rr,16) == NULL) return(0); + if (bn_wexpand(rr,16) == NULL) goto err; rr->top=16; bn_mul_comba8(rr->d,a->d,b->d); goto end; @@ -614,7 +617,7 @@ printf("BN_mul %d * %d\n",a->top,b->top); if (al < BN_MULL_SIZE_NORMAL) #endif { - if (bn_wexpand(rr,top) == NULL) return(0); + if (bn_wexpand(rr,top) == NULL) goto err; rr->top=top; bn_mul_normal(rr->d,a->d,al,b->d,bl); goto end; @@ -627,7 +630,7 @@ printf("BN_mul %d * %d\n",a->top,b->top); #ifdef BN_RECURSION else if ((al < BN_MULL_SIZE_NORMAL) || (bl < BN_MULL_SIZE_NORMAL)) { - if (bn_wexpand(rr,top) == NULL) return(0); + if (bn_wexpand(rr,top) == NULL) goto err; rr->top=top; bn_mul_normal(rr->d,a->d,al,b->d,bl); goto end; @@ -653,7 +656,7 @@ printf("BN_mul %d * %d\n",a->top,b->top); #endif /* asymmetric and >= 4 */ - if (bn_wexpand(rr,top) == NULL) return(0); + if (bn_wexpand(rr,top) == NULL) goto err; rr->top=top; bn_mul_normal(rr->d,a->d,al,b->d,bl); @@ -666,7 +669,7 @@ symmetric: j=BN_num_bits_word((BN_ULONG)al); j=1<<(j-1); k=j+j; - t= &(ctx->bn[ctx->tos]); + t = BN_CTX_get(ctx); if (al == j) /* exact multiple */ { bn_wexpand(t,k*2); @@ -693,7 +696,11 @@ end: #endif bn_fix_top(rr); if (r != rr) BN_copy(r,rr); + BN_CTX_end(ctx); return(1); +err: + BN_CTX_end(ctx); + return(0); } void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) |