projects
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Leave the decision to call/implement bn_sqr_mont to assembler developer.
[openssl.git]
/
crypto
/
bn
/
bn_ctx.c
diff --git
a/crypto/bn/bn_ctx.c
b/crypto/bn/bn_ctx.c
index 5aec0c987ee97729a813f21bba6150e0a3c16d37..b3452f1a91e31081e18667e25c49790b5b5a876a 100644
(file)
--- a/
crypto/bn/bn_ctx.c
+++ b/
crypto/bn/bn_ctx.c
@@
-70,10
+70,7
@@
*
* 1. Check a bunch of "(words+1)" type hacks in various bignum functions and
* check they can be safely removed.
*
* 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()
* - 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
*
* 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
@@
-161,33
+158,33
@@
static void ctxdbg(BN_CTX *ctx)
unsigned int bnidx = 0, fpidx = 0;
BN_POOL_ITEM *item = ctx->pool.head;
BN_STACK *stack = &ctx->stack;
unsigned int bnidx = 0, fpidx = 0;
BN_POOL_ITEM *item = ctx->pool.head;
BN_STACK *stack = &ctx->stack;
-
printf(
"(%08x): ", (unsigned int)ctx);
+
fprintf(stderr,
"(%08x): ", (unsigned int)ctx);
while(bnidx < ctx->used)
{
while(bnidx < ctx->used)
{
-
printf(
"%02x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
+
fprintf(stderr,
"%02x ", item->vals[bnidx++ % BN_CTX_POOL_SIZE].dmax);
if(!(bnidx % BN_CTX_POOL_SIZE))
item = item->next;
}
if(!(bnidx % BN_CTX_POOL_SIZE))
item = item->next;
}
-
printf(
"\n");
+
fprintf(stderr,
"\n");
bnidx = 0;
bnidx = 0;
-
printf(
" : ");
+
fprintf(stderr,
" : ");
while(fpidx < stack->depth)
{
while(bnidx++ < stack->indexes[fpidx])
while(fpidx < stack->depth)
{
while(bnidx++ < stack->indexes[fpidx])
-
printf(
" ");
-
printf(
"^^ ");
+
fprintf(stderr,
" ");
+
fprintf(stderr,
"^^ ");
bnidx++;
fpidx++;
}
bnidx++;
fpidx++;
}
-
printf(
"\n");
+
fprintf(stderr,
"\n");
}
#define CTXDBG_ENTRY(str, ctx) do { \
ctxdbg_cur = (str); \
}
#define CTXDBG_ENTRY(str, ctx) do { \
ctxdbg_cur = (str); \
-
printf(
"Starting %s\n", ctxdbg_cur); \
+
fprintf(stderr,
"Starting %s\n", ctxdbg_cur); \
ctxdbg(ctx); \
} while(0)
#define CTXDBG_EXIT(ctx) do { \
ctxdbg(ctx); \
} while(0)
#define CTXDBG_EXIT(ctx) do { \
-
printf(
"Ending %s\n", ctxdbg_cur); \
+
fprintf(stderr,
"Ending %s\n", ctxdbg_cur); \
ctxdbg(ctx); \
} while(0)
#define CTXDBG_RET(ctx,ret)
ctxdbg(ctx); \
} while(0)
#define CTXDBG_RET(ctx,ret)
@@
-233,18
+230,22
@@
BN_CTX *BN_CTX_new(void)
void BN_CTX_free(BN_CTX *ctx)
{
void BN_CTX_free(BN_CTX *ctx)
{
+ if (ctx == NULL)
+ return;
#ifdef BN_CTX_DEBUG
#ifdef BN_CTX_DEBUG
+ {
BN_POOL_ITEM *pool = ctx->pool.head;
BN_POOL_ITEM *pool = ctx->pool.head;
-
printf(
"BN_CTX_free, stack-size=%d, pool-bignums=%d\n",
+
fprintf(stderr,
"BN_CTX_free, stack-size=%d, pool-bignums=%d\n",
ctx->stack.size, ctx->pool.size);
ctx->stack.size, ctx->pool.size);
-
printf(
"dmaxs: ");
+
fprintf(stderr,
"dmaxs: ");
while(pool) {
unsigned loop = 0;
while(loop < BN_CTX_POOL_SIZE)
while(pool) {
unsigned loop = 0;
while(loop < BN_CTX_POOL_SIZE)
-
printf(
"%02x ", pool->vals[loop++].dmax);
+
fprintf(stderr,
"%02x ", pool->vals[loop++].dmax);
pool = pool->next;
}
pool = pool->next;
}
- printf("\n");
+ fprintf(stderr,"\n");
+ }
#endif
BN_STACK_finish(&ctx->stack);
BN_POOL_finish(&ctx->pool);
#endif
BN_STACK_finish(&ctx->stack);
BN_POOL_finish(&ctx->pool);
@@
-260,8
+261,7
@@
void BN_CTX_start(BN_CTX *ctx)
/* (Try to) get a new frame pointer */
else if(!BN_STACK_push(&ctx->stack, ctx->used))
{
/* (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);
ctx->err_stack++;
}
CTXDBG_EXIT(ctx);