crypto/ec/ecp_smpl.c:616: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_mod_sqr`.
Showing all 19 steps of the trace


crypto/ec/ecp_smpl.c:603:8: Call
601.   	else
602.   		{
603.   		if (!BN_mod_inverse(Z_1, Z_, group->field, ctx))
              ^
604.   			{
605.   			ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_BN_LIB);

crypto/bn/bn_gcd.c:216:7: Call
  214.   	BIGNUM *rv;
  215.   	int noinv;
  216.   	rv = int_bn_mod_inverse(in, a, n, ctx, &noinv);
               ^
  217.   	if (noinv)
  218.   		BNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);

crypto/bn/bn_gcd.c:222:1: Parameter `ctx->stack.depth`
    220.   	}
    221.   
    222. > BIGNUM *int_bn_mod_inverse(BIGNUM *in,
    223.   	const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, int *pnoinv)
    224.   	{

crypto/bn/bn_gcd.c:240:2: Call
    238.   	bn_check_top(n);
    239.   
    240.   	BN_CTX_start(ctx);
            ^
    241.   	A = BN_CTX_get(ctx);
    242.   	B = BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:256:1: Parameter `ctx->stack.depth`
      254.   	}
      255.   
      256. > void BN_CTX_start(BN_CTX *ctx)
      257.   	{
      258.   	CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_gcd.c:515:2: Call
    513.   err:
    514.   	if ((ret == NULL) && (in == NULL)) BN_free(R);
    515.   	BN_CTX_end(ctx);
            ^
    516.   	bn_check_top(ret);
    517.   	return(ret);

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

crypto/ec/ecp_smpl.c:616:9: Call
614.   		else
615.   			{
616.   			if (!BN_mod_sqr(Z_2, Z_1, group->field, ctx)) goto err;
               ^
617.   			}
618.   	

crypto/bn/bn_mod.c:205:1: Parameter `ctx->stack.depth`
  203.   
  204.   
  205. > int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
  206.   	{
  207.   	if (!BN_sqr(r, a, ctx)) return 0;

crypto/bn/bn_mod.c:207:7: Call
  205.   int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)
  206.   	{
  207.   	if (!BN_sqr(r, a, ctx)) return 0;
               ^
  208.   	/* r->neg == 0,  thus we don't need BN_nnmod */
  209.   	return BN_mod(r, r, m, ctx);

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

crypto/bn/bn_sqr.c:80:2: Call
    78.   		}
    79.   
    80.   	BN_CTX_start(ctx);
           ^
    81.   	rr=(a != r) ? r : BN_CTX_get(ctx);
    82.   	tmp=BN_CTX_get(ctx);

crypto/bn/bn_ctx.c:256:1: Parameter `ctx->stack.depth`
      254.   	}
      255.   
      256. > void BN_CTX_start(BN_CTX *ctx)
      257.   	{
      258.   	CTXDBG_ENTRY("BN_CTX_start", ctx);

crypto/bn/bn_sqr.c:150:2: Call
    148.   	bn_check_top(rr);
    149.   	bn_check_top(tmp);
    150.   	BN_CTX_end(ctx);
            ^
    151.   	return(ret);
    152.   	}

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

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

crypto/bn/bn_ctx.c:352:1: <LHS trace>
350.   	}
351.   
352. > static unsigned int BN_STACK_pop(BN_STACK *st)
353.   	{
354.   	return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:352:1: Parameter `st->depth`
        350.   	}
        351.   
        352. > static unsigned int BN_STACK_pop(BN_STACK *st)
        353.   	{
        354.   	return st->indexes[--(st->depth)];

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

static unsigned int BN_STACK_pop(BN_STACK *st)
	{
	return st->indexes[--(st->depth)];
	}
['int ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT *point,\n\tBIGNUM *x, BIGNUM *y, BN_CTX *ctx)\n\t{\n\tBN_CTX *new_ctx = NULL;\n\tBIGNUM *Z, *Z_1, *Z_2, *Z_3;\n\tconst BIGNUM *Z_;\n\tint ret = 0;\n\tif (EC_POINT_is_at_infinity(group, point))\n\t\t{\n\t\tECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY);\n\t\treturn 0;\n\t\t}\n\tif (ctx == NULL)\n\t\t{\n\t\tctx = new_ctx = BN_CTX_new();\n\t\tif (ctx == NULL)\n\t\t\treturn 0;\n\t\t}\n\tBN_CTX_start(ctx);\n\tZ = BN_CTX_get(ctx);\n\tZ_1 = BN_CTX_get(ctx);\n\tZ_2 = BN_CTX_get(ctx);\n\tZ_3 = BN_CTX_get(ctx);\n\tif (Z_3 == NULL) goto err;\n\tif (group->meth->field_decode)\n\t\t{\n\t\tif (!group->meth->field_decode(group, Z, point->Z, ctx)) goto err;\n\t\tZ_ = Z;\n\t\t}\n\telse\n\t\t{\n\t\tZ_ = point->Z;\n\t\t}\n\tif (BN_is_one(Z_))\n\t\t{\n\t\tif (group->meth->field_decode)\n\t\t\t{\n\t\t\tif (x != NULL)\n\t\t\t\t{\n\t\t\t\tif (!group->meth->field_decode(group, x, point->X, ctx)) goto err;\n\t\t\t\t}\n\t\t\tif (y != NULL)\n\t\t\t\t{\n\t\t\t\tif (!group->meth->field_decode(group, y, point->Y, ctx)) goto err;\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (x != NULL)\n\t\t\t\t{\n\t\t\t\tif (!BN_copy(x, point->X)) goto err;\n\t\t\t\t}\n\t\t\tif (y != NULL)\n\t\t\t\t{\n\t\t\t\tif (!BN_copy(y, point->Y)) goto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\tif (!BN_mod_inverse(Z_1, Z_, group->field, ctx))\n\t\t\t{\n\t\t\tECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, ERR_R_BN_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (group->meth->field_encode == 0)\n\t\t\t{\n\t\t\tif (!group->meth->field_sqr(group, Z_2, Z_1, ctx)) goto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (!BN_mod_sqr(Z_2, Z_1, group->field, ctx)) goto err;\n\t\t\t}\n\t\tif (x != NULL)\n\t\t\t{\n\t\t\tif (!group->meth->field_mul(group, x, point->X, Z_2, ctx)) goto err;\n\t\t\t}\n\t\tif (y != NULL)\n\t\t\t{\n\t\t\tif (group->meth->field_encode == 0)\n\t\t\t\t{\n\t\t\t\tif (!group->meth->field_mul(group, Z_3, Z_2, Z_1, ctx)) goto err;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (!BN_mod_mul(Z_3, Z_2, Z_1, group->field, ctx)) goto err;\n\t\t\t\t}\n\t\t\tif (!group->meth->field_mul(group, y, point->Y, Z_3, ctx)) goto err;\n\t\t\t}\n\t\t}\n\tret = 1;\n err:\n\tBN_CTX_end(ctx);\n\tif (new_ctx != NULL)\n\t\tBN_CTX_free(new_ctx);\n\treturn ret;\n\t}', 'BIGNUM *BN_mod_inverse(BIGNUM *in,\n\tconst BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)\n\t{\n\tBIGNUM *rv;\n\tint noinv;\n\trv = int_bn_mod_inverse(in, a, n, ctx, &noinv);\n\tif (noinv)\n\t\tBNerr(BN_F_BN_MOD_INVERSE,BN_R_NO_INVERSE);\n\treturn rv;\n\t}', 'BIGNUM *int_bn_mod_inverse(BIGNUM *in,\n\tconst BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, int *pnoinv)\n\t{\n\tBIGNUM *A,*B,*X,*Y,*M,*D,*T,*R=NULL;\n\tBIGNUM *ret=NULL;\n\tint sign;\n\tif (pnoinv)\n\t\t*pnoinv = 0;\n\tif ((BN_get_flags(a, BN_FLG_CONSTTIME) != 0) || (BN_get_flags(n, BN_FLG_CONSTTIME) != 0))\n\t\t{\n\t\treturn BN_mod_inverse_no_branch(in, a, n, ctx);\n\t\t}\n\tbn_check_top(a);\n\tbn_check_top(n);\n\tBN_CTX_start(ctx);\n\tA = BN_CTX_get(ctx);\n\tB = BN_CTX_get(ctx);\n\tX = BN_CTX_get(ctx);\n\tD = BN_CTX_get(ctx);\n\tM = BN_CTX_get(ctx);\n\tY = BN_CTX_get(ctx);\n\tT = BN_CTX_get(ctx);\n\tif (T == NULL) goto err;\n\tif (in == NULL)\n\t\tR=BN_new();\n\telse\n\t\tR=in;\n\tif (R == NULL) goto err;\n\tBN_one(X);\n\tBN_zero(Y);\n\tif (BN_copy(B,a) == NULL) goto err;\n\tif (BN_copy(A,n) == NULL) goto err;\n\tA->neg = 0;\n\tif (B->neg || (BN_ucmp(B, A) >= 0))\n\t\t{\n\t\tif (!BN_nnmod(B, B, A, ctx)) goto err;\n\t\t}\n\tsign = -1;\n\tif (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048)))\n\t\t{\n\t\tint shift;\n\t\twhile (!BN_is_zero(B))\n\t\t\t{\n\t\t\tshift = 0;\n\t\t\twhile (!BN_is_bit_set(B, shift))\n\t\t\t\t{\n\t\t\t\tshift++;\n\t\t\t\tif (BN_is_odd(X))\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_uadd(X, X, n)) goto err;\n\t\t\t\t\t}\n\t\t\t\tif (!BN_rshift1(X, X)) goto err;\n\t\t\t\t}\n\t\t\tif (shift > 0)\n\t\t\t\t{\n\t\t\t\tif (!BN_rshift(B, B, shift)) goto err;\n\t\t\t\t}\n\t\t\tshift = 0;\n\t\t\twhile (!BN_is_bit_set(A, shift))\n\t\t\t\t{\n\t\t\t\tshift++;\n\t\t\t\tif (BN_is_odd(Y))\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_uadd(Y, Y, n)) goto err;\n\t\t\t\t\t}\n\t\t\t\tif (!BN_rshift1(Y, Y)) goto err;\n\t\t\t\t}\n\t\t\tif (shift > 0)\n\t\t\t\t{\n\t\t\t\tif (!BN_rshift(A, A, shift)) goto err;\n\t\t\t\t}\n\t\t\tif (BN_ucmp(B, A) >= 0)\n\t\t\t\t{\n\t\t\t\tif (!BN_uadd(X, X, Y)) goto err;\n\t\t\t\tif (!BN_usub(B, B, A)) goto err;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (!BN_uadd(Y, Y, X)) goto err;\n\t\t\t\tif (!BN_usub(A, A, B)) goto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\twhile (!BN_is_zero(B))\n\t\t\t{\n\t\t\tBIGNUM *tmp;\n\t\t\tif (BN_num_bits(A) == BN_num_bits(B))\n\t\t\t\t{\n\t\t\t\tif (!BN_one(D)) goto err;\n\t\t\t\tif (!BN_sub(M,A,B)) goto err;\n\t\t\t\t}\n\t\t\telse if (BN_num_bits(A) == BN_num_bits(B) + 1)\n\t\t\t\t{\n\t\t\t\tif (!BN_lshift1(T,B)) goto err;\n\t\t\t\tif (BN_ucmp(A,T) < 0)\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_one(D)) goto err;\n\t\t\t\t\tif (!BN_sub(M,A,B)) goto err;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_sub(M,A,T)) goto err;\n\t\t\t\t\tif (!BN_add(D,T,B)) goto err;\n\t\t\t\t\tif (BN_ucmp(A,D) < 0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (!BN_set_word(D,2)) goto err;\n\t\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\tif (!BN_set_word(D,3)) goto err;\n\t\t\t\t\t\tif (!BN_sub(M,M,B)) goto err;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (!BN_div(D,M,A,B,ctx)) goto err;\n\t\t\t\t}\n\t\t\ttmp=A;\n\t\t\tA=B;\n\t\t\tB=M;\n\t\t\tif (BN_is_one(D))\n\t\t\t\t{\n\t\t\t\tif (!BN_add(tmp,X,Y)) goto err;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tif (BN_is_word(D,2))\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_lshift1(tmp,X)) goto err;\n\t\t\t\t\t}\n\t\t\t\telse if (BN_is_word(D,4))\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_lshift(tmp,X,2)) goto err;\n\t\t\t\t\t}\n\t\t\t\telse if (D->top == 1)\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_copy(tmp,X)) goto err;\n\t\t\t\t\tif (!BN_mul_word(tmp,D->d[0])) goto err;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tif (!BN_mul(tmp,D,X,ctx)) goto err;\n\t\t\t\t\t}\n\t\t\t\tif (!BN_add(tmp,tmp,Y)) goto err;\n\t\t\t\t}\n\t\t\tM=Y;\n\t\t\tY=X;\n\t\t\tX=tmp;\n\t\t\tsign = -sign;\n\t\t\t}\n\t\t}\n\tif (sign < 0)\n\t\t{\n\t\tif (!BN_sub(Y,n,Y)) goto err;\n\t\t}\n\tif (BN_is_one(A))\n\t\t{\n\t\tif (!Y->neg && BN_ucmp(Y,n) < 0)\n\t\t\t{\n\t\t\tif (!BN_copy(R,Y)) goto err;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (!BN_nnmod(R,Y,n,ctx)) goto err;\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\tif (pnoinv)\n\t\t\t*pnoinv = 1;\n\t\tgoto err;\n\t\t}\n\tret=R;\nerr:\n\tif ((ret == NULL) && (in == NULL)) BN_free(R);\n\tBN_CTX_end(ctx);\n\tbn_check_top(ret);\n\treturn(ret);\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_START,BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n\t\tctx->err_stack++;\n\t\t}\n\tCTXDBG_EXIT(ctx);\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_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx)\n\t{\n\tif (!BN_sqr(r, a, ctx)) return 0;\n\treturn BN_mod(r, r, m, ctx);\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\tbn_check_top(a);\n\tal=a->top;\n\tif (al <= 0)\n\t\t{\n\t\tr->top=0;\n\t\tr->neg = 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 unsigned int BN_STACK_pop(BN_STACK *st)\n\t{\n\treturn st->indexes[--(st->depth)];\n\t}']