From b64270d1e45fe7f3241e4c9b6ce60d5ac89bc2e9 Mon Sep 17 00:00:00 2001 From: beck <> Date: Wed, 15 May 2002 02:29:21 +0000 Subject: OpenSSL 0.9.7 stable 2002 05 08 merge --- src/lib/libcrypto/bn/bn_ctx.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/bn/bn_ctx.c') diff --git a/src/lib/libcrypto/bn/bn_ctx.c b/src/lib/libcrypto/bn/bn_ctx.c index b1a8d7571e..7daf19eb84 100644 --- a/src/lib/libcrypto/bn/bn_ctx.c +++ b/src/lib/libcrypto/bn/bn_ctx.c @@ -61,8 +61,9 @@ #include #include + #include "cryptlib.h" -#include +#include "bn_lcl.h" BN_CTX *BN_CTX_new(void) @@ -83,6 +84,7 @@ BN_CTX *BN_CTX_new(void) void BN_CTX_init(BN_CTX *ctx) { +#if 0 /* explicit version */ int i; ctx->tos = 0; ctx->flags = 0; @@ -90,6 +92,9 @@ void BN_CTX_init(BN_CTX *ctx) ctx->too_many = 0; for (i = 0; i < BN_CTX_NUM; i++) BN_init(&(ctx->bn[i])); +#else + memset(ctx, 0, sizeof *ctx); +#endif } void BN_CTX_free(BN_CTX *ctx) @@ -112,8 +117,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) -- cgit v1.2.3-55-g6feb