BN_CTX is opaque and the static initialiser BN_CTX_init() is not used
[openssl.git] / crypto / bn / bn_ctx.c
index 7daf19eb8436cf42bfec2aaba2a1866353b642b0..34cc75cfa93524500a5145676b2c5c344d9216fa 100644 (file)
  *
  */
 
-#ifndef BN_CTX_DEBUG
-# undef NDEBUG /* avoid conflicting definitions */
-# define NDEBUG
+#if !defined(BN_CTX_DEBUG) && !defined(BN_DEBUG)
+#ifndef NDEBUG
+#define NDEBUG
+#endif
 #endif
 
 #include <stdio.h>
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
+/* BN_CTX structure details */
+#define BN_CTX_NUM     32
+#define BN_CTX_NUM_POS 12
+struct bignum_ctx
+       {
+       int tos;
+       BIGNUM bn[BN_CTX_NUM];
+       int flags;
+       int depth;
+       int pos[BN_CTX_NUM_POS];
+       int too_many;
+       };
+
+#ifndef OPENSSL_NO_DEPRECATED
+void BN_CTX_init(BN_CTX *ctx)
+#else
+static void BN_CTX_init(BN_CTX *ctx)
+#endif
+       {
+#if 0 /* explicit version */
+       int i;
+       ctx->tos = 0;
+       ctx->flags = 0;
+       ctx->depth = 0;
+       ctx->too_many = 0;
+       for (i = 0; i < BN_CTX_NUM; i++)
+               BN_init(&(ctx->bn[i]));
+#else
+       memset(ctx, 0, sizeof *ctx);
+#endif
+       }
 
 BN_CTX *BN_CTX_new(void)
        {
@@ -82,21 +114,6 @@ BN_CTX *BN_CTX_new(void)
        return(ret);
        }
 
-void BN_CTX_init(BN_CTX *ctx)
-       {
-#if 0 /* explicit version */
-       int i;
-       ctx->tos = 0;
-       ctx->flags = 0;
-       ctx->depth = 0;
-       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)
        {
        int i;