crypto/evp/e_chacha20_poly1305.c:278: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - [0, 63]):unsigned64 by call to `chacha_cipher`.
Showing all 8 steps of the trace


crypto/evp/e_chacha20_poly1305.c:233:1: Parameter `len`
231.   }
232.   
233. > static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
234.                                       const unsigned char *in, size_t len)
235.   {

crypto/evp/e_chacha20_poly1305.c:278:17: Call
276.               } else {                            /* ciphertext */
277.                   Poly1305_Update(POLY1305_ctx(actx), in, plen);
278.                   chacha_cipher(ctx, out, in, plen);
                       ^
279.                   in += plen;
280.                   out += plen;

crypto/evp/e_chacha20_poly1305.c:96:1: <LHS trace>
94.   }
95.   
96. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
97.                            const unsigned char *inp, size_t len)
98.   {

crypto/evp/e_chacha20_poly1305.c:96:1: Parameter `len`
  94.   }
  95.   
  96. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
  97.                            const unsigned char *inp, size_t len)
  98.   {

crypto/evp/e_chacha20_poly1305.c:96:1: <RHS trace>
94.   }
95.   
96. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
97.                            const unsigned char *inp, size_t len)
98.   {

crypto/evp/e_chacha20_poly1305.c:96:1: Parameter `len`
  94.   }
  95.   
  96. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
  97.                            const unsigned char *inp, size_t len)
  98.   {

crypto/evp/e_chacha20_poly1305.c:120:5: Assignment
  118.       }
  119.   
  120.       rem = (unsigned int)(len % CHACHA_BLK_SIZE);
             ^
  121.       len -= rem;
  122.       ctr32 = key->counter[0];

crypto/evp/e_chacha20_poly1305.c:121:5: Binary operation: ([0, +oo] - [0, 63]):unsigned64 by call to `chacha_cipher` 
  119.   
  120.       rem = (unsigned int)(len % CHACHA_BLK_SIZE);
  121.       len -= rem;
             ^
  122.       ctr32 = key->counter[0];
  123.       while (len >= CHACHA_BLK_SIZE) {

static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
                         const unsigned char *inp, size_t len)
{
    EVP_CHACHA_KEY *key = data(ctx);
    unsigned int n, rem, ctr32;
    if ((n = key->partial_len)) {
        while (len && n < CHACHA_BLK_SIZE) {
            *out++ = *inp++ ^ key->buf[n++];
            len--;
        }
        key->partial_len = n;
        if (len == 0)
            return 1;
        if (n == CHACHA_BLK_SIZE) {
            key->partial_len = 0;
            key->counter[0]++;
            if (key->counter[0] == 0)
                key->counter[1]++;
        }
    }
    rem = (unsigned int)(len % CHACHA_BLK_SIZE);
    len -= rem;
    ctr32 = key->counter[0];
    while (len >= CHACHA_BLK_SIZE) {
        size_t blocks = len / CHACHA_BLK_SIZE;
        if (sizeof(size_t)>sizeof(unsigned int) && blocks>(1U<<28))
            blocks = (1U<<28);
        ctr32 += (unsigned int)blocks;
        if (ctr32 < blocks) {
            blocks -= ctr32;
            ctr32 = 0;
        }
        blocks *= CHACHA_BLK_SIZE;
        ChaCha20_ctr32(out, inp, blocks, key->key.d, key->counter);
        len -= blocks;
        inp += blocks;
        out += blocks;
        key->counter[0] = ctr32;
        if (ctr32 == 0) key->counter[1]++;
    }
    if (rem) {
        memset(key->buf, 0, sizeof(key->buf));
        ChaCha20_ctr32(key->buf, key->buf, CHACHA_BLK_SIZE,
                       key->key.d, key->counter);
        for (n = 0; n < rem; n++)
            out[n] = inp[n] ^ key->buf[n];
        key->partial_len = rem;
    }
    return 1;
}
['static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,\n                                    const unsigned char *in, size_t len)\n{\n    EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx);\n    size_t rem, plen = actx->tls_payload_length;\n    static const unsigned char zero[POLY1305_BLOCK_SIZE] = { 0 };\n    if (!actx->mac_inited) {\n        actx->key.counter[0] = 0;\n        memset(actx->key.buf, 0, sizeof(actx->key.buf));\n        ChaCha20_ctr32(actx->key.buf, actx->key.buf, CHACHA_BLK_SIZE,\n                       actx->key.key.d, actx->key.counter);\n        Poly1305_Init(POLY1305_ctx(actx), actx->key.buf);\n        actx->key.counter[0] = 1;\n        actx->mac_inited = 1;\n    }\n    if (in) {\n        if (out == NULL) {\n            Poly1305_Update(POLY1305_ctx(actx), in, len);\n            actx->len.aad += len;\n            actx->aad = 1;\n            return len;\n        } else {\n            if (actx->aad) {\n                if ((rem = (size_t)actx->len.aad % POLY1305_BLOCK_SIZE))\n                    Poly1305_Update(POLY1305_ctx(actx), zero,\n                                    POLY1305_BLOCK_SIZE - rem);\n                actx->aad = 0;\n            }\n            actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH;\n            if (plen == NO_TLS_PAYLOAD_LENGTH)\n                plen = len;\n            else if (len != plen + POLY1305_BLOCK_SIZE)\n                return -1;\n            if (ctx->encrypt) {\n                chacha_cipher(ctx, out, in, plen);\n                Poly1305_Update(POLY1305_ctx(actx), out, plen);\n                in += plen;\n                out += plen;\n                actx->len.text += plen;\n            } else {\n                Poly1305_Update(POLY1305_ctx(actx), in, plen);\n                chacha_cipher(ctx, out, in, plen);\n                in += plen;\n                out += plen;\n                actx->len.text += plen;\n            }\n        }\n    }\n    if (in == NULL\n        || plen != len) {\n        const union {\n            long one;\n            char little;\n        } is_endian = { 1 };\n        unsigned char temp[POLY1305_BLOCK_SIZE];\n        if (actx->aad) {\n            if ((rem = (size_t)actx->len.aad % POLY1305_BLOCK_SIZE))\n                Poly1305_Update(POLY1305_ctx(actx), zero,\n                                POLY1305_BLOCK_SIZE - rem);\n            actx->aad = 0;\n        }\n        if ((rem = (size_t)actx->len.text % POLY1305_BLOCK_SIZE))\n            Poly1305_Update(POLY1305_ctx(actx), zero,\n                            POLY1305_BLOCK_SIZE - rem);\n        if (is_endian.little) {\n            Poly1305_Update(POLY1305_ctx(actx),\n                            (unsigned char *)&actx->len, POLY1305_BLOCK_SIZE);\n        } else {\n            temp[0]  = (unsigned char)(actx->len.aad);\n            temp[1]  = (unsigned char)(actx->len.aad>>8);\n            temp[2]  = (unsigned char)(actx->len.aad>>16);\n            temp[3]  = (unsigned char)(actx->len.aad>>24);\n            temp[4]  = (unsigned char)(actx->len.aad>>32);\n            temp[5]  = (unsigned char)(actx->len.aad>>40);\n            temp[6]  = (unsigned char)(actx->len.aad>>48);\n            temp[7]  = (unsigned char)(actx->len.aad>>56);\n            temp[8]  = (unsigned char)(actx->len.text);\n            temp[9]  = (unsigned char)(actx->len.text>>8);\n            temp[10] = (unsigned char)(actx->len.text>>16);\n            temp[11] = (unsigned char)(actx->len.text>>24);\n            temp[12] = (unsigned char)(actx->len.text>>32);\n            temp[13] = (unsigned char)(actx->len.text>>40);\n            temp[14] = (unsigned char)(actx->len.text>>48);\n            temp[15] = (unsigned char)(actx->len.text>>56);\n            Poly1305_Update(POLY1305_ctx(actx), temp, POLY1305_BLOCK_SIZE);\n        }\n        Poly1305_Final(POLY1305_ctx(actx), ctx->encrypt ? actx->tag\n                                                        : temp);\n        actx->mac_inited = 0;\n        if (in != NULL && len != plen) {\n            if (ctx->encrypt) {\n                memcpy(out, actx->tag, POLY1305_BLOCK_SIZE);\n            } else {\n                if (CRYPTO_memcmp(temp, in, POLY1305_BLOCK_SIZE)) {\n                    memset(out, 0, plen);\n                    return -1;\n                }\n            }\n        }\n        else if (!ctx->encrypt) {\n            if (CRYPTO_memcmp(temp, actx->tag, actx->tag_len))\n                return -1;\n        }\n    }\n    return len;\n}', 'static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,\n                         const unsigned char *inp, size_t len)\n{\n    EVP_CHACHA_KEY *key = data(ctx);\n    unsigned int n, rem, ctr32;\n    if ((n = key->partial_len)) {\n        while (len && n < CHACHA_BLK_SIZE) {\n            *out++ = *inp++ ^ key->buf[n++];\n            len--;\n        }\n        key->partial_len = n;\n        if (len == 0)\n            return 1;\n        if (n == CHACHA_BLK_SIZE) {\n            key->partial_len = 0;\n            key->counter[0]++;\n            if (key->counter[0] == 0)\n                key->counter[1]++;\n        }\n    }\n    rem = (unsigned int)(len % CHACHA_BLK_SIZE);\n    len -= rem;\n    ctr32 = key->counter[0];\n    while (len >= CHACHA_BLK_SIZE) {\n        size_t blocks = len / CHACHA_BLK_SIZE;\n        if (sizeof(size_t)>sizeof(unsigned int) && blocks>(1U<<28))\n            blocks = (1U<<28);\n        ctr32 += (unsigned int)blocks;\n        if (ctr32 < blocks) {\n            blocks -= ctr32;\n            ctr32 = 0;\n        }\n        blocks *= CHACHA_BLK_SIZE;\n        ChaCha20_ctr32(out, inp, blocks, key->key.d, key->counter);\n        len -= blocks;\n        inp += blocks;\n        out += blocks;\n        key->counter[0] = ctr32;\n        if (ctr32 == 0) key->counter[1]++;\n    }\n    if (rem) {\n        memset(key->buf, 0, sizeof(key->buf));\n        ChaCha20_ctr32(key->buf, key->buf, CHACHA_BLK_SIZE,\n                       key->key.d, key->counter);\n        for (n = 0; n < rem; n++)\n            out[n] = inp[n] ^ key->buf[n];\n        key->partial_len = rem;\n    }\n    return 1;\n}']