engines/e_atalla.c:557: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul`.
Showing all 17 steps of the trace


engines/e_atalla.c:555:7: Call
553.   	if (!atalla_mod_exp(rr,a1,p1,m,ctx)) goto end;
554.   	/* let t = a2 ^ p2 mod m */
555.   	if (!atalla_mod_exp(&t,a2,p2,m,ctx)) goto end;
             ^
556.   	/* let rr = rr * t mod m */
557.   	if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;

engines/e_atalla.c:511:2: Call
  509.   	to_return = 1;
  510.   err:
  511.   	BN_CTX_end(ctx);
          ^
  512.   	return to_return;
  513.   	}

crypto/bn/bn_ctx.c:270:1: Parameter `ctx->pool.used`
    268.   	}
    269.   
    270. > void BN_CTX_end(BN_CTX *ctx)
    271.   	{
    272.   	CTXDBG_ENTRY("BN_CTX_end", ctx);

engines/e_atalla.c:557:7: Call
555.   	if (!atalla_mod_exp(&t,a2,p2,m,ctx)) goto end;
556.   	/* let rr = rr * t mod m */
557.   	if (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;
             ^
558.   	to_return = 1;
559.   end:

crypto/bn/bn_mod.c:178:1: Parameter `ctx->pool.used`
  176.   
  177.   /* slow but works */
  178. > int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,
  179.   	BN_CTX *ctx)
  180.   	{

crypto/bn/bn_mod.c:189:11: Call
  187.   
  188.   	BN_CTX_start(ctx);
  189.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
                   ^
  190.   	if (a == b)
  191.   		{ if (!BN_sqr(t,a,ctx)) goto err; }

crypto/bn/bn_ctx.c:288:1: Parameter `ctx->pool.used`
    286.   	}
    287.   
    288. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
    289.   	{
    290.   	BIGNUM *ret;

crypto/bn/bn_mod.c:191:10: Call
  189.   	if ((t = BN_CTX_get(ctx)) == NULL) goto err;
  190.   	if (a == b)
  191.   		{ if (!BN_sqr(t,a,ctx)) goto err; }
                  ^
  192.   	else
  193.   		{ if (!BN_mul(t,a,b,ctx)) goto err; }

crypto/bn/bn_sqr.c:65:1: Parameter `ctx->pool.used`
    63.   /* r must not be a */
    64.   /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */
    65. > int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
    66.   	{
    67.   	int max,al;

crypto/bn/bn_sqr.c:85:6: Call
    83.   	BN_CTX_start(ctx);
    84.   	rr=(a != r) ? r : BN_CTX_get(ctx);
    85.   	tmp=BN_CTX_get(ctx);
               ^
    86.   	if (!rr || !tmp) goto err;
    87.   

crypto/bn/bn_ctx.c:288:1: Parameter `ctx->pool.used`
      286.   	}
      287.   
      288. > BIGNUM *BN_CTX_get(BN_CTX *ctx)
      289.   	{
      290.   	BIGNUM *ret;

crypto/bn/bn_sqr.c:153:2: Call
    151.   	bn_check_top(rr);
    152.   	bn_check_top(tmp);
    153.   	BN_CTX_end(ctx);
            ^
    154.   	return(ret);
    155.   	}

crypto/bn/bn_ctx.c:270:1: Parameter `ctx->pool.used`
      268.   	}
      269.   
      270. > void BN_CTX_end(BN_CTX *ctx)
      271.   	{
      272.   	CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:280:4: Call
      278.   		/* Does this stack frame have anything to release? */
      279.   		if(fp < ctx->used)
      280.   			BN_POOL_release(&ctx->pool, ctx->used - fp);
                ^
      281.   		ctx->used = fp;
      282.   		/* Unjam "too_many" in case "get" had failed */

crypto/bn/bn_ctx.c:438:1: <LHS trace>
436.   	}
437.   
438. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
439.   	{
440.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:438:1: Parameter `p->used`
        436.   	}
        437.   
        438. > static void BN_POOL_release(BN_POOL *p, unsigned int num)
        439.   	{
        440.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;

crypto/bn/bn_ctx.c:440:2: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_mod_mul` 
        438.   static void BN_POOL_release(BN_POOL *p, unsigned int num)
        439.   	{
        440.   	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
                ^
        441.   	p->used -= num;
        442.   	while(num--)

static void BN_POOL_release(BN_POOL *p, unsigned int num)
	{
	unsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;
	p->used -= num;
	while(num--)
		{
		bn_check_top(p->current->vals + offset);
		if(!offset)
			{
			offset = BN_CTX_POOL_SIZE - 1;
			p->current = p->current->prev;
			}
		else
			offset--;
		}
	}
['static int atalla_dsa_mod_exp(DSA *dsa, BIGNUM *rr, BIGNUM *a1,\n\t\tBIGNUM *p1, BIGNUM *a2, BIGNUM *p2, BIGNUM *m,\n\t\tBN_CTX *ctx, BN_MONT_CTX *in_mont)\n\t{\n\tBIGNUM t;\n\tint to_return = 0;\n\tBN_init(&t);\n\tif (!atalla_mod_exp(rr,a1,p1,m,ctx)) goto end;\n\tif (!atalla_mod_exp(&t,a2,p2,m,ctx)) goto end;\n\tif (!BN_mod_mul(rr,rr,&t,m,ctx)) goto end;\n\tto_return = 1;\nend:\n\tBN_free(&t);\n\treturn to_return;\n\t}', 'static int atalla_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,\n\t\t\tconst BIGNUM *m, BN_CTX *ctx)\n\t{\n\tBIGNUM *modulus;\n\tBIGNUM *exponent;\n\tBIGNUM *argument;\n\tBIGNUM *result;\n\tRSAPrivateKey keydata;\n\tint to_return, numbytes;\n\tmodulus = exponent = argument = result = NULL;\n\tto_return = 0;\n\tif(!atalla_dso)\n\t\t{\n\t\tATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_NOT_LOADED);\n\t\tgoto err;\n\t\t}\n\tBN_CTX_start(ctx);\n\tmodulus = BN_CTX_get(ctx);\n\texponent = BN_CTX_get(ctx);\n\targument = BN_CTX_get(ctx);\n\tresult = BN_CTX_get(ctx);\n\tif (!result)\n\t\t{\n\t\tATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_CTX_FULL);\n\t\tgoto err;\n\t\t}\n\tif(!bn_wexpand(modulus, m->top) || !bn_wexpand(exponent, m->top) ||\n\t   !bn_wexpand(argument, m->top) || !bn_wexpand(result, m->top))\n\t\t{\n\t\tATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_BN_EXPAND_FAIL);\n\t\tgoto err;\n\t\t}\n\tmemset(&keydata, 0,sizeof keydata);\n\tnumbytes = BN_num_bytes(m);\n\tmemset(exponent->d, 0, numbytes);\n\tmemset(modulus->d, 0, numbytes);\n\tBN_bn2bin(p, (unsigned char *)exponent->d + numbytes - BN_num_bytes(p));\n\tBN_bn2bin(m, (unsigned char *)modulus->d + numbytes - BN_num_bytes(m));\n\tkeydata.privateExponent.data = (unsigned char *)exponent->d;\n\tkeydata.privateExponent.len = numbytes;\n\tkeydata.modulus.data = (unsigned char *)modulus->d;\n\tkeydata.modulus.len = numbytes;\n\tmemset(argument->d, 0, numbytes);\n\tmemset(result->d, 0, numbytes);\n\tBN_bn2bin(a, (unsigned char *)argument->d + numbytes - BN_num_bytes(a));\n\tif(p_Atalla_RSAPrivateKeyOpFn(&keydata, (unsigned char *)result->d,\n\t\t\t(unsigned char *)argument->d,\n\t\t\tkeydata.modulus.len) != 0)\n\t\t{\n\t\tATALLAerr(ATALLA_F_ATALLA_MOD_EXP,ATALLA_R_REQUEST_FAILED);\n\t\tgoto err;\n\t\t}\n\tBN_bin2bn((unsigned char *)result->d, numbytes, r);\n\tto_return = 1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn to_return;\n\t}', 'void BN_CTX_end(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_end", ctx);\n\tif(ctx->err_stack)\n\t\tctx->err_stack--;\n\telse\n\t\t{\n\t\tunsigned int fp = BN_STACK_pop(&ctx->stack);\n\t\tif(fp < ctx->used)\n\t\t\tBN_POOL_release(&ctx->pool, ctx->used - fp);\n\t\tctx->used = fp;\n\t\tctx->too_many = 0;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}', 'int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m,\n\tBN_CTX *ctx)\n\t{\n\tBIGNUM *t;\n\tint ret=0;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(m);\n\tBN_CTX_start(ctx);\n\tif ((t = BN_CTX_get(ctx)) == NULL) goto err;\n\tif (a == b)\n\t\t{ if (!BN_sqr(t,a,ctx)) goto err; }\n\telse\n\t\t{ if (!BN_mul(t,a,b,ctx)) goto err; }\n\tif (!BN_nnmod(r,t,m,ctx)) goto err;\n\tbn_check_top(r);\n\tret=1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn(ret);\n\t}', 'BIGNUM *BN_CTX_get(BN_CTX *ctx)\n\t{\n\tBIGNUM *ret;\n\tCTXDBG_ENTRY("BN_CTX_get", ctx);\n\tif(ctx->err_stack || ctx->too_many) return NULL;\n\tif((ret = BN_POOL_get(&ctx->pool)) == NULL)\n\t\t{\n\t\tctx->too_many = 1;\n\t\tBNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\treturn NULL;\n\t\t}\n\tBN_zero(ret);\n\tctx->used++;\n\tCTXDBG_RET(ctx, ret);\n\treturn ret;\n\t}', 'int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)\n\t{\n\tint max,al;\n\tint ret = 0;\n\tBIGNUM *tmp,*rr;\n#ifdef BN_COUNT\n\tfprintf(stderr,"BN_sqr %d * %d\\n",a->top,a->top);\n#endif\n\tbn_check_top(a);\n\tal=a->top;\n\tif (al <= 0)\n\t\t{\n\t\tr->top=0;\n\t\treturn 1;\n\t\t}\n\tBN_CTX_start(ctx);\n\trr=(a != r) ? r : BN_CTX_get(ctx);\n\ttmp=BN_CTX_get(ctx);\n\tif (!rr || !tmp) goto err;\n\tmax = 2 * al;\n\tif (bn_wexpand(rr,max) == NULL) goto err;\n\tif (al == 4)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[8];\n\t\tbn_sqr_normal(rr->d,a->d,4,t);\n#else\n\t\tbn_sqr_comba4(rr->d,a->d);\n#endif\n\t\t}\n\telse if (al == 8)\n\t\t{\n#ifndef BN_SQR_COMBA\n\t\tBN_ULONG t[16];\n\t\tbn_sqr_normal(rr->d,a->d,8,t);\n#else\n\t\tbn_sqr_comba8(rr->d,a->d);\n#endif\n\t\t}\n\telse\n\t\t{\n#if defined(BN_RECURSION)\n\t\tif (al < BN_SQR_RECURSIVE_SIZE_NORMAL)\n\t\t\t{\n\t\t\tBN_ULONG t[BN_SQR_RECURSIVE_SIZE_NORMAL*2];\n\t\t\tbn_sqr_normal(rr->d,a->d,al,t);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tint j,k;\n\t\t\tj=BN_num_bits_word((BN_ULONG)al);\n\t\t\tj=1<<(j-1);\n\t\t\tk=j+j;\n\t\t\tif (al == j)\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,k*2) == NULL) goto err;\n\t\t\t\tbn_sqr_recursive(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\t\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n\t\t\t\t}\n\t\t\t}\n#else\n\t\tif (bn_wexpand(tmp,max) == NULL) goto err;\n\t\tbn_sqr_normal(rr->d,a->d,al,tmp->d);\n#endif\n\t\t}\n\trr->neg=0;\n\tif(a->d[al - 1] == (a->d[al - 1] & BN_MASK2l))\n\t\trr->top = max - 1;\n\telse\n\t\trr->top = max;\n\tif (rr != r) BN_copy(r,rr);\n\tret = 1;\n err:\n\tbn_check_top(rr);\n\tbn_check_top(tmp);\n\tBN_CTX_end(ctx);\n\treturn(ret);\n\t}', 'static void BN_POOL_release(BN_POOL *p, unsigned int num)\n\t{\n\tunsigned int offset = (p->used - 1) % BN_CTX_POOL_SIZE;\n\tp->used -= num;\n\twhile(num--)\n\t\t{\n\t\tbn_check_top(p->current->vals + offset);\n\t\tif(!offset)\n\t\t\t{\n\t\t\toffset = BN_CTX_POOL_SIZE - 1;\n\t\t\tp->current = p->current->prev;\n\t\t\t}\n\t\telse\n\t\t\toffset--;\n\t\t}\n\t}']