crypto/evp/e_chacha20_poly1305.c:380: 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:325:1: Parameter `len`
323.   #  endif
324.   
325. > static int chacha20_poly1305_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
326.                                       const unsigned char *in, size_t len)
327.   {

crypto/evp/e_chacha20_poly1305.c:380:17: Call
378.               } else {                            /* ciphertext */
379.                   Poly1305_Update(POLY1305_ctx(actx), in, plen);
380.                   chacha_cipher(ctx, out, in, plen);
                       ^
381.                   in += plen;
382.                   out += plen;

crypto/evp/e_chacha20_poly1305.c:55:1: <LHS trace>
53.   }
54.   
55. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
56.                            const unsigned char *inp, size_t len)
57.   {

crypto/evp/e_chacha20_poly1305.c:55:1: Parameter `len`
  53.   }
  54.   
  55. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
  56.                            const unsigned char *inp, size_t len)
  57.   {

crypto/evp/e_chacha20_poly1305.c:55:1: <RHS trace>
53.   }
54.   
55. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
56.                            const unsigned char *inp, size_t len)
57.   {

crypto/evp/e_chacha20_poly1305.c:55:1: Parameter `len`
  53.   }
  54.   
  55. > static int chacha_cipher(EVP_CIPHER_CTX * ctx, unsigned char *out,
  56.                            const unsigned char *inp, size_t len)
  57.   {

crypto/evp/e_chacha20_poly1305.c:79:5: Assignment
  77.       }
  78.   
  79.       rem = (unsigned int)(len % CHACHA_BLK_SIZE);
            ^
  80.       len -= rem;
  81.       ctr32 = key->counter[0];

crypto/evp/e_chacha20_poly1305.c:80:5: Binary operation: ([0, +oo] - [0, 63]):unsigned64 by call to `chacha_cipher` 
  78.   
  79.       rem = (unsigned int)(len % CHACHA_BLK_SIZE);
  80.       len -= rem;
            ^
  81.       ctr32 = key->counter[0];
  82.       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    if (!actx->mac_inited) {\n#  if !defined(OPENSSL_SMALL_FOOTPRINT)\n        if (plen != NO_TLS_PAYLOAD_LENGTH && out != NULL)\n            return chacha20_poly1305_tls_cipher(ctx, out, in, len);\n#  endif\n        actx->key.counter[0] = 0;\n        ChaCha20_ctr32(actx->key.buf, zero, 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->key.partial_len = 0;\n        actx->len.aad = actx->len.text = 0;\n        actx->mac_inited = 1;\n        if (plen != NO_TLS_PAYLOAD_LENGTH) {\n            Poly1305_Update(POLY1305_ctx(actx), actx->tls_aad,\n                            EVP_AEAD_TLS1_AAD_LEN);\n            actx->len.aad = EVP_AEAD_TLS1_AAD_LEN;\n            actx->aad = 1;\n        }\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 - plen, 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}']