diff options
Diffstat (limited to 'crypto/openssl/crypto/bn/bn_exp2.c')
-rw-r--r-- | crypto/openssl/crypto/bn/bn_exp2.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crypto/openssl/crypto/bn/bn_exp2.c b/crypto/openssl/crypto/bn/bn_exp2.c index 1132d53..4f4e9e3 100644 --- a/crypto/openssl/crypto/bn/bn_exp2.c +++ b/crypto/openssl/crypto/bn/bn_exp2.c @@ -9,7 +9,7 @@ * bits=1 75.4% 79.4% * bits=2 61.2% 62.4% * bits=3 61.3% 59.3% - * The lack of speed improvment is also a function of the pre-calculation + * The lack of speed improvement is also a function of the pre-calculation * which could be removed. */ #define EXP2_TABLE_BITS 2 /* 1 2 3 4 5 */ @@ -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++) |