summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_exp2.c
diff options
context:
space:
mode:
authorUlf Möller <ulf@openssl.org>2000-02-05 15:17:32 +0100
committerUlf Möller <ulf@openssl.org>2000-02-05 15:17:32 +0100
commit9b141126d4b6f0636bc047e81b846c193ae26611 (patch)
treec8786c99bfccc8b9899cad5c3aa30f29ada5e1b9 /crypto/bn/bn_exp2.c
parentmd2 is documented in the md5 page. lets see if this works... (diff)
downloadopenssl-9b141126d4b6f0636bc047e81b846c193ae26611.tar.xz
openssl-9b141126d4b6f0636bc047e81b846c193ae26611.zip
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_exp2.c')
-rw-r--r--crypto/bn/bn_exp2.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/crypto/bn/bn_exp2.c b/crypto/bn/bn_exp2.c
index 2d7bf8997d..4f4e9e3299 100644
--- a/crypto/bn/bn_exp2.c
+++ b/crypto/bn/bn_exp2.c
@@ -35,15 +35,19 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);
return(0);
}
- d= &(ctx->bn[ctx->tos++]);
- r= &(ctx->bn[ctx->tos++]);
bits1=BN_num_bits(p1);
bits2=BN_num_bits(p2);
if ((bits1 == 0) && (bits2 == 0))
{
- BN_one(r);
+ BN_one(rr);
return(1);
}
+
+ BN_CTX_start(ctx);
+ d = BN_CTX_get(ctx);
+ r = BN_CTX_get(ctx);
+ if (d == NULL || r == NULL) goto err;
+
bits=(bits1 > bits2)?bits1:bits2;
/* If this is not done, things will break in the montgomery
@@ -183,7 +187,7 @@ int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2,
ret=1;
err:
if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
- ctx->tos-=2;
+ BN_CTX_end(ctx);
for (i=0; i<ts; i++)
{
for (j=0; j<ts; j++)