static int test_early_data_replay_int(int idx, int usecb, int confopt)
{
    SSL_CTX *cctx = NULL, *sctx = NULL;
    SSL *clientssl = NULL, *serverssl = NULL;
    int testresult = 0;
    SSL_SESSION *sess = NULL;
    size_t readbytes, written;
    unsigned char buf[20];
    allow_ed_cb_called = 0;
    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
                                       TLS1_VERSION, 0, &sctx,
                                       &cctx, cert, privkey)))
        return 0;
    if (usecb > 0) {
        if (confopt == 0) {
            SSL_CTX_set_options(sctx, SSL_OP_NO_ANTI_REPLAY);
        } else {
            SSL_CONF_CTX *confctx = SSL_CONF_CTX_new();
            if (!TEST_ptr(confctx))
                goto end;
            SSL_CONF_CTX_set_flags(confctx, SSL_CONF_FLAG_FILE
                                            | SSL_CONF_FLAG_SERVER);
            SSL_CONF_CTX_set_ssl_ctx(confctx, sctx);
            if (!TEST_int_eq(SSL_CONF_cmd(confctx, "Options", "-AntiReplay"),
                             2)) {
                SSL_CONF_CTX_free(confctx);
                goto end;
            }
            SSL_CONF_CTX_free(confctx);
        }
        SSL_CTX_set_allow_early_data_cb(sctx, allow_early_data_cb, &usecb);
    }
    if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
                                        &serverssl, &sess, idx)))
        goto end;
    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
            || !TEST_true(SSL_session_reused(clientssl)))
        goto end;
    SSL_shutdown(clientssl);
    SSL_shutdown(serverssl);
    SSL_free(serverssl);
    SSL_free(clientssl);
    serverssl = clientssl = NULL;
    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,
                                      &clientssl, NULL, NULL))
            || !TEST_true(SSL_set_session(clientssl, sess)))
        goto end;
    if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),
                                        &written))
            || !TEST_size_t_eq(written, strlen(MSG1)))
        goto end;
    if (usecb <= 1) {
        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
                                             &readbytes),
                         SSL_READ_EARLY_DATA_FINISH)
                || !TEST_int_eq(SSL_get_early_data_status(serverssl),
                                SSL_EARLY_DATA_REJECTED))
            goto end;
    } else {
        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
                                             &readbytes),
                         SSL_READ_EARLY_DATA_SUCCESS)
                || !TEST_mem_eq(MSG1, strlen(MSG1), buf, readbytes)
                || !TEST_int_gt(SSL_connect(clientssl), 0)
                || !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),
                                             &readbytes),
                                SSL_READ_EARLY_DATA_FINISH)
                || !TEST_int_eq(SSL_get_early_data_status(serverssl),
                                SSL_EARLY_DATA_ACCEPTED))
            goto end;
    }
    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))
            || !TEST_int_eq(SSL_session_reused(clientssl), (usecb > 0) ? 1 : 0)
            || !TEST_int_eq(allow_ed_cb_called, usecb > 0 ? 1 : 0))
        goto end;
    testresult = 1;
 end:
    SSL_SESSION_free(sess);
    SSL_SESSION_free(clientpsk);
    SSL_SESSION_free(serverpsk);
    clientpsk = serverpsk = NULL;
    SSL_free(serverssl);
    SSL_free(clientssl);
    SSL_CTX_free(sctx);
    SSL_CTX_free(cctx);
    return testresult;
}
['static int test_early_data_replay_int(int idx, int usecb, int confopt)\n{\n    SSL_CTX *cctx = NULL, *sctx = NULL;\n    SSL *clientssl = NULL, *serverssl = NULL;\n    int testresult = 0;\n    SSL_SESSION *sess = NULL;\n    size_t readbytes, written;\n    unsigned char buf[20];\n    allow_ed_cb_called = 0;\n    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),\n                                       TLS1_VERSION, 0, &sctx,\n                                       &cctx, cert, privkey)))\n        return 0;\n    if (usecb > 0) {\n        if (confopt == 0) {\n            SSL_CTX_set_options(sctx, SSL_OP_NO_ANTI_REPLAY);\n        } else {\n            SSL_CONF_CTX *confctx = SSL_CONF_CTX_new();\n            if (!TEST_ptr(confctx))\n                goto end;\n            SSL_CONF_CTX_set_flags(confctx, SSL_CONF_FLAG_FILE\n                                            | SSL_CONF_FLAG_SERVER);\n            SSL_CONF_CTX_set_ssl_ctx(confctx, sctx);\n            if (!TEST_int_eq(SSL_CONF_cmd(confctx, "Options", "-AntiReplay"),\n                             2)) {\n                SSL_CONF_CTX_free(confctx);\n                goto end;\n            }\n            SSL_CONF_CTX_free(confctx);\n        }\n        SSL_CTX_set_allow_early_data_cb(sctx, allow_early_data_cb, &usecb);\n    }\n    if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,\n                                        &serverssl, &sess, idx)))\n        goto end;\n    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))\n            || !TEST_true(SSL_session_reused(clientssl)))\n        goto end;\n    SSL_shutdown(clientssl);\n    SSL_shutdown(serverssl);\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    serverssl = clientssl = NULL;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,\n                                      &clientssl, NULL, NULL))\n            || !TEST_true(SSL_set_session(clientssl, sess)))\n        goto end;\n    if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),\n                                        &written))\n            || !TEST_size_t_eq(written, strlen(MSG1)))\n        goto end;\n    if (usecb <= 1) {\n        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                             &readbytes),\n                         SSL_READ_EARLY_DATA_FINISH)\n                || !TEST_int_eq(SSL_get_early_data_status(serverssl),\n                                SSL_EARLY_DATA_REJECTED))\n            goto end;\n    } else {\n        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                             &readbytes),\n                         SSL_READ_EARLY_DATA_SUCCESS)\n                || !TEST_mem_eq(MSG1, strlen(MSG1), buf, readbytes)\n                || !TEST_int_gt(SSL_connect(clientssl), 0)\n                || !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                             &readbytes),\n                                SSL_READ_EARLY_DATA_FINISH)\n                || !TEST_int_eq(SSL_get_early_data_status(serverssl),\n                                SSL_EARLY_DATA_ACCEPTED))\n            goto end;\n    }\n    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))\n            || !TEST_int_eq(SSL_session_reused(clientssl), (usecb > 0) ? 1 : 0)\n            || !TEST_int_eq(allow_ed_cb_called, usecb > 0 ? 1 : 0))\n        goto end;\n    testresult = 1;\n end:\n    SSL_SESSION_free(sess);\n    SSL_SESSION_free(clientpsk);\n    SSL_SESSION_free(serverpsk);\n    clientpsk = serverpsk = NULL;\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    SSL_CTX_free(sctx);\n    SSL_CTX_free(cctx);\n    return testresult;\n}', 'IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,\n                        TLS_server_method,\n                        ossl_statem_accept,\n                        ssl_undefined_function, TLSv1_2_enc_data)', 'IMPLEMENT_tls_meth_func(TLS_ANY_VERSION, 0, 0,\n                        TLS_client_method,\n                        ssl_undefined_function,\n                        ossl_statem_connect, TLSv1_2_enc_data)', 'int test_true(const char *file, int line, const char *s, int b)\n{\n    if (b)\n        return 1;\n    test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");\n    return 0;\n}', 'SSL_CONF_CTX *SSL_CONF_CTX_new(void)\n{\n    SSL_CONF_CTX *ret = OPENSSL_zalloc(sizeof(*ret));\n    return ret;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    FAILTEST();\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)(file); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'unsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags)\n{\n    cctx->flags |= flags;\n    return cctx->flags;\n}', 'void SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx)\n{\n    cctx->ctx = ctx;\n    cctx->ssl = NULL;\n    if (ctx) {\n        cctx->poptions = &ctx->options;\n        cctx->min_version = &ctx->min_proto_version;\n        cctx->max_version = &ctx->max_proto_version;\n        cctx->pcert_flags = &ctx->cert->cert_flags;\n        cctx->pvfy_flags = &ctx->verify_mode;\n    } else {\n        cctx->poptions = NULL;\n        cctx->min_version = NULL;\n        cctx->max_version = NULL;\n        cctx->pcert_flags = NULL;\n        cctx->pvfy_flags = NULL;\n    }\n}', 'DEFINE_COMPARISONS(int, int, "%d")']