crypto/bn/bn_rand.c:365: error: INTEGER_OVERFLOW_L2
  (128 - [113, 506]):unsigned64 by call to `SHA512_Final`.
Showing all 16 steps of the trace


crypto/bn/bn_rand.c:360:3: Call
358.   		if (RAND_bytes(random_bytes, sizeof(random_bytes)) != 1)
359.   			goto err;
360.   		SHA512_Init(&sha);
         ^
361.   		SHA512_Update(&sha, &done, sizeof(done));
362.   		SHA512_Update(&sha, private_bytes, sizeof(private_bytes));

crypto/sha/sha512.c:91:9: Assignment
  89.   
  90.           c->Nl=0;        c->Nh=0;
  91.           c->num=0;       c->md_len=SHA512_DIGEST_LENGTH;
                ^
  92.           return 1;
  93.   	}

crypto/bn/bn_rand.c:361:3: Call
359.   			goto err;
360.   		SHA512_Init(&sha);
361.   		SHA512_Update(&sha, &done, sizeof(done));
         ^
362.   		SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
363.   		SHA512_Update(&sha, message, message_len);

crypto/sha/sha512.c:181:1: Parameter `c->num`
  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/bn/bn_rand.c:362:3: Call
360.   		SHA512_Init(&sha);
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));

crypto/sha/sha512.c:181:1: Parameter `c->num`
  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/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: Parameter `c->num`
  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/bn/bn_rand.c:364:3: Call
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);
366.   

crypto/sha/sha512.c:181:1: Parameter `c->num`
  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/bn/bn_rand.c:365:3: Call
363.   		SHA512_Update(&sha, message, message_len);
364.   		SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
365.   		SHA512_Final(digest, &sha);
         ^
366.   
367.   		todo = num_k_bytes - done;

crypto/sha/sha512.c:100:1: <RHS trace>
98.   void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num);
99.   
100. > int SHA512_Final (unsigned char *md, SHA512_CTX *c)
101.   	{
102.   	unsigned char *p=(unsigned char *)c->u.p;

crypto/sha/sha512.c:100:1: Parameter `c->num`
  98.   void sha512_block_data_order (SHA512_CTX *ctx, const void *in, size_t num);
  99.   
  100. > int SHA512_Final (unsigned char *md, SHA512_CTX *c)
  101.   	{
  102.   	unsigned char *p=(unsigned char *)c->u.p;

crypto/sha/sha512.c:103:2: Assignment
  101.   	{
  102.   	unsigned char *p=(unsigned char *)c->u.p;
  103.   	size_t n=c->num;
          ^
  104.   
  105.   	p[n]=0x80;	/* There always is a room for one */

crypto/sha/sha512.c:106:2: Assignment
  104.   
  105.   	p[n]=0x80;	/* There always is a room for one */
  106.   	n++;
          ^
  107.   	if (n > (sizeof(c->u)-16))
  108.   		memset (p+n,0,sizeof(c->u)-n), n=0,

crypto/sha/sha512.c:108:3: Binary operation: (128 - [113, 506]):unsigned64 by call to `SHA512_Final` 
  106.   	n++;
  107.   	if (n > (sizeof(c->u)-16))
  108.   		memset (p+n,0,sizeof(c->u)-n), n=0,
           ^
  109.   		sha512_block_data_order (c,p,1);
  110.   

int SHA512_Final (unsigned char *md, SHA512_CTX *c)
	{
	unsigned char *p=(unsigned char *)c->u.p;
	size_t n=c->num;
	p[n]=0x80;
	n++;
	if (n > (sizeof(c->u)-16))
		memset (p+n,0,sizeof(c->u)-n), n=0,
		sha512_block_data_order (c,p,1);
	memset (p+n,0,sizeof(c->u)-16-n);
#ifdef	B_ENDIAN
	c->u.d[SHA_LBLOCK-2] = c->Nh;
	c->u.d[SHA_LBLOCK-1] = c->Nl;
#else
	p[sizeof(c->u)-1]  = (unsigned char)(c->Nl);
	p[sizeof(c->u)-2]  = (unsigned char)(c->Nl>>8);
	p[sizeof(c->u)-3]  = (unsigned char)(c->Nl>>16);
	p[sizeof(c->u)-4]  = (unsigned char)(c->Nl>>24);
	p[sizeof(c->u)-5]  = (unsigned char)(c->Nl>>32);
	p[sizeof(c->u)-6]  = (unsigned char)(c->Nl>>40);
	p[sizeof(c->u)-7]  = (unsigned char)(c->Nl>>48);
	p[sizeof(c->u)-8]  = (unsigned char)(c->Nl>>56);
	p[sizeof(c->u)-9]  = (unsigned char)(c->Nh);
	p[sizeof(c->u)-10] = (unsigned char)(c->Nh>>8);
	p[sizeof(c->u)-11] = (unsigned char)(c->Nh>>16);
	p[sizeof(c->u)-12] = (unsigned char)(c->Nh>>24);
	p[sizeof(c->u)-13] = (unsigned char)(c->Nh>>32);
	p[sizeof(c->u)-14] = (unsigned char)(c->Nh>>40);
	p[sizeof(c->u)-15] = (unsigned char)(c->Nh>>48);
	p[sizeof(c->u)-16] = (unsigned char)(c->Nh>>56);
#endif
	sha512_block_data_order (c,p,1);
	if (md==0) return 0;
	switch (c->md_len)
		{
		case SHA384_DIGEST_LENGTH:
			for (n=0;n<SHA384_DIGEST_LENGTH/8;n++)
				{
				SHA_LONG64 t = c->h[n];
				*(md++)	= (unsigned char)(t>>56);
				*(md++)	= (unsigned char)(t>>48);
				*(md++)	= (unsigned char)(t>>40);
				*(md++)	= (unsigned char)(t>>32);
				*(md++)	= (unsigned char)(t>>24);
				*(md++)	= (unsigned char)(t>>16);
				*(md++)	= (unsigned char)(t>>8);
				*(md++)	= (unsigned char)(t);
				}
			break;
		case SHA512_DIGEST_LENGTH:
			for (n=0;n<SHA512_DIGEST_LENGTH/8;n++)
				{
				SHA_LONG64 t = c->h[n];
				*(md++)	= (unsigned char)(t>>56);
				*(md++)	= (unsigned char)(t>>48);
				*(md++)	= (unsigned char)(t>>40);
				*(md++)	= (unsigned char)(t>>32);
				*(md++)	= (unsigned char)(t>>24);
				*(md++)	= (unsigned char)(t>>16);
				*(md++)	= (unsigned char)(t>>8);
				*(md++)	= (unsigned char)(t);
				}
			break;
		default:	return 0;
		}
	return 1;
	}
['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_Init (SHA512_CTX *c)\n\t{\n\tc->h[0]=U64(0x6a09e667f3bcc908);\n\tc->h[1]=U64(0xbb67ae8584caa73b);\n\tc->h[2]=U64(0x3c6ef372fe94f82b);\n\tc->h[3]=U64(0xa54ff53a5f1d36f1);\n\tc->h[4]=U64(0x510e527fade682d1);\n\tc->h[5]=U64(0x9b05688c2b3e6c1f);\n\tc->h[6]=U64(0x1f83d9abfb41bd6b);\n\tc->h[7]=U64(0x5be0cd19137e2179);\n        c->Nl=0;        c->Nh=0;\n        c->num=0;       c->md_len=SHA512_DIGEST_LENGTH;\n        return 1;\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}', 'int SHA512_Final (unsigned char *md, SHA512_CTX *c)\n\t{\n\tunsigned char *p=(unsigned char *)c->u.p;\n\tsize_t n=c->num;\n\tp[n]=0x80;\n\tn++;\n\tif (n > (sizeof(c->u)-16))\n\t\tmemset (p+n,0,sizeof(c->u)-n), n=0,\n\t\tsha512_block_data_order (c,p,1);\n\tmemset (p+n,0,sizeof(c->u)-16-n);\n#ifdef\tB_ENDIAN\n\tc->u.d[SHA_LBLOCK-2] = c->Nh;\n\tc->u.d[SHA_LBLOCK-1] = c->Nl;\n#else\n\tp[sizeof(c->u)-1]  = (unsigned char)(c->Nl);\n\tp[sizeof(c->u)-2]  = (unsigned char)(c->Nl>>8);\n\tp[sizeof(c->u)-3]  = (unsigned char)(c->Nl>>16);\n\tp[sizeof(c->u)-4]  = (unsigned char)(c->Nl>>24);\n\tp[sizeof(c->u)-5]  = (unsigned char)(c->Nl>>32);\n\tp[sizeof(c->u)-6]  = (unsigned char)(c->Nl>>40);\n\tp[sizeof(c->u)-7]  = (unsigned char)(c->Nl>>48);\n\tp[sizeof(c->u)-8]  = (unsigned char)(c->Nl>>56);\n\tp[sizeof(c->u)-9]  = (unsigned char)(c->Nh);\n\tp[sizeof(c->u)-10] = (unsigned char)(c->Nh>>8);\n\tp[sizeof(c->u)-11] = (unsigned char)(c->Nh>>16);\n\tp[sizeof(c->u)-12] = (unsigned char)(c->Nh>>24);\n\tp[sizeof(c->u)-13] = (unsigned char)(c->Nh>>32);\n\tp[sizeof(c->u)-14] = (unsigned char)(c->Nh>>40);\n\tp[sizeof(c->u)-15] = (unsigned char)(c->Nh>>48);\n\tp[sizeof(c->u)-16] = (unsigned char)(c->Nh>>56);\n#endif\n\tsha512_block_data_order (c,p,1);\n\tif (md==0) return 0;\n\tswitch (c->md_len)\n\t\t{\n\t\tcase SHA384_DIGEST_LENGTH:\n\t\t\tfor (n=0;n<SHA384_DIGEST_LENGTH/8;n++)\n\t\t\t\t{\n\t\t\t\tSHA_LONG64 t = c->h[n];\n\t\t\t\t*(md++)\t= (unsigned char)(t>>56);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>48);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>40);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>32);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>24);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>16);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>8);\n\t\t\t\t*(md++)\t= (unsigned char)(t);\n\t\t\t\t}\n\t\t\tbreak;\n\t\tcase SHA512_DIGEST_LENGTH:\n\t\t\tfor (n=0;n<SHA512_DIGEST_LENGTH/8;n++)\n\t\t\t\t{\n\t\t\t\tSHA_LONG64 t = c->h[n];\n\t\t\t\t*(md++)\t= (unsigned char)(t>>56);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>48);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>40);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>32);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>24);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>16);\n\t\t\t\t*(md++)\t= (unsigned char)(t>>8);\n\t\t\t\t*(md++)\t= (unsigned char)(t);\n\t\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\treturn 0;\n\t\t}\n\treturn 1;\n\t}']