crypto/ec/curve25519.c:4623: error: INTEGER_OVERFLOW_L2
  (128 - [113, 380]):unsigned64 by call to `SHA512_Final`.
Showing all 14 steps of the trace


crypto/ec/curve25519.c:4619:3: Call
4617.     ge_p3_tobytes(out_sig, &R);
4618.   
4619.     SHA512_Init(&hash_ctx);
          ^
4620.     SHA512_Update(&hash_ctx, out_sig, 32);
4621.     SHA512_Update(&hash_ctx, public_key, 32);

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

crypto/ec/curve25519.c:4620:3: Call
4618.   
4619.     SHA512_Init(&hash_ctx);
4620.     SHA512_Update(&hash_ctx, out_sig, 32);
          ^
4621.     SHA512_Update(&hash_ctx, public_key, 32);
4622.     SHA512_Update(&hash_ctx, message, message_len);

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

crypto/ec/curve25519.c:4621:3: Call
4619.     SHA512_Init(&hash_ctx);
4620.     SHA512_Update(&hash_ctx, out_sig, 32);
4621.     SHA512_Update(&hash_ctx, public_key, 32);
          ^
4622.     SHA512_Update(&hash_ctx, message, message_len);
4623.     SHA512_Final(hram, &hash_ctx);

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

crypto/ec/curve25519.c:4622:3: Call
4620.     SHA512_Update(&hash_ctx, out_sig, 32);
4621.     SHA512_Update(&hash_ctx, public_key, 32);
4622.     SHA512_Update(&hash_ctx, message, message_len);
          ^
4623.     SHA512_Final(hram, &hash_ctx);
4624.   

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

crypto/ec/curve25519.c:4623:3: Call
4621.     SHA512_Update(&hash_ctx, public_key, 32);
4622.     SHA512_Update(&hash_ctx, message, message_len);
4623.     SHA512_Final(hram, &hash_ctx);
          ^
4624.   
4625.     x25519_sc_reduce(hram);

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

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

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

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

crypto/sha/sha512.c:112:9: Binary operation: (128 - [113, 380]):unsigned64 by call to `SHA512_Final` 
  110.       n++;
  111.       if (n > (sizeof(c->u) - 16)) {
  112.           memset(p + n, 0, sizeof(c->u) - n);
                 ^
  113.           n = 0;
  114.           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 ED25519_sign(uint8_t *out_sig, const uint8_t *message, size_t message_len,\n                 const uint8_t public_key[32], const uint8_t private_key[32]) {\n  uint8_t az[SHA512_DIGEST_LENGTH];\n  uint8_t nonce[SHA512_DIGEST_LENGTH];\n  ge_p3 R;\n  uint8_t hram[SHA512_DIGEST_LENGTH];\n  SHA512_CTX hash_ctx;\n  SHA512_Init(&hash_ctx);\n  SHA512_Update(&hash_ctx, private_key, 32);\n  SHA512_Final(az, &hash_ctx);\n  az[0] &= 248;\n  az[31] &= 63;\n  az[31] |= 64;\n  SHA512_Init(&hash_ctx);\n  SHA512_Update(&hash_ctx, az + 32, 32);\n  SHA512_Update(&hash_ctx, message, message_len);\n  SHA512_Final(nonce, &hash_ctx);\n  x25519_sc_reduce(nonce);\n  ge_scalarmult_base(&R, nonce);\n  ge_p3_tobytes(out_sig, &R);\n  SHA512_Init(&hash_ctx);\n  SHA512_Update(&hash_ctx, out_sig, 32);\n  SHA512_Update(&hash_ctx, public_key, 32);\n  SHA512_Update(&hash_ctx, message, message_len);\n  SHA512_Final(hram, &hash_ctx);\n  x25519_sc_reduce(hram);\n  sc_muladd(out_sig + 32, hram, az, nonce);\n  OPENSSL_cleanse(&hash_ctx, sizeof(hash_ctx));\n  OPENSSL_cleanse(nonce, sizeof(nonce));\n  OPENSSL_cleanse(az, sizeof(az));\n  return 1;\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}']