crypto/bn/bn_rand.c:343: 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:338:9: Call
336.           if (RAND_bytes(random_bytes, sizeof(random_bytes)) != 1)
337.               goto err;
338.           SHA512_Init(&sha);
               ^
339.           SHA512_Update(&sha, &done, sizeof(done));
340.           SHA512_Update(&sha, private_bytes, sizeof(private_bytes));

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

crypto/bn/bn_rand.c:339:9: Call
337.               goto err;
338.           SHA512_Init(&sha);
339.           SHA512_Update(&sha, &done, sizeof(done));
               ^
340.           SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
341.           SHA512_Update(&sha, message, message_len);

crypto/sha/sha512.c:185:1: Parameter `c->num`
  183.   }
  184.   
  185. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
  186.   {
  187.       SHA_LONG64 l;

crypto/bn/bn_rand.c:340:9: Call
338.           SHA512_Init(&sha);
339.           SHA512_Update(&sha, &done, sizeof(done));
340.           SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
               ^
341.           SHA512_Update(&sha, message, message_len);
342.           SHA512_Update(&sha, random_bytes, sizeof(random_bytes));

crypto/sha/sha512.c:185:1: Parameter `c->num`
  183.   }
  184.   
  185. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
  186.   {
  187.       SHA_LONG64 l;

crypto/bn/bn_rand.c:341:9: Call
339.           SHA512_Update(&sha, &done, sizeof(done));
340.           SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
341.           SHA512_Update(&sha, message, message_len);
               ^
342.           SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
343.           SHA512_Final(digest, &sha);

crypto/sha/sha512.c:185:1: Parameter `c->num`
  183.   }
  184.   
  185. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
  186.   {
  187.       SHA_LONG64 l;

crypto/bn/bn_rand.c:342:9: Call
340.           SHA512_Update(&sha, private_bytes, sizeof(private_bytes));
341.           SHA512_Update(&sha, message, message_len);
342.           SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
               ^
343.           SHA512_Final(digest, &sha);
344.   

crypto/sha/sha512.c:185:1: Parameter `c->num`
  183.   }
  184.   
  185. > int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
  186.   {
  187.       SHA_LONG64 l;

crypto/bn/bn_rand.c:343:9: Call
341.           SHA512_Update(&sha, message, message_len);
342.           SHA512_Update(&sha, random_bytes, sizeof(random_bytes));
343.           SHA512_Final(digest, &sha);
               ^
344.   
345.           todo = num_k_bytes - done;

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

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

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

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

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

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,\n                          const BIGNUM *priv, const unsigned char *message,\n                          size_t message_len, BN_CTX *ctx)\n{\n    SHA512_CTX sha;\n    unsigned char random_bytes[64];\n    unsigned char digest[SHA512_DIGEST_LENGTH];\n    unsigned done, todo;\n    const unsigned num_k_bytes = BN_num_bytes(range) + 8;\n    unsigned char private_bytes[96];\n    unsigned char *k_bytes;\n    int ret = 0;\n    k_bytes = OPENSSL_malloc(num_k_bytes);\n    if (!k_bytes)\n        goto err;\n    todo = sizeof(priv->d[0]) * priv->top;\n    if (todo > sizeof(private_bytes)) {\n        BNerr(BN_F_BN_GENERATE_DSA_NONCE, BN_R_PRIVATE_KEY_TOO_LARGE);\n        goto err;\n    }\n    memcpy(private_bytes, priv->d, todo);\n    memset(private_bytes + todo, 0, sizeof(private_bytes) - todo);\n    for (done = 0; done < num_k_bytes;) {\n        if (RAND_bytes(random_bytes, sizeof(random_bytes)) != 1)\n            goto err;\n        SHA512_Init(&sha);\n        SHA512_Update(&sha, &done, sizeof(done));\n        SHA512_Update(&sha, private_bytes, sizeof(private_bytes));\n        SHA512_Update(&sha, message, message_len);\n        SHA512_Update(&sha, random_bytes, sizeof(random_bytes));\n        SHA512_Final(digest, &sha);\n        todo = num_k_bytes - done;\n        if (todo > SHA512_DIGEST_LENGTH)\n            todo = SHA512_DIGEST_LENGTH;\n        memcpy(k_bytes + done, digest, todo);\n        done += todo;\n    }\n    if (!BN_bin2bn(k_bytes, num_k_bytes, out))\n        goto err;\n    if (BN_mod(out, out, range, ctx) != 1)\n        goto err;\n    ret = 1;\n err:\n    OPENSSL_free(k_bytes);\n    return ret;\n}', 'int SHA512_Init(SHA512_CTX *c)\n{\n    c->h[0] = U64(0x6a09e667f3bcc908);\n    c->h[1] = U64(0xbb67ae8584caa73b);\n    c->h[2] = U64(0x3c6ef372fe94f82b);\n    c->h[3] = U64(0xa54ff53a5f1d36f1);\n    c->h[4] = U64(0x510e527fade682d1);\n    c->h[5] = U64(0x9b05688c2b3e6c1f);\n    c->h[6] = U64(0x1f83d9abfb41bd6b);\n    c->h[7] = U64(0x5be0cd19137e2179);\n    c->Nl = 0;\n    c->Nh = 0;\n    c->num = 0;\n    c->md_len = SHA512_DIGEST_LENGTH;\n    return 1;\n}', 'int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)\n{\n    SHA_LONG64 l;\n    unsigned char *p = c->u.p;\n    const unsigned char *data = (const unsigned char *)_data;\n    if (len == 0)\n        return 1;\n    l = (c->Nl + (((SHA_LONG64) len) << 3)) & U64(0xffffffffffffffff);\n    if (l < c->Nl)\n        c->Nh++;\n    if (sizeof(len) >= 8)\n        c->Nh += (((SHA_LONG64) len) >> 61);\n    c->Nl = l;\n    if (c->num != 0) {\n        size_t n = sizeof(c->u) - c->num;\n        if (len < n) {\n            memcpy(p + c->num, data, len), c->num += (unsigned int)len;\n            return 1;\n        } else {\n            memcpy(p + c->num, data, n), c->num = 0;\n            len -= n, data += n;\n            sha512_block_data_order(c, p, 1);\n        }\n    }\n    if (len >= sizeof(c->u)) {\n#ifndef SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA\n        if ((size_t)data % sizeof(c->u.d[0]) != 0)\n            while (len >= sizeof(c->u))\n                memcpy(p, data, sizeof(c->u)),\n                    sha512_block_data_order(c, p, 1),\n                    len -= sizeof(c->u), data += sizeof(c->u);\n        else\n#endif\n            sha512_block_data_order(c, data, len / sizeof(c->u)),\n                data += len, len %= sizeof(c->u), data -= len;\n    }\n    if (len != 0)\n        memcpy(p, data, len), c->num = (int)len;\n    return 1;\n}', 'int SHA512_Final(unsigned char *md, SHA512_CTX *c)\n{\n    unsigned char *p = (unsigned char *)c->u.p;\n    size_t n = c->num;\n    p[n] = 0x80;\n    n++;\n    if (n > (sizeof(c->u) - 16)) {\n        memset(p + n, 0, sizeof(c->u) - n);\n        n = 0;\n        sha512_block_data_order(c, p, 1);\n    }\n    memset(p + n, 0, sizeof(c->u) - 16 - n);\n#ifdef  B_ENDIAN\n    c->u.d[SHA_LBLOCK - 2] = c->Nh;\n    c->u.d[SHA_LBLOCK - 1] = c->Nl;\n#else\n    p[sizeof(c->u) - 1] = (unsigned char)(c->Nl);\n    p[sizeof(c->u) - 2] = (unsigned char)(c->Nl >> 8);\n    p[sizeof(c->u) - 3] = (unsigned char)(c->Nl >> 16);\n    p[sizeof(c->u) - 4] = (unsigned char)(c->Nl >> 24);\n    p[sizeof(c->u) - 5] = (unsigned char)(c->Nl >> 32);\n    p[sizeof(c->u) - 6] = (unsigned char)(c->Nl >> 40);\n    p[sizeof(c->u) - 7] = (unsigned char)(c->Nl >> 48);\n    p[sizeof(c->u) - 8] = (unsigned char)(c->Nl >> 56);\n    p[sizeof(c->u) - 9] = (unsigned char)(c->Nh);\n    p[sizeof(c->u) - 10] = (unsigned char)(c->Nh >> 8);\n    p[sizeof(c->u) - 11] = (unsigned char)(c->Nh >> 16);\n    p[sizeof(c->u) - 12] = (unsigned char)(c->Nh >> 24);\n    p[sizeof(c->u) - 13] = (unsigned char)(c->Nh >> 32);\n    p[sizeof(c->u) - 14] = (unsigned char)(c->Nh >> 40);\n    p[sizeof(c->u) - 15] = (unsigned char)(c->Nh >> 48);\n    p[sizeof(c->u) - 16] = (unsigned char)(c->Nh >> 56);\n#endif\n    sha512_block_data_order(c, p, 1);\n    if (md == 0)\n        return 0;\n    switch (c->md_len) {\n    case SHA384_DIGEST_LENGTH:\n        for (n = 0; n < SHA384_DIGEST_LENGTH / 8; n++) {\n            SHA_LONG64 t = c->h[n];\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n            *(md++) = (unsigned char)(t >> 24);\n            *(md++) = (unsigned char)(t >> 16);\n            *(md++) = (unsigned char)(t >> 8);\n            *(md++) = (unsigned char)(t);\n        }\n        break;\n    case SHA512_DIGEST_LENGTH:\n        for (n = 0; n < SHA512_DIGEST_LENGTH / 8; n++) {\n            SHA_LONG64 t = c->h[n];\n            *(md++) = (unsigned char)(t >> 56);\n            *(md++) = (unsigned char)(t >> 48);\n            *(md++) = (unsigned char)(t >> 40);\n            *(md++) = (unsigned char)(t >> 32);\n            *(md++) = (unsigned char)(t >> 24);\n            *(md++) = (unsigned char)(t >> 16);\n            *(md++) = (unsigned char)(t >> 8);\n            *(md++) = (unsigned char)(t);\n        }\n        break;\n    default:\n        return 0;\n    }\n    return 1;\n}']