Version skew reduction: trivia (I hope).
[openssl.git] / crypto / bn / bn_ctx.c
index 12d8a8cbf87f54371285bd2de3e72a34af3b7bd7..0272dbb62b0dd0e78d3b1902cc200625dc39a360 100644 (file)
@@ -60,6 +60,8 @@
 #endif
 #endif
 
+#define OPENSSL_FIPSAPI
+
 #include <stdio.h>
 #include <assert.h>
 
  *
  * 1. Check a bunch of "(words+1)" type hacks in various bignum functions and
  * check they can be safely removed.
- *  - BN_bin2bn() looks pretty nasty with the miscellaneous +1 and +2 adjustments.
- *    Needs a full rubber-gloving, me thinks.
  *  - Check +1 and other ugliness in BN_from_montgomery()
- *  - Aspects of BN_bn2dec() also look a bit arbitrary
  *
  * 2. Consider allowing a BN_new_ex() that, at least, lets you specify an
  * appropriate 'block' size that will be honoured by bn_expand_internal() to
@@ -164,7 +163,7 @@ static void ctxdbg(BN_CTX *ctx)
        fprintf(stderr,"(%08x): ", (unsigned int)ctx);
        while(bnidx < ctx->used)
                {
-               fprintf(stderr,"%02x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
+               fprintf(stderr,"%03x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
                if(!(bnidx % BN_CTX_POOL_SIZE))
                        item = item->next;
                }
@@ -174,8 +173,8 @@ static void ctxdbg(BN_CTX *ctx)
        while(fpidx < stack->depth)
                {
                while(bnidx++ < stack->indexes[fpidx])
-                       fprintf(stderr,"   ");
-               fprintf(stderr,"^^ ");
+                       fprintf(stderr,"    ");
+               fprintf(stderr,"^^^ ");
                bnidx++;
                fpidx++;
                }
@@ -233,7 +232,10 @@ BN_CTX *BN_CTX_new(void)
 
 void BN_CTX_free(BN_CTX *ctx)
        {
+       if (ctx == NULL)
+               return;
 #ifdef BN_CTX_DEBUG
+       {
        BN_POOL_ITEM *pool = ctx->pool.head;
        fprintf(stderr,"BN_CTX_free, stack-size=%d, pool-bignums=%d\n",
                ctx->stack.size, ctx->pool.size);
@@ -245,6 +247,7 @@ void BN_CTX_free(BN_CTX *ctx)
                pool = pool->next;
        }
        fprintf(stderr,"\n");
+       }
 #endif
        BN_STACK_finish(&ctx->stack);
        BN_POOL_finish(&ctx->pool);
@@ -260,8 +263,7 @@ void BN_CTX_start(BN_CTX *ctx)
        /* (Try to) get a new frame pointer */
        else if(!BN_STACK_push(&ctx->stack, ctx->used))
                {
-               /* I know this isn't BN_CTX_get, but ... */
-               BNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);
+               BNerr(BN_F_BN_CTX_START,BN_R_TOO_MANY_TEMPORARY_VARIABLES);
                ctx->err_stack++;
                }
        CTXDBG_EXIT(ctx);