test/evp_test.c:979: error: INTEGER_OVERFLOW_L1
  ([18446744073709551615, +oo] + [1, 16]):unsigned64 by call to `cipher_test_enc`.
Showing all 8 steps of the trace


test/evp_test.c:968:14: Assignment
966.           static char aux_err[64];
967.           t->aux_err = aux_err;
968.           for (inp_misalign = (size_t)-1; inp_misalign != 2; inp_misalign++) {
                    ^
969.               if (inp_misalign == (size_t)-1) {
970.                   /* kludge: inp_misalign == -1 means "exercise in-place" */

test/evp_test.c:979:22: Call
977.               }
978.               if (cdat->enc) {
979.                   rv = cipher_test_enc(t, 1, out_misalign, inp_misalign);
                            ^
980.                   /* Not fatal errors: return */
981.                   if (rv != 1) {

test/evp_test.c:794:1: <LHS trace>
792.   }
793.   
794. > static int cipher_test_enc(struct evp_test *t, int enc,
795.                              size_t out_misalign, size_t inp_misalign)
796.   {

test/evp_test.c:794:1: Parameter `inp_misalign`
  792.   }
  793.   
  794. > static int cipher_test_enc(struct evp_test *t, int enc,
  795.                              size_t out_misalign, size_t inp_misalign)
  796.   {

test/evp_test.c:794:1: <RHS trace>
792.   }
793.   
794. > static int cipher_test_enc(struct evp_test *t, int enc,
795.                              size_t out_misalign, size_t inp_misalign)
796.   {

test/evp_test.c:794:1: Parameter `t->data->plaintext_len`
  792.   }
  793.   
  794. > static int cipher_test_enc(struct evp_test *t, int enc,
  795.                              size_t out_misalign, size_t inp_misalign)
  796.   {

test/evp_test.c:810:9: Assignment
  808.       if (enc) {
  809.           in = cdat->plaintext;
  810.           in_len = cdat->plaintext_len;
                 ^
  811.           out = cdat->ciphertext;
  812.           out_len = cdat->ciphertext_len;

test/evp_test.c:828:9: Binary operation: ([18446744073709551615, +oo] + [1, 16]):unsigned64 by call to `cipher_test_enc` 
  826.           in = memcpy(tmp + out_misalign, in, in_len);
  827.       } else {
  828.           inp_misalign += 16 - ((out_misalign + in_len) & 15);
                 ^
  829.           /*
  830.            * 'tmp' will store both output and copy of input. We make the copy

static int cipher_test_enc(struct evp_test *t, int enc,
                           size_t out_misalign, size_t inp_misalign)
{
    struct cipher_data *cdat = t->data;
    unsigned char *in, *out, *tmp = NULL;
    size_t in_len, out_len;
    int tmplen, tmpflen;
    EVP_CIPHER_CTX *ctx = NULL;
    const char *err;
    err = "INTERNAL_ERROR";
    ctx = EVP_CIPHER_CTX_new();
    if (!ctx)
        goto err;
    EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);
    if (enc) {
        in = cdat->plaintext;
        in_len = cdat->plaintext_len;
        out = cdat->ciphertext;
        out_len = cdat->ciphertext_len;
    } else {
        in = cdat->ciphertext;
        in_len = cdat->ciphertext_len;
        out = cdat->plaintext;
        out_len = cdat->plaintext_len;
    }
    if (inp_misalign == (size_t)-1) {
        tmp = OPENSSL_malloc(out_misalign + in_len + 2 * EVP_MAX_BLOCK_LENGTH);
        if (!tmp)
            goto err;
        in = memcpy(tmp + out_misalign, in, in_len);
    } else {
        inp_misalign += 16 - ((out_misalign + in_len) & 15);
        tmp = OPENSSL_malloc(out_misalign + in_len + 2 * EVP_MAX_BLOCK_LENGTH +
                             inp_misalign + in_len);
        if (!tmp)
            goto err;
        in = memcpy(tmp + out_misalign + in_len + 2 * EVP_MAX_BLOCK_LENGTH +
                    inp_misalign, in, in_len);
    }
    err = "CIPHERINIT_ERROR";
    if (!EVP_CipherInit_ex(ctx, cdat->cipher, NULL, NULL, NULL, enc))
        goto err;
    err = "INVALID_IV_LENGTH";
    if (cdat->iv) {
        if (cdat->aead) {
            if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN,
                                     cdat->iv_len, 0))
                goto err;
        } else if (cdat->iv_len != (size_t)EVP_CIPHER_CTX_iv_length(ctx))
            goto err;
    }
    if (cdat->aead) {
        unsigned char *tag;
        if (enc || cdat->aead == EVP_CIPH_OCB_MODE) {
            err = "TAG_LENGTH_SET_ERROR";
            tag = NULL;
        } else {
            err = "TAG_SET_ERROR";
            tag = cdat->tag;
        }
        if (tag || cdat->aead != EVP_CIPH_GCM_MODE) {
            if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
                                     cdat->tag_len, tag))
                goto err;
        }
    }
    err = "INVALID_KEY_LENGTH";
    if (!EVP_CIPHER_CTX_set_key_length(ctx, cdat->key_len))
        goto err;
    err = "KEY_SET_ERROR";
    if (!EVP_CipherInit_ex(ctx, NULL, NULL, cdat->key, cdat->iv, -1))
        goto err;
    if (!enc && cdat->aead == EVP_CIPH_OCB_MODE) {
        if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,
                                 cdat->tag_len, cdat->tag)) {
            err = "TAG_SET_ERROR";
            goto err;
        }
    }
    if (cdat->aead == EVP_CIPH_CCM_MODE) {
        if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, out_len)) {
            err = "CCM_PLAINTEXT_LENGTH_SET_ERROR";
            goto err;
        }
    }
    if (cdat->aad) {
        if (!EVP_CipherUpdate(ctx, NULL, &tmplen, cdat->aad, cdat->aad_len)) {
            err = "AAD_SET_ERROR";
            goto err;
        }
    }
    EVP_CIPHER_CTX_set_padding(ctx, 0);
    err = "CIPHERUPDATE_ERROR";
    if (!EVP_CipherUpdate(ctx, tmp + out_misalign, &tmplen, in, in_len))
        goto err;
    if (cdat->aead == EVP_CIPH_CCM_MODE)
        tmpflen = 0;
    else {
        err = "CIPHERFINAL_ERROR";
        if (!EVP_CipherFinal_ex(ctx, tmp + out_misalign + tmplen, &tmpflen))
            goto err;
    }
    err = "LENGTH_MISMATCH";
    if (out_len != (size_t)(tmplen + tmpflen))
        goto err;
    err = "VALUE_MISMATCH";
    if (check_output(t, out, tmp + out_misalign, out_len))
        goto err;
    if (enc && cdat->aead) {
        unsigned char rtag[16];
        if (cdat->tag_len > sizeof(rtag)) {
            err = "TAG_LENGTH_INTERNAL_ERROR";
            goto err;
        }
        if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG,
                                 cdat->tag_len, rtag)) {
            err = "TAG_RETRIEVE_ERROR";
            goto err;
        }
        if (check_output(t, cdat->tag, rtag, cdat->tag_len)) {
            err = "TAG_VALUE_MISMATCH";
            goto err;
        }
    }
    err = NULL;
 err:
    OPENSSL_free(tmp);
    EVP_CIPHER_CTX_free(ctx);
    t->err = err;
    return err ? 0 : 1;
}
['static int cipher_test_run(struct evp_test *t)\n{\n    struct cipher_data *cdat = t->data;\n    int rv;\n    size_t out_misalign, inp_misalign;\n    if (!cdat->key) {\n        t->err = "NO_KEY";\n        return 0;\n    }\n    if (!cdat->iv && EVP_CIPHER_iv_length(cdat->cipher)) {\n        if (EVP_CIPHER_mode(cdat->cipher) != EVP_CIPH_WRAP_MODE) {\n            t->err = "NO_IV";\n            return 0;\n        }\n    }\n    if (cdat->aead && !cdat->tag) {\n        t->err = "NO_TAG";\n        return 0;\n    }\n    for (out_misalign = 0; out_misalign <= 1; out_misalign++) {\n        static char aux_err[64];\n        t->aux_err = aux_err;\n        for (inp_misalign = (size_t)-1; inp_misalign != 2; inp_misalign++) {\n            if (inp_misalign == (size_t)-1) {\n                BIO_snprintf(aux_err, sizeof(aux_err), "%s in-place",\n                             out_misalign ? "misaligned" : "aligned");\n            } else {\n                BIO_snprintf(aux_err, sizeof(aux_err), "%s output and %s input",\n                             out_misalign ? "misaligned" : "aligned",\n                             inp_misalign ? "misaligned" : "aligned");\n            }\n            if (cdat->enc) {\n                rv = cipher_test_enc(t, 1, out_misalign, inp_misalign);\n                if (rv != 1) {\n                    if (rv < 0)\n                        return 0;\n                    return 1;\n                }\n            }\n            if (cdat->enc != 1) {\n                rv = cipher_test_enc(t, 0, out_misalign, inp_misalign);\n                if (rv != 1) {\n                    if (rv < 0)\n                        return 0;\n                    return 1;\n                }\n            }\n        }\n    }\n    t->aux_err = NULL;\n    return 1;\n}', 'static int cipher_test_enc(struct evp_test *t, int enc,\n                           size_t out_misalign, size_t inp_misalign)\n{\n    struct cipher_data *cdat = t->data;\n    unsigned char *in, *out, *tmp = NULL;\n    size_t in_len, out_len;\n    int tmplen, tmpflen;\n    EVP_CIPHER_CTX *ctx = NULL;\n    const char *err;\n    err = "INTERNAL_ERROR";\n    ctx = EVP_CIPHER_CTX_new();\n    if (!ctx)\n        goto err;\n    EVP_CIPHER_CTX_set_flags(ctx, EVP_CIPHER_CTX_FLAG_WRAP_ALLOW);\n    if (enc) {\n        in = cdat->plaintext;\n        in_len = cdat->plaintext_len;\n        out = cdat->ciphertext;\n        out_len = cdat->ciphertext_len;\n    } else {\n        in = cdat->ciphertext;\n        in_len = cdat->ciphertext_len;\n        out = cdat->plaintext;\n        out_len = cdat->plaintext_len;\n    }\n    if (inp_misalign == (size_t)-1) {\n        tmp = OPENSSL_malloc(out_misalign + in_len + 2 * EVP_MAX_BLOCK_LENGTH);\n        if (!tmp)\n            goto err;\n        in = memcpy(tmp + out_misalign, in, in_len);\n    } else {\n        inp_misalign += 16 - ((out_misalign + in_len) & 15);\n        tmp = OPENSSL_malloc(out_misalign + in_len + 2 * EVP_MAX_BLOCK_LENGTH +\n                             inp_misalign + in_len);\n        if (!tmp)\n            goto err;\n        in = memcpy(tmp + out_misalign + in_len + 2 * EVP_MAX_BLOCK_LENGTH +\n                    inp_misalign, in, in_len);\n    }\n    err = "CIPHERINIT_ERROR";\n    if (!EVP_CipherInit_ex(ctx, cdat->cipher, NULL, NULL, NULL, enc))\n        goto err;\n    err = "INVALID_IV_LENGTH";\n    if (cdat->iv) {\n        if (cdat->aead) {\n            if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN,\n                                     cdat->iv_len, 0))\n                goto err;\n        } else if (cdat->iv_len != (size_t)EVP_CIPHER_CTX_iv_length(ctx))\n            goto err;\n    }\n    if (cdat->aead) {\n        unsigned char *tag;\n        if (enc || cdat->aead == EVP_CIPH_OCB_MODE) {\n            err = "TAG_LENGTH_SET_ERROR";\n            tag = NULL;\n        } else {\n            err = "TAG_SET_ERROR";\n            tag = cdat->tag;\n        }\n        if (tag || cdat->aead != EVP_CIPH_GCM_MODE) {\n            if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,\n                                     cdat->tag_len, tag))\n                goto err;\n        }\n    }\n    err = "INVALID_KEY_LENGTH";\n    if (!EVP_CIPHER_CTX_set_key_length(ctx, cdat->key_len))\n        goto err;\n    err = "KEY_SET_ERROR";\n    if (!EVP_CipherInit_ex(ctx, NULL, NULL, cdat->key, cdat->iv, -1))\n        goto err;\n    if (!enc && cdat->aead == EVP_CIPH_OCB_MODE) {\n        if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG,\n                                 cdat->tag_len, cdat->tag)) {\n            err = "TAG_SET_ERROR";\n            goto err;\n        }\n    }\n    if (cdat->aead == EVP_CIPH_CCM_MODE) {\n        if (!EVP_CipherUpdate(ctx, NULL, &tmplen, NULL, out_len)) {\n            err = "CCM_PLAINTEXT_LENGTH_SET_ERROR";\n            goto err;\n        }\n    }\n    if (cdat->aad) {\n        if (!EVP_CipherUpdate(ctx, NULL, &tmplen, cdat->aad, cdat->aad_len)) {\n            err = "AAD_SET_ERROR";\n            goto err;\n        }\n    }\n    EVP_CIPHER_CTX_set_padding(ctx, 0);\n    err = "CIPHERUPDATE_ERROR";\n    if (!EVP_CipherUpdate(ctx, tmp + out_misalign, &tmplen, in, in_len))\n        goto err;\n    if (cdat->aead == EVP_CIPH_CCM_MODE)\n        tmpflen = 0;\n    else {\n        err = "CIPHERFINAL_ERROR";\n        if (!EVP_CipherFinal_ex(ctx, tmp + out_misalign + tmplen, &tmpflen))\n            goto err;\n    }\n    err = "LENGTH_MISMATCH";\n    if (out_len != (size_t)(tmplen + tmpflen))\n        goto err;\n    err = "VALUE_MISMATCH";\n    if (check_output(t, out, tmp + out_misalign, out_len))\n        goto err;\n    if (enc && cdat->aead) {\n        unsigned char rtag[16];\n        if (cdat->tag_len > sizeof(rtag)) {\n            err = "TAG_LENGTH_INTERNAL_ERROR";\n            goto err;\n        }\n        if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG,\n                                 cdat->tag_len, rtag)) {\n            err = "TAG_RETRIEVE_ERROR";\n            goto err;\n        }\n        if (check_output(t, cdat->tag, rtag, cdat->tag_len)) {\n            err = "TAG_VALUE_MISMATCH";\n            goto err;\n        }\n    }\n    err = NULL;\n err:\n    OPENSSL_free(tmp);\n    EVP_CIPHER_CTX_free(ctx);\n    t->err = err;\n    return err ? 0 : 1;\n}']