summaryrefslogtreecommitdiff
path: root/lib/libcrypto/bn/bn_ctx.c
diff options
context:
space:
mode:
authorBob Beck <beck@cvs.openbsd.org>2002-05-15 02:29:22 +0000
committerBob Beck <beck@cvs.openbsd.org>2002-05-15 02:29:22 +0000
commit4df88d25cb3419048d1bcf9740d37d4c459aef22 (patch)
tree97858aa44644bc9b64d1775a8bbccfb5baca24d3 /lib/libcrypto/bn/bn_ctx.c
parent998d0d156e423800e9a2fa1a482c0726f14201c2 (diff)
OpenSSL 0.9.7 stable 2002 05 08 merge
Diffstat (limited to 'lib/libcrypto/bn/bn_ctx.c')
-rw-r--r--lib/libcrypto/bn/bn_ctx.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/libcrypto/bn/bn_ctx.c b/lib/libcrypto/bn/bn_ctx.c
index b1a8d7571e8..7daf19eb843 100644
--- a/lib/libcrypto/bn/bn_ctx.c
+++ b/lib/libcrypto/bn/bn_ctx.c
@@ -61,8 +61,9 @@
#include <stdio.h>
#include <assert.h>
+
#include "cryptlib.h"
-#include <openssl/bn.h>
+#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)