crypto/dsa/dsa_gen.c:240: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_div`.
Showing all 14 steps of the trace


crypto/dsa/dsa_gen.c:132:2: Call
130.   	if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
131.   
132.   	BN_CTX_start(ctx);
        ^
133.   	r0 = BN_CTX_get(ctx);
134.   	g = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:251:1: Parameter `ctx->stack.depth`
  249.   	}
  250.   
  251. > void BN_CTX_start(BN_CTX *ctx)
  252.   	{
  253.   	CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/dsa/dsa_gen.c:186:8: Call
184.   
185.   			/* step 4 */
186.   			r = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx,
              ^
187.   					seed_is_random, cb);
188.   			if (r > 0)

crypto/bn/bn_prime.c:243:1: Parameter `ctx_passed->stack.depth`
  241.   	}
  242.   
  243. > int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
  244.   		int do_trial_division, BN_GENCB *cb)
  245.   	{

crypto/dsa/dsa_gen.c:240:9: Call
238.   			/* step 9 */
239.   			if (!BN_lshift1(r0,q)) goto err;
240.   			if (!BN_mod(c,X,r0,ctx)) goto err;
               ^
241.   			if (!BN_sub(r0,c,BN_value_one())) goto err;
242.   			if (!BN_sub(p,X,r0)) goto err;

crypto/bn/bn_div.c:179:1: Parameter `ctx->stack.depth`
  177.    * If 'dv' or 'rm' is NULL, the respective value is not returned.
  178.    */
  179. > int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
  180.   	   BN_CTX *ctx)
  181.   	{

crypto/bn/bn_div.c:209:2: Call
  207.   		}
  208.   
  209.   	BN_CTX_start(ctx);
          ^
  210.   	tmp=BN_CTX_get(ctx);
  211.   	snum=BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:251:1: Parameter `ctx->stack.depth`
    249.   	}
    250.   
    251. > void BN_CTX_start(BN_CTX *ctx)
    252.   	{
    253.   	CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_div.c:394:2: Call
  392.   		bn_check_top(rm);
  393.   		}
  394.   	BN_CTX_end(ctx);
          ^
  395.   	return(1);
  396.   err:

crypto/bn/bn_ctx.c:267:1: Parameter `ctx->stack.depth`
    265.   	}
    266.   
    267. > void BN_CTX_end(BN_CTX *ctx)
    268.   	{
    269.   	CTXDBG_ENTRY("BN_CTX_end", ctx);

crypto/bn/bn_ctx.c:274:21: Call
    272.   	else
    273.   		{
    274.   		unsigned int fp = BN_STACK_pop(&ctx->stack);
                               ^
    275.   		/* Does this stack frame have anything to release? */
    276.   		if(fp < ctx->used)

crypto/bn/bn_ctx.c:348:1: <LHS trace>
346.   	}
347.   
348. > static unsigned int BN_STACK_pop(BN_STACK *st)
349.   	{
350.   	return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:348:1: Parameter `st->depth`
      346.   	}
      347.   
      348. > static unsigned int BN_STACK_pop(BN_STACK *st)
      349.   	{
      350.   	return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:350:9: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_div` 
      348.   static unsigned int BN_STACK_pop(BN_STACK *st)
      349.   	{
      350.   	return st->indexes[--(st->depth)];
                     ^
      351.   	}
      352.   

static unsigned int BN_STACK_pop(BN_STACK *st)
	{
	return st->indexes[--(st->depth)];
	}
['static int dsa_builtin_paramgen(DSA *ret, int bits,\n\t\tunsigned char *seed_in, int seed_len,\n\t\tint *counter_ret, unsigned long *h_ret, BN_GENCB *cb)\n\t{\n\tint ok=0;\n\tunsigned char seed[SHA_DIGEST_LENGTH];\n\tunsigned char md[SHA_DIGEST_LENGTH];\n\tunsigned char buf[SHA_DIGEST_LENGTH],buf2[SHA_DIGEST_LENGTH];\n\tBIGNUM *r0,*W,*X,*c,*test;\n\tBIGNUM *g=NULL,*q=NULL,*p=NULL;\n\tBN_MONT_CTX *mont=NULL;\n\tint k,n=0,i,b,m=0;\n\tint counter=0;\n\tint r=0;\n\tBN_CTX *ctx=NULL;\n\tunsigned int h=2;\n\tif (bits < 512) bits=512;\n\tbits=(bits+63)/64*64;\n\tif (seed_len < 20)\n\t\tseed_in = NULL;\n\tif (seed_len > 20)\n\t\tseed_len = 20;\n\tif ((seed_in != NULL) && (seed_len == 20))\n\t\tmemcpy(seed,seed_in,seed_len);\n\tif ((ctx=BN_CTX_new()) == NULL) goto err;\n\tif ((mont=BN_MONT_CTX_new()) == NULL) goto err;\n\tBN_CTX_start(ctx);\n\tr0 = BN_CTX_get(ctx);\n\tg = BN_CTX_get(ctx);\n\tW = BN_CTX_get(ctx);\n\tq = BN_CTX_get(ctx);\n\tX = BN_CTX_get(ctx);\n\tc = BN_CTX_get(ctx);\n\tp = BN_CTX_get(ctx);\n\ttest = BN_CTX_get(ctx);\n\tif (!BN_lshift(test,BN_value_one(),bits-1))\n\t\tgoto err;\n\tfor (;;)\n\t\t{\n\t\tfor (;;)\n\t\t\t{\n\t\t\tint seed_is_random;\n\t\t\tif(!BN_GENCB_call(cb, 0, m++))\n\t\t\t\tgoto err;\n\t\t\tif (!seed_len)\n\t\t\t\t{\n\t\t\t\tRAND_pseudo_bytes(seed,SHA_DIGEST_LENGTH);\n\t\t\t\tseed_is_random = 1;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tseed_is_random = 0;\n\t\t\t\tseed_len=0;\n\t\t\t\t}\n\t\t\tmemcpy(buf,seed,SHA_DIGEST_LENGTH);\n\t\t\tmemcpy(buf2,seed,SHA_DIGEST_LENGTH);\n\t\t\tfor (i=SHA_DIGEST_LENGTH-1; i >= 0; i--)\n\t\t\t\t{\n\t\t\t\tbuf[i]++;\n\t\t\t\tif (buf[i] != 0) break;\n\t\t\t\t}\n\t\t\tEVP_Digest(seed,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL);\n\t\t\tEVP_Digest(buf,SHA_DIGEST_LENGTH,buf2,NULL,HASH, NULL);\n\t\t\tfor (i=0; i<SHA_DIGEST_LENGTH; i++)\n\t\t\t\tmd[i]^=buf2[i];\n\t\t\tmd[0]|=0x80;\n\t\t\tmd[SHA_DIGEST_LENGTH-1]|=0x01;\n\t\t\tif (!BN_bin2bn(md,SHA_DIGEST_LENGTH,q)) goto err;\n\t\t\tr = BN_is_prime_fasttest_ex(q, DSS_prime_checks, ctx,\n\t\t\t\t\tseed_is_random, cb);\n\t\t\tif (r > 0)\n\t\t\t\tbreak;\n\t\t\tif (r != 0)\n\t\t\t\tgoto err;\n\t\t\t}\n\t\tif(!BN_GENCB_call(cb, 2, 0)) goto err;\n\t\tif(!BN_GENCB_call(cb, 3, 0)) goto err;\n\t\tcounter=0;\n\t\tn=(bits-1)/160;\n\t\tb=(bits-1)-n*160;\n\t\tfor (;;)\n\t\t\t{\n\t\t\tif ((counter != 0) && !BN_GENCB_call(cb, 0, counter))\n\t\t\t\tgoto err;\n\t\t\tif (!BN_zero(W)) goto err;\n\t\t\tfor (k=0; k<=n; k++)\n\t\t\t\t{\n\t\t\t\tfor (i=SHA_DIGEST_LENGTH-1; i >= 0; i--)\n\t\t\t\t\t{\n\t\t\t\t\tbuf[i]++;\n\t\t\t\t\tif (buf[i] != 0) break;\n\t\t\t\t\t}\n\t\t\t\tEVP_Digest(buf,SHA_DIGEST_LENGTH,md,NULL,HASH, NULL);\n\t\t\t\tif (!BN_bin2bn(md,SHA_DIGEST_LENGTH,r0))\n\t\t\t\t\tgoto err;\n\t\t\t\tif (!BN_lshift(r0,r0,160*k)) goto err;\n\t\t\t\tif (!BN_add(W,W,r0)) goto err;\n\t\t\t\t}\n\t\t\tif (!BN_mask_bits(W,bits-1)) goto err;\n\t\t\tif (!BN_copy(X,W)) goto err;\n\t\t\tif (!BN_add(X,X,test)) goto err;\n\t\t\tif (!BN_lshift1(r0,q)) goto err;\n\t\t\tif (!BN_mod(c,X,r0,ctx)) goto err;\n\t\t\tif (!BN_sub(r0,c,BN_value_one())) goto err;\n\t\t\tif (!BN_sub(p,X,r0)) goto err;\n\t\t\tif (BN_cmp(p,test) >= 0)\n\t\t\t\t{\n\t\t\t\tr = BN_is_prime_fasttest_ex(p, DSS_prime_checks,\n\t\t\t\t\t\tctx, 1, cb);\n\t\t\t\tif (r > 0)\n\t\t\t\t\t\tgoto end;\n\t\t\t\tif (r != 0)\n\t\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tcounter++;\n\t\t\tif (counter >= 4096) break;\n\t\t\t}\n\t\t}\nend:\n\tif(!BN_GENCB_call(cb, 2, 1))\n\t\tgoto err;\n\tif (!BN_sub(test,p,BN_value_one())) goto err;\n\tif (!BN_div(r0,NULL,test,q,ctx)) goto err;\n\tif (!BN_set_word(test,h)) goto err;\n\tif (!BN_MONT_CTX_set(mont,p,ctx)) goto err;\n\tfor (;;)\n\t\t{\n\t\tif (!BN_mod_exp_mont(g,test,r0,p,ctx,mont)) goto err;\n\t\tif (!BN_is_one(g)) break;\n\t\tif (!BN_add(test,test,BN_value_one())) goto err;\n\t\th++;\n\t\t}\n\tif(!BN_GENCB_call(cb, 3, 1))\n\t\tgoto err;\n\tok=1;\nerr:\n\tif (ok)\n\t\t{\n\t\tif(ret->p) BN_free(ret->p);\n\t\tif(ret->q) BN_free(ret->q);\n\t\tif(ret->g) BN_free(ret->g);\n\t\tret->p=BN_dup(p);\n\t\tret->q=BN_dup(q);\n\t\tret->g=BN_dup(g);\n\t\tif (ret->p == NULL || ret->q == NULL || ret->g == NULL)\n\t\t\t{\n\t\t\tok=0;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif ((m > 1) && (seed_in != NULL)) memcpy(seed_in,seed,20);\n\t\tif (counter_ret != NULL) *counter_ret=counter;\n\t\tif (h_ret != NULL) *h_ret=h;\n\t\t}\n\tif(ctx)\n\t\t{\n\t\tBN_CTX_end(ctx);\n\t\tBN_CTX_free(ctx);\n\t\t}\n\tif (mont != NULL) BN_MONT_CTX_free(mont);\n\treturn ok;\n\t}', 'void BN_CTX_start(BN_CTX *ctx)\n\t{\n\tCTXDBG_ENTRY("BN_CTX_start", ctx);\n\tif(ctx->err_stack || ctx->too_many)\n\t\tctx->err_stack++;\n\telse if(!BN_STACK_push(&ctx->stack, ctx->used))\n\t\t{\n\t\tBNerr(BN_F_BN_CTX_GET,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\tctx->err_stack++;\n\t\t}\n\tCTXDBG_EXIT(ctx);\n\t}', 'int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,\n\t\tint do_trial_division, BN_GENCB *cb)\n\t{\n\tint i, j, ret = -1;\n\tint k;\n\tBN_CTX *ctx = NULL;\n\tBIGNUM *A1, *A1_odd, *check;\n\tBN_MONT_CTX *mont = NULL;\n\tconst BIGNUM *A = NULL;\n\tif (BN_cmp(a, BN_value_one()) <= 0)\n\t\treturn 0;\n\tif (checks == BN_prime_checks)\n\t\tchecks = BN_prime_checks_for_size(BN_num_bits(a));\n\tif (!BN_is_odd(a))\n\t\treturn 0;\n\tif (do_trial_division)\n\t\t{\n\t\tfor (i = 1; i < NUMPRIMES; i++)\n\t\t\tif (BN_mod_word(a, primes[i]) == 0)\n\t\t\t\treturn 0;\n\t\tif(!BN_GENCB_call(cb, 1, -1))\n\t\t\tgoto err;\n\t\t}\n\tif (ctx_passed != NULL)\n\t\tctx = ctx_passed;\n\telse\n\t\tif ((ctx=BN_CTX_new()) == NULL)\n\t\t\tgoto err;\n\tBN_CTX_start(ctx);\n\tif (a->neg)\n\t\t{\n\t\tBIGNUM *t;\n\t\tif ((t = BN_CTX_get(ctx)) == NULL) goto err;\n\t\tBN_copy(t, a);\n\t\tt->neg = 0;\n\t\tA = t;\n\t\t}\n\telse\n\t\tA = a;\n\tA1 = BN_CTX_get(ctx);\n\tA1_odd = BN_CTX_get(ctx);\n\tcheck = BN_CTX_get(ctx);\n\tif (check == NULL) goto err;\n\tif (!BN_copy(A1, A))\n\t\tgoto err;\n\tif (!BN_sub_word(A1, 1))\n\t\tgoto err;\n\tif (BN_is_zero(A1))\n\t\t{\n\t\tret = 0;\n\t\tgoto err;\n\t\t}\n\tk = 1;\n\twhile (!BN_is_bit_set(A1, k))\n\t\tk++;\n\tif (!BN_rshift(A1_odd, A1, k))\n\t\tgoto err;\n\tmont = BN_MONT_CTX_new();\n\tif (mont == NULL)\n\t\tgoto err;\n\tif (!BN_MONT_CTX_set(mont, A, ctx))\n\t\tgoto err;\n\tfor (i = 0; i < checks; i++)\n\t\t{\n\t\tif (!BN_pseudo_rand_range(check, A1))\n\t\t\tgoto err;\n\t\tif (!BN_add_word(check, 1))\n\t\t\tgoto err;\n\t\tj = witness(check, A, A1, A1_odd, k, ctx, mont);\n\t\tif (j == -1) goto err;\n\t\tif (j)\n\t\t\t{\n\t\t\tret=0;\n\t\t\tgoto err;\n\t\t\t}\n\t\tif(!BN_GENCB_call(cb, 1, i))\n\t\t\tgoto err;\n\t\t}\n\tret=1;\nerr:\n\tif (ctx != NULL)\n\t\t{\n\t\tBN_CTX_end(ctx);\n\t\tif (ctx_passed == NULL)\n\t\t\tBN_CTX_free(ctx);\n\t\t}\n\tif (mont != NULL)\n\t\tBN_MONT_CTX_free(mont);\n\treturn(ret);\n\t}', 'int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,\n\t   BN_CTX *ctx)\n\t{\n\tint norm_shift,i,loop;\n\tBIGNUM *tmp,wnum,*snum,*sdiv,*res;\n\tBN_ULONG *resp,*wnump;\n\tBN_ULONG d0,d1;\n\tint num_n,div_n;\n\tif (dv)\n\t\tbn_check_top(dv);\n\tif (rm)\n\t\tbn_check_top(rm);\n\tbn_check_top(num);\n\tbn_check_top(divisor);\n\tif (BN_is_zero(divisor))\n\t\t{\n\t\tBNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);\n\t\treturn(0);\n\t\t}\n\tif (BN_ucmp(num,divisor) < 0)\n\t\t{\n\t\tif (rm != NULL)\n\t\t\t{ if (BN_copy(rm,num) == NULL) return(0); }\n\t\tif (dv != NULL) BN_zero(dv);\n\t\treturn(1);\n\t\t}\n\tBN_CTX_start(ctx);\n\ttmp=BN_CTX_get(ctx);\n\tsnum=BN_CTX_get(ctx);\n\tsdiv=BN_CTX_get(ctx);\n\tif (dv == NULL)\n\t\tres=BN_CTX_get(ctx);\n\telse\tres=dv;\n\tif (sdiv == NULL || res == NULL) goto err;\n\tnorm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);\n\tif (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;\n\tsdiv->neg=0;\n\tnorm_shift+=BN_BITS2;\n\tif (!(BN_lshift(snum,num,norm_shift))) goto err;\n\tsnum->neg=0;\n\tdiv_n=sdiv->top;\n\tnum_n=snum->top;\n\tloop=num_n-div_n;\n\twnum.neg   = 0;\n\twnum.d     = &(snum->d[loop]);\n\twnum.top   = div_n;\n\twnum.dmax  = snum->dmax - loop;\n\td0=sdiv->d[div_n-1];\n\td1=(div_n == 1)?0:sdiv->d[div_n-2];\n\twnump= &(snum->d[num_n-1]);\n\tres->neg= (num->neg^divisor->neg);\n\tif (!bn_wexpand(res,(loop+1))) goto err;\n\tres->top=loop;\n\tresp= &(res->d[loop-1]);\n\tif (!bn_wexpand(tmp,(div_n+1))) goto err;\n\tif (BN_ucmp(&wnum,sdiv) >= 0)\n\t\t{\n\t\tbn_clear_top2max(&wnum);\n\t\tbn_sub_words(wnum.d, wnum.d, sdiv->d, div_n);\n\t\t*resp=1;\n\t\t}\n\telse\n\t\tres->top--;\n\tif (res->top == 0)\n\t\tres->neg = 0;\n\telse\n\t\tresp--;\n\tfor (i=0; i<loop-1; i++, wnump--, resp--)\n\t\t{\n\t\tBN_ULONG q,l0;\n#if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)\n\t\tBN_ULONG bn_div_3_words(BN_ULONG*,BN_ULONG,BN_ULONG);\n\t\tq=bn_div_3_words(wnump,d1,d0);\n#else\n\t\tBN_ULONG n0,n1,rem=0;\n\t\tn0=wnump[0];\n\t\tn1=wnump[-1];\n\t\tif (n0 == d0)\n\t\t\tq=BN_MASK2;\n\t\telse\n\t\t\t{\n#ifdef BN_LLONG\n\t\t\tBN_ULLONG t2;\n#if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)\n\t\t\tq=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);\n#else\n\t\t\tq=bn_div_words(n0,n1,d0);\n#ifdef BN_DEBUG_LEVITTE\n\t\t\tfprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\\\nX) -> 0x%08X\\n",\n\t\t\t\tn0, n1, d0, q);\n#endif\n#endif\n#ifndef REMAINDER_IS_ALREADY_CALCULATED\n\t\t\trem=(n1-q*d0)&BN_MASK2;\n#endif\n\t\t\tt2=(BN_ULLONG)d1*q;\n\t\t\tfor (;;)\n\t\t\t\t{\n\t\t\t\tif (t2 <= ((((BN_ULLONG)rem)<<BN_BITS2)|wnump[-2]))\n\t\t\t\t\tbreak;\n\t\t\t\tq--;\n\t\t\t\trem += d0;\n\t\t\t\tif (rem < d0) break;\n\t\t\t\tt2 -= d1;\n\t\t\t\t}\n#else\n\t\t\tBN_ULONG t2l,t2h,ql,qh;\n\t\t\tq=bn_div_words(n0,n1,d0);\n#ifdef BN_DEBUG_LEVITTE\n\t\t\tfprintf(stderr,"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\\\nX) -> 0x%08X\\n",\n\t\t\t\tn0, n1, d0, q);\n#endif\n#ifndef REMAINDER_IS_ALREADY_CALCULATED\n\t\t\trem=(n1-q*d0)&BN_MASK2;\n#endif\n#if defined(BN_UMULT_LOHI)\n\t\t\tBN_UMULT_LOHI(t2l,t2h,d1,q);\n#elif defined(BN_UMULT_HIGH)\n\t\t\tt2l = d1 * q;\n\t\t\tt2h = BN_UMULT_HIGH(d1,q);\n#else\n\t\t\tt2l=LBITS(d1); t2h=HBITS(d1);\n\t\t\tql =LBITS(q);  qh =HBITS(q);\n\t\t\tmul64(t2l,t2h,ql,qh);\n#endif\n\t\t\tfor (;;)\n\t\t\t\t{\n\t\t\t\tif ((t2h < rem) ||\n\t\t\t\t\t((t2h == rem) && (t2l <= wnump[-2])))\n\t\t\t\t\tbreak;\n\t\t\t\tq--;\n\t\t\t\trem += d0;\n\t\t\t\tif (rem < d0) break;\n\t\t\t\tif (t2l < d1) t2h--; t2l -= d1;\n\t\t\t\t}\n#endif\n\t\t\t}\n#endif\n\t\tl0=bn_mul_words(tmp->d,sdiv->d,div_n,q);\n\t\ttmp->d[div_n]=l0;\n\t\twnum.d--;\n\t\tif (bn_sub_words(wnum.d, wnum.d, tmp->d, div_n+1))\n\t\t\t{\n\t\t\tq--;\n\t\t\tif (bn_add_words(wnum.d, wnum.d, sdiv->d, div_n))\n\t\t\t\t(*wnump)++;\n\t\t\t}\n\t\t*resp = q;\n\t\t}\n\tbn_correct_top(snum);\n\tif (rm != NULL)\n\t\t{\n\t\tint neg = num->neg;\n\t\tBN_rshift(rm,snum,norm_shift);\n\t\tif (!BN_is_zero(rm))\n\t\t\trm->neg = neg;\n\t\tbn_check_top(rm);\n\t\t}\n\tBN_CTX_end(ctx);\n\treturn(1);\nerr:\n\tif (rm)\n\t\tbn_check_top(rm);\n\tBN_CTX_end(ctx);\n\treturn(0);\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}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n\t{\n\treturn st->indexes[--(st->depth)];\n\t}']