diff options
author | Bodo Möller <bodo@openssl.org> | 2000-11-08 10:05:34 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2000-11-08 10:05:34 +0000 |
commit | 7f7b8d687173bd65ba2acea130ea25bd809e41b6 (patch) | |
tree | 3fe79e869d224338a2dc7e12241bf7694d686f35 /crypto | |
parent | bb7e632aef4ca511feb9f3dae29cccbab984c057 (diff) |
BN_CTX-related fixes.
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/bn/bn.h | 2 | ||||
-rw-r--r-- | crypto/bn/bn_ctx.c | 6 | ||||
-rw-r--r-- | crypto/bn/bn_div.c | 4 |
3 files changed, 9 insertions, 3 deletions
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h index dad488fafb..b6e8b7c9a4 100644 --- a/crypto/bn/bn.h +++ b/crypto/bn/bn.h @@ -239,7 +239,7 @@ typedef struct bignum_st } BIGNUM; /* Used for temp variables */ -#define BN_CTX_NUM 12 +#define BN_CTX_NUM 16 #define BN_CTX_NUM_POS 12 typedef struct bignum_ctx { diff --git a/crypto/bn/bn_ctx.c b/crypto/bn/bn_ctx.c index b1a8d7571e..28b334fbd5 100644 --- a/crypto/bn/bn_ctx.c +++ b/crypto/bn/bn_ctx.c @@ -112,8 +112,14 @@ void BN_CTX_start(BN_CTX *ctx) ctx->depth++; } + BIGNUM *BN_CTX_get(BN_CTX *ctx) { + /* Note: If BN_CTX_get is ever changed to allocate BIGNUMs dynamically, + * make sure that if BN_CTX_get fails once it will return NULL again + * until BN_CTX_end is called. (This is so that callers have to check + * only the last return value.) + */ if (ctx->depth > BN_CTX_NUM_POS || ctx->tos >= BN_CTX_NUM) { if (!ctx->too_many) diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index c3772c243b..999bba756c 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -180,13 +180,13 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, BN_CTX_start(ctx); tmp=BN_CTX_get(ctx); - tmp->neg=0; snum=BN_CTX_get(ctx); sdiv=BN_CTX_get(ctx); if (dv == NULL) res=BN_CTX_get(ctx); else res=dv; - if (res == NULL) goto err; + if (sdiv == NULL || res == NULL) goto err; + tmp->neg=0; /* First we normalise the numbers */ norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2); |