crypto/ecdsa/ecs_ossl.c:330: error: INTEGER_OVERFLOW_L2
  ([1, +oo] - [-125, 127]):unsigned64 by call to `ecdsa_sign_setup`.
Showing all 11 steps of the trace


crypto/ecdsa/ecs_ossl.c:254:1: Parameter `dgst_len`
252.   
253.   
254. > static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len, 
255.   		const BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey)
256.   {

crypto/ecdsa/ecs_ossl.c:330:9: Call
328.   		if (in_kinv == NULL || in_r == NULL)
329.   		{
330.   			if (!ecdsa_sign_setup(
               ^
331.   				eckey, ctx, &kinv, &ret->r, dgst, dgst_len))
332.   			{

crypto/ecdsa/ecs_ossl.c:100:1: Parameter `dlen`
  98.   }
  99.   
  100. > static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,
  101.   					BIGNUM **kinvp, BIGNUM **rp,
  102.   					const unsigned char *dgst, int dlen)

crypto/ecdsa/ecs_ossl.c:159:10: Call
  157.   			if (dgst != NULL)
  158.   			{
  159.   				if (!BN_generate_dsa_nonce(k, order, EC_KEY_get0_private_key(eckey),
                  ^
  160.   							   dgst, dlen, ctx))
  161.   					{

crypto/bn/bn_rand.c:324:1: Parameter `message_len`
    322.    * secret. This is intended for use in DSA and ECDSA where an RNG weakness
    323.    * leads directly to private key exposure unless this function is used. */
    324. > int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, const BIGNUM* priv,
    325.   			  const unsigned char *message, size_t message_len,
    326.   			  BN_CTX *ctx)

crypto/bn/bn_rand.c:363:3: Call
    361.   		SHA512_Update(&sha, &done, sizeof(done));
    362.   		SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
    363.   		SHA512_Update(&sha, message, message_len);
             ^
    364.   		SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
    365.   		SHA512_Final(digest, &sha);

crypto/sha/sha512.c:181:1: <LHS trace>
179.   {   return SHA512_Final (md,c);   }
180.   
181. > int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len)
182.   	{
183.   	SHA_LONG64	l;

crypto/sha/sha512.c:181:1: Parameter `len`
      179.   {   return SHA512_Final (md,c);   }
      180.   
      181. > int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len)
      182.   	{
      183.   	SHA_LONG64	l;

crypto/sha/sha512.c:181:1: <RHS trace>
179.   {   return SHA512_Final (md,c);   }
180.   
181. > int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len)
182.   	{
183.   	SHA_LONG64	l;

crypto/sha/sha512.c:181:1: Parameter `len`
      179.   {   return SHA512_Final (md,c);   }
      180.   
      181. > int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len)
      182.   	{
      183.   	SHA_LONG64	l;

crypto/sha/sha512.c:205:4: Binary operation: ([1, +oo] - [-125, 127]):unsigned64 by call to `ecdsa_sign_setup` 
      203.   		else	{
      204.   			memcpy (p+c->num,data,n), c->num = 0;
      205.   			len-=n, data+=n;
                ^
      206.   			sha512_block_data_order (c,p,1);
      207.   			}

int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len)
	{
	SHA_LONG64	l;
	unsigned char  *p=c->u.p;
	const unsigned char *data=(const unsigned char *)_data;
	if (len==0) return  1;
	l = (c->Nl+(((SHA_LONG64)len)<<3))&U64(0xffffffffffffffff);
	if (l < c->Nl)		c->Nh++;
	if (sizeof(len)>=8)	c->Nh+=(((SHA_LONG64)len)>>61);
	c->Nl=l;
	if (c->num != 0)
		{
		size_t n = sizeof(c->u) - c->num;
		if (len < n)
			{
			memcpy (p+c->num,data,len), c->num += (unsigned int)len;
			return 1;
			}
		else	{
			memcpy (p+c->num,data,n), c->num = 0;
			len-=n, data+=n;
			sha512_block_data_order (c,p,1);
			}
		}
	if (len >= sizeof(c->u))
		{
#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA
		if ((size_t)data%sizeof(c->u.d[0]) != 0)
			while (len >= sizeof(c->u))
				memcpy (p,data,sizeof(c->u)),
				sha512_block_data_order (c,p,1),
				len  -= sizeof(c->u),
				data += sizeof(c->u);
		else
#endif
			sha512_block_data_order (c,data,len/sizeof(c->u)),
			data += len,
			len  %= sizeof(c->u),
			data -= len;
		}
	if (len != 0)	memcpy (p,data,len), c->num = (int)len;
	return 1;
	}
['static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dgst_len,\n\t\tconst BIGNUM *in_kinv, const BIGNUM *in_r, EC_KEY *eckey)\n{\n\tint     ok = 0, i;\n\tBIGNUM *kinv=NULL, *s, *m=NULL,*tmp=NULL,*order=NULL;\n\tconst BIGNUM *ckinv;\n\tBN_CTX     *ctx = NULL;\n\tconst EC_GROUP   *group;\n\tECDSA_SIG  *ret;\n\tECDSA_DATA *ecdsa;\n\tconst BIGNUM *priv_key;\n#ifdef OPENSSL_FIPS\n\tif(FIPS_selftest_failed())\n\t\t{\n\t\tFIPSerr(FIPS_F_ECDSA_DO_SIGN,FIPS_R_FIPS_SELFTEST_FAILED);\n\t\treturn NULL;\n\t\t}\n#endif\n\tecdsa    = ecdsa_check(eckey);\n\tgroup    = EC_KEY_get0_group(eckey);\n\tpriv_key = EC_KEY_get0_private_key(eckey);\n\tif (group == NULL || priv_key == NULL || ecdsa == NULL)\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_PASSED_NULL_PARAMETER);\n\t\treturn NULL;\n\t}\n#ifdef OPENSSL_FIPS\n\tif (!fips_check_ec_prng(eckey))\n\t\treturn NULL;\n#endif\n\tret = ECDSA_SIG_new();\n\tif (!ret)\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE);\n\t\treturn NULL;\n\t}\n\ts = ret->s;\n\tif ((ctx = BN_CTX_new()) == NULL || (order = BN_new()) == NULL ||\n\t\t(tmp = BN_new()) == NULL || (m = BN_new()) == NULL)\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t}\n\tif (!EC_GROUP_get_order(group, order, ctx))\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_EC_LIB);\n\t\tgoto err;\n\t}\n\ti = BN_num_bits(order);\n\tif (8 * dgst_len > i)\n\t\tdgst_len = (i + 7)/8;\n\tif (!BN_bin2bn(dgst, dgst_len, m))\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB);\n\t\tgoto err;\n\t}\n\tif ((8 * dgst_len > i) && !BN_rshift(m, m, 8 - (i & 0x7)))\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB);\n\t\tgoto err;\n\t}\n\tdo\n\t{\n\t\tif (in_kinv == NULL || in_r == NULL)\n\t\t{\n\t\t\tif (!ecdsa_sign_setup(\n\t\t\t\teckey, ctx, &kinv, &ret->r, dgst, dgst_len))\n\t\t\t{\n\t\t\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN,ERR_R_ECDSA_LIB);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t\tckinv = kinv;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tckinv  = in_kinv;\n\t\t\tif (BN_copy(ret->r, in_r) == NULL)\n\t\t\t{\n\t\t\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\t\tif (!BN_mod_mul(tmp, priv_key, ret->r, order, ctx))\n\t\t{\n\t\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB);\n\t\t\tgoto err;\n\t\t}\n\t\tif (!BN_mod_add_quick(s, tmp, m, order))\n\t\t{\n\t\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB);\n\t\t\tgoto err;\n\t\t}\n\t\tif (!BN_mod_mul(s, s, ckinv, order, ctx))\n\t\t{\n\t\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ERR_R_BN_LIB);\n\t\t\tgoto err;\n\t\t}\n\t\tif (BN_is_zero(s))\n\t\t{\n\t\t\tif (in_kinv != NULL && in_r != NULL)\n\t\t\t{\n\t\t\t\tECDSAerr(ECDSA_F_ECDSA_DO_SIGN, ECDSA_R_NEED_NEW_SETUP_VALUES);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t\tbreak;\n\t}\n\twhile (1);\n\tok = 1;\nerr:\n\tif (!ok)\n\t{\n\t\tECDSA_SIG_free(ret);\n\t\tret = NULL;\n\t}\n\tif (ctx)\n\t\tBN_CTX_free(ctx);\n\tif (m)\n\t\tBN_clear_free(m);\n\tif (tmp)\n\t\tBN_clear_free(tmp);\n\tif (order)\n\t\tBN_free(order);\n\tif (kinv)\n\t\tBN_clear_free(kinv);\n\treturn ret;\n}', 'static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in,\n\t\t\t\t\tBIGNUM **kinvp, BIGNUM **rp,\n\t\t\t\t\tconst unsigned char *dgst, int dlen)\n{\n\tBN_CTX   *ctx = NULL;\n\tBIGNUM\t *k = NULL, *r = NULL, *order = NULL, *X = NULL;\n\tEC_POINT *tmp_point=NULL;\n\tconst EC_GROUP *group;\n\tint \t ret = 0;\n\tif (eckey == NULL || (group = EC_KEY_get0_group(eckey)) == NULL)\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_PASSED_NULL_PARAMETER);\n\t\treturn 0;\n\t}\n\tif (ctx_in == NULL)\n\t{\n\t\tif ((ctx = BN_CTX_new()) == NULL)\n\t\t{\n\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_MALLOC_FAILURE);\n\t\t\treturn 0;\n\t\t}\n\t}\n\telse\n\t\tctx = ctx_in;\n\tk     = BN_new();\n\tr     = BN_new();\n\torder = BN_new();\n\tX     = BN_new();\n\tif (!k || !r || !order || !X)\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t}\n\tif ((tmp_point = EC_POINT_new(group)) == NULL)\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);\n\t\tgoto err;\n\t}\n\tif (!EC_GROUP_get_order(group, order, ctx))\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);\n\t\tgoto err;\n\t}\n#ifdef OPENSSL_FIPS\n\tif (!fips_check_ec_prng(eckey))\n\t\tgoto err;\n#endif\n\tdo\n\t{\n\t\tdo\n#ifndef OPENSSL_NO_SHA512\n\t\t\tif (dgst != NULL)\n\t\t\t{\n\t\t\t\tif (!BN_generate_dsa_nonce(k, order, EC_KEY_get0_private_key(eckey),\n\t\t\t\t\t\t\t   dgst, dlen, ctx))\n\t\t\t\t\t{\n\t\t\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,\n\t\t\t\t\t\t ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\t{\n\t\t\t\tif (!BN_rand_range(k, order))\n\t\t\t\t{\n\t\t\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,\n\t\t\t\t\t\t ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED);\n\t\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\twhile (BN_is_zero(k));\n\t\tif (!BN_add(k, k, order)) goto err;\n\t\tif (BN_num_bits(k) <= BN_num_bits(order))\n\t\t\tif (!BN_add(k, k, order)) goto err;\n\t\tif (!EC_POINT_mul(group, tmp_point, k, NULL, NULL, ctx))\n\t\t{\n\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_EC_LIB);\n\t\t\tgoto err;\n\t\t}\n\t\tif (EC_METHOD_get_field_type(EC_GROUP_method_of(group)) == NID_X9_62_prime_field)\n\t\t{\n\t\t\tif (!EC_POINT_get_affine_coordinates_GFp(group,\n\t\t\t\ttmp_point, X, NULL, ctx))\n\t\t\t{\n\t\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_EC_LIB);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n#ifndef OPENSSL_NO_EC2M\n\t\telse\n\t\t{\n\t\t\tif (!EC_POINT_get_affine_coordinates_GF2m(group,\n\t\t\t\ttmp_point, X, NULL, ctx))\n\t\t\t{\n\t\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP,ERR_R_EC_LIB);\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n#endif\n\t\tif (!BN_nnmod(r, X, order, ctx))\n\t\t{\n\t\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n\t\t\tgoto err;\n\t\t}\n\t}\n\twhile (BN_is_zero(r));\n\tif (!BN_mod_inverse(k, k, order, ctx))\n\t{\n\t\tECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB);\n\t\tgoto err;\n\t}\n\tif (*rp != NULL)\n\t\tBN_clear_free(*rp);\n\tif (*kinvp != NULL)\n\t\tBN_clear_free(*kinvp);\n\t*rp    = r;\n\t*kinvp = k;\n\tret = 1;\nerr:\n\tif (!ret)\n\t{\n\t\tif (k != NULL) BN_clear_free(k);\n\t\tif (r != NULL) BN_clear_free(r);\n\t}\n\tif (ctx_in == NULL)\n\t\tBN_CTX_free(ctx);\n\tif (order != NULL)\n\t\tBN_free(order);\n\tif (tmp_point != NULL)\n\t\tEC_POINT_free(tmp_point);\n\tif (X)\n\t\tBN_clear_free(X);\n\treturn(ret);\n}', 'int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, const BIGNUM* priv,\n\t\t\t  const unsigned char *message, size_t message_len,\n\t\t\t  BN_CTX *ctx)\n\t{\n\tSHA512_CTX sha;\n\tunsigned char random_bytes[64];\n\tunsigned char digest[SHA512_DIGEST_LENGTH];\n\tunsigned done, todo;\n\tconst unsigned num_k_bytes = BN_num_bytes(range) + 8;\n\tunsigned char private_bytes[96];\n\tunsigned char *k_bytes;\n\tint ret = 0;\n\tk_bytes = OPENSSL_malloc(num_k_bytes);\n\tif (!k_bytes)\n\t\tgoto err;\n\ttodo = sizeof(priv->d[0])*priv->top;\n\tif (todo > sizeof(private_bytes))\n\t\t{\n\t\tBNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_PRIVATE_KEY_TOO_LARGE);\n\t\tgoto err;\n\t\t}\n\tmemcpy(private_bytes, priv->d, todo);\n\tmemset(private_bytes + todo, 0, sizeof(private_bytes) - todo);\n\tfor (done = 0; done < num_k_bytes;) {\n\t\tif (RAND_bytes(random_bytes, sizeof(random_bytes)) != 1)\n\t\t\tgoto err;\n\t\tSHA512_Init(&sha);\n\t\tSHA512_Update(&sha, &done, sizeof(done));\n\t\tSHA512_Update(&sha, private_bytes, sizeof(private_bytes));\n\t\tSHA512_Update(&sha, message, message_len);\n\t\tSHA512_Update(&sha, random_bytes, sizeof(random_bytes));\n\t\tSHA512_Final(digest, &sha);\n\t\ttodo = num_k_bytes - done;\n\t\tif (todo > SHA512_DIGEST_LENGTH)\n\t\t\ttodo = SHA512_DIGEST_LENGTH;\n\t\tmemcpy(k_bytes + done, digest, todo);\n\t\tdone += todo;\n\t}\n\tif (!BN_bin2bn(k_bytes, num_k_bytes, out))\n\t\tgoto err;\n\tif (BN_mod(out, out, range, ctx) != 1)\n\t\tgoto err;\n\tret = 1;\nerr:\n\tif (k_bytes)\n\t\tOPENSSL_free(k_bytes);\n\treturn ret;\n\t}', 'int SHA512_Update (SHA512_CTX *c, const void *_data, size_t len)\n\t{\n\tSHA_LONG64\tl;\n\tunsigned char  *p=c->u.p;\n\tconst unsigned char *data=(const unsigned char *)_data;\n\tif (len==0) return  1;\n\tl = (c->Nl+(((SHA_LONG64)len)<<3))&U64(0xffffffffffffffff);\n\tif (l < c->Nl)\t\tc->Nh++;\n\tif (sizeof(len)>=8)\tc->Nh+=(((SHA_LONG64)len)>>61);\n\tc->Nl=l;\n\tif (c->num != 0)\n\t\t{\n\t\tsize_t n = sizeof(c->u) - c->num;\n\t\tif (len < n)\n\t\t\t{\n\t\t\tmemcpy (p+c->num,data,len), c->num += (unsigned int)len;\n\t\t\treturn 1;\n\t\t\t}\n\t\telse\t{\n\t\t\tmemcpy (p+c->num,data,n), c->num = 0;\n\t\t\tlen-=n, data+=n;\n\t\t\tsha512_block_data_order (c,p,1);\n\t\t\t}\n\t\t}\n\tif (len >= sizeof(c->u))\n\t\t{\n#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA\n\t\tif ((size_t)data%sizeof(c->u.d[0]) != 0)\n\t\t\twhile (len >= sizeof(c->u))\n\t\t\t\tmemcpy (p,data,sizeof(c->u)),\n\t\t\t\tsha512_block_data_order (c,p,1),\n\t\t\t\tlen  -= sizeof(c->u),\n\t\t\t\tdata += sizeof(c->u);\n\t\telse\n#endif\n\t\t\tsha512_block_data_order (c,data,len/sizeof(c->u)),\n\t\t\tdata += len,\n\t\t\tlen  %= sizeof(c->u),\n\t\t\tdata -= len;\n\t\t}\n\tif (len != 0)\tmemcpy (p,data,len), c->num = (int)len;\n\treturn 1;\n\t}']