crypto/bn/bntest.c:1384: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `BN_GF2m_mod_div`.
Showing all 12 steps of the trace


crypto/bn/bntest.c:1386:4: Call
1384.   			BN_GF2m_mod_div(d, a, c, b[j], ctx);
1385.   			BN_GF2m_mod_mul(e, d, c, b[j], ctx);
1386.   			BN_GF2m_mod_div(f, a, e, b[j], ctx);
           ^
1387.   #if 0 /* make test uses ouput in bc but bc can't handle GF(2^m) arithmetic */
1388.   			if (bp != NULL)

crypto/bn/bn_gf2m.c:606:1: Parameter `r->top`
  604.    * or y, x could equal y.
  605.    */
  606. > int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx)
  607.   	{
  608.   	BIGNUM *xinv = NULL;

crypto/bn/bntest.c:1384:4: Call
1382.   		for (j=0; j < 2; j++)
1383.   			{
1384.   			BN_GF2m_mod_div(d, a, c, b[j], ctx);
           ^
1385.   			BN_GF2m_mod_mul(e, d, c, b[j], ctx);
1386.   			BN_GF2m_mod_div(f, a, e, b[j], ctx);

crypto/bn/bn_gf2m.c:606:1: Parameter `p->top`
  604.    * or y, x could equal y.
  605.    */
  606. > int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx)
  607.   	{
  608.   	BIGNUM *xinv = NULL;

crypto/bn/bn_gf2m.c:619:7: Call
  617.   	if (xinv == NULL) goto err;
  618.   	
  619.   	if (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err;
               ^
  620.   	if (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err;
  621.   	bn_check_top(r);

crypto/bn/bn_gf2m.c:521:1: Parameter `p->top`
    519.    *     of Elliptic Curve Cryptography Over Binary Fields".
    520.    */
    521. > int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
    522.   	{
    523.   	BIGNUM *b, *c, *u, *v, *tmp;

crypto/bn/bn_gf2m.c:538:7: Call
    536.   
    537.   	if (!BN_one(b)) goto err;
    538.   	if (!BN_GF2m_mod(u, a, p)) goto err;
                 ^
    539.   	if (!BN_copy(v, p)) goto err;
    540.   

crypto/bn/bn_gf2m.c:359:1: Parameter `p->top`
      357.    * BN_GF2m_mod_arr function.
      358.    */
      359. > int	BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p)
      360.   	{
      361.   	int ret = 0;

crypto/bn/bn_gf2m.c:362:18: Call
      360.   	{
      361.   	int ret = 0;
      362.   	const int max = BN_num_bits(p) + 1;
                              ^
      363.   	int *arr=NULL;
      364.   	bn_check_top(a);

crypto/bn/bn_lib.c:248:1: <LHS trace>
246.   	}
247.   
248. > int BN_num_bits(const BIGNUM *a)
249.   	{
250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:248:1: Parameter `a->top`
        246.   	}
        247.   
        248. > int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;

crypto/bn/bn_lib.c:250:2: Binary operation: ([0, +oo] - 1):unsigned64 by call to `BN_GF2m_mod_div` 
        248.   int BN_num_bits(const BIGNUM *a)
        249.   	{
        250.   	int i = a->top - 1;
                ^
        251.   	bn_check_top(a);
        252.   

int BN_num_bits(const BIGNUM *a)
	{
	int i = a->top - 1;
	bn_check_top(a);
	if (BN_is_zero(a)) return 0;
	return ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));
	}
['int test_gf2m_mod_div(BIO *bp,BN_CTX *ctx)\n\t{\n\tBIGNUM *a,*b[2],*c,*d,*e,*f;\n\tint i, j, ret = 0;\n\tint p0[] = {163,7,6,3,0,-1};\n\tint p1[] = {193,15,0,-1};\n\ta=BN_new();\n\tb[0]=BN_new();\n\tb[1]=BN_new();\n\tc=BN_new();\n\td=BN_new();\n\te=BN_new();\n\tf=BN_new();\n\tBN_GF2m_arr2poly(p0, b[0]);\n\tBN_GF2m_arr2poly(p1, b[1]);\n\tfor (i=0; i<num0; i++)\n\t\t{\n\t\tBN_bntest_rand(a, 512, 0, 0);\n\t\tBN_bntest_rand(c, 512, 0, 0);\n\t\tfor (j=0; j < 2; j++)\n\t\t\t{\n\t\t\tBN_GF2m_mod_div(d, a, c, b[j], ctx);\n\t\t\tBN_GF2m_mod_mul(e, d, c, b[j], ctx);\n\t\t\tBN_GF2m_mod_div(f, a, e, b[j], ctx);\n#if 0\n\t\t\tif (bp != NULL)\n\t\t\t\t{\n\t\t\t\tif (!results)\n\t\t\t\t\t{\n\t\t\t\t\tBN_print(bp,a);\n\t\t\t\t\tBIO_puts(bp, " = ");\n\t\t\t\t\tBN_print(bp,c);\n\t\t\t\t\tBIO_puts(bp," * ");\n\t\t\t\t\tBN_print(bp,d);\n\t\t\t\t\tBIO_puts(bp, " % ");\n\t\t\t\t\tBN_print(bp,b[j]);\n\t\t\t\t\tBIO_puts(bp,"\\n");\n\t\t\t\t\t}\n\t\t\t\t}\n#endif\n\t\t\tif(!BN_is_one(f))\n\t\t\t\t{\n\t\t\t\tfprintf(stderr,"GF(2^m) modular division test failed!\\n");\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tret = 1;\n  err:\n\tBN_free(a);\n\tBN_free(b[0]);\n\tBN_free(b[1]);\n\tBN_free(c);\n\tBN_free(d);\n\tBN_free(e);\n\tBN_free(f);\n\treturn ret;\n\t}', 'int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tBIGNUM *xinv = NULL;\n\tint ret = 0;\n\tbn_check_top(y);\n\tbn_check_top(x);\n\tbn_check_top(p);\n\tBN_CTX_start(ctx);\n\txinv = BN_CTX_get(ctx);\n\tif (xinv == NULL) goto err;\n\tif (!BN_GF2m_mod_inv(xinv, x, p, ctx)) goto err;\n\tif (!BN_GF2m_mod_mul(r, y, xinv, p, ctx)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\n\tBN_CTX_end(ctx);\n\treturn ret;\n\t}', 'int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tBIGNUM *b, *c, *u, *v, *tmp;\n\tint ret = 0;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tBN_CTX_start(ctx);\n\tb = BN_CTX_get(ctx);\n\tc = BN_CTX_get(ctx);\n\tu = BN_CTX_get(ctx);\n\tv = BN_CTX_get(ctx);\n\tif (v == NULL) goto err;\n\tif (!BN_one(b)) goto err;\n\tif (!BN_GF2m_mod(u, a, p)) goto err;\n\tif (!BN_copy(v, p)) goto err;\n\tif (BN_is_zero(u)) goto err;\n\twhile (1)\n\t\t{\n\t\twhile (!BN_is_odd(u))\n\t\t\t{\n\t\t\tif (!BN_rshift1(u, u)) goto err;\n\t\t\tif (BN_is_odd(b))\n\t\t\t\t{\n\t\t\t\tif (!BN_GF2m_add(b, b, p)) goto err;\n\t\t\t\t}\n\t\t\tif (!BN_rshift1(b, b)) goto err;\n\t\t\t}\n\t\tif (BN_abs_is_word(u, 1)) break;\n\t\tif (BN_num_bits(u) < BN_num_bits(v))\n\t\t\t{\n\t\t\ttmp = u; u = v; v = tmp;\n\t\t\ttmp = b; b = c; c = tmp;\n\t\t\t}\n\t\tif (!BN_GF2m_add(u, u, v)) goto err;\n\t\tif (!BN_GF2m_add(b, b, c)) goto err;\n\t\t}\n\tif (!BN_copy(r, b)) goto err;\n\tbn_check_top(r);\n\tret = 1;\nerr:\n  \tBN_CTX_end(ctx);\n\treturn ret;\n\t}', 'int\tBN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p)\n\t{\n\tint ret = 0;\n\tconst int max = BN_num_bits(p) + 1;\n\tint *arr=NULL;\n\tbn_check_top(a);\n\tbn_check_top(p);\n\tif ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;\n\tret = BN_GF2m_poly2arr(p, arr, max);\n\tif (!ret || ret > max)\n\t\t{\n\t\tBNerr(BN_F_BN_GF2M_MOD,BN_R_INVALID_LENGTH);\n\t\tgoto err;\n\t\t}\n\tret = BN_GF2m_mod_arr(r, a, arr);\n\tbn_check_top(r);\nerr:\n\tif (arr) OPENSSL_free(arr);\n\treturn ret;\n\t}', 'int BN_num_bits(const BIGNUM *a)\n\t{\n\tint i = a->top - 1;\n\tbn_check_top(a);\n\tif (BN_is_zero(a)) return 0;\n\treturn ((i*BN_BITS2) + BN_num_bits_word(a->d[i]));\n\t}']