示例#1
0
/* Returns 1 if the contexts are equal, 0 otherwise. */
static int SSL_TEST_CTX_equal(SSL_TEST_CTX *ctx, SSL_TEST_CTX *ctx2)
{
    if (ctx->expected_result != ctx2->expected_result) {
        fprintf(stderr, "ExpectedResult mismatch: %s vs %s.\n",
                ssl_test_result_name(ctx->expected_result),
                ssl_test_result_name(ctx2->expected_result));
        return 0;
    }
    if (ctx->client_alert != ctx2->client_alert) {
        fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
                ssl_alert_name(ctx->client_alert),
                ssl_alert_name(ctx2->client_alert));
        return 0;
    }
    if (ctx->server_alert != ctx2->server_alert) {
        fprintf(stderr, "ServerAlert mismatch: %s vs %s.\n",
                ssl_alert_name(ctx->server_alert),
                ssl_alert_name(ctx2->server_alert));
        return 0;
    }
    if (ctx->protocol != ctx2->protocol) {
        fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
                ssl_protocol_name(ctx->protocol),
                ssl_protocol_name(ctx2->protocol));
        return 0;
    }
    if (ctx->client_verify_callback != ctx2->client_verify_callback) {
        fprintf(stderr, "ClientVerifyCallback mismatch: %s vs %s.\n",
                ssl_verify_callback_name(ctx->client_verify_callback),
                ssl_verify_callback_name(ctx2->client_verify_callback));
        return 0;
    }
    if (ctx->servername != ctx2->servername) {
        fprintf(stderr, "ServerName mismatch: %s vs %s.\n",
                ssl_servername_name(ctx->servername),
                ssl_servername_name(ctx2->servername));
        return 0;
    }
    if (ctx->expected_servername != ctx2->expected_servername) {
        fprintf(stderr, "ExpectedServerName mismatch: %s vs %s.\n",
                ssl_servername_name(ctx->expected_servername),
                ssl_servername_name(ctx2->expected_servername));
        return 0;
    }
    if (ctx->servername_callback != ctx2->servername_callback) {
        fprintf(stderr, "ServerNameCallback mismatch: %s vs %s.\n",
                ssl_servername_callback_name(ctx->servername_callback),
                ssl_servername_callback_name(ctx2->servername_callback));
        return 0;
    }
    if (ctx->session_ticket_expected != ctx2->session_ticket_expected) {
        fprintf(stderr, "SessionTicketExpected mismatch: %s vs %s.\n",
                ssl_session_ticket_name(ctx->session_ticket_expected),
                ssl_session_ticket_name(ctx2->session_ticket_expected));
        return 0;
    }

    return 1;
}
示例#2
0
static int check_result(HANDSHAKE_RESULT result, SSL_TEST_CTX *test_ctx)
{
    if (result.result != test_ctx->expected_result) {
        fprintf(stderr, "ExpectedResult mismatch: expected %s, got %s.\n",
                ssl_test_result_name(test_ctx->expected_result),
                ssl_test_result_name(result.result));
        return 0;
    }
    return 1;
}
示例#3
0
文件: ssl_test.c 项目: Lukasa/openssl
static int check_result(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
{
    if (!TEST_int_eq(result->result, test_ctx->expected_result)) {
        TEST_info("ExpectedResult mismatch: expected %s, got %s.",
                  ssl_test_result_name(test_ctx->expected_result),
                  ssl_test_result_name(result->result));
        return 0;
    }
    return 1;
}
示例#4
0
/* Returns 1 if the contexts are equal, 0 otherwise. */
static int SSL_TEST_CTX_equal(SSL_TEST_CTX *ctx, SSL_TEST_CTX *ctx2)
{
    if (ctx->method != ctx2->method) {
        fprintf(stderr, "Method mismatch: %s vs %s.\n",
                ssl_test_method_name(ctx->method),
                ssl_test_method_name(ctx2->method));
        return 0;
    }
    if (ctx->handshake_mode != ctx2->handshake_mode) {
        fprintf(stderr, "HandshakeMode mismatch: %s vs %s.\n",
                ssl_handshake_mode_name(ctx->handshake_mode),
                ssl_handshake_mode_name(ctx2->handshake_mode));
        return 0;
    }
    if (ctx->app_data_size != ctx2->app_data_size) {
        fprintf(stderr, "ApplicationData mismatch: %d vs %d.\n",
                ctx->app_data_size, ctx2->app_data_size);
        return 0;
    }

    if (ctx->max_fragment_size != ctx2->max_fragment_size) {
        fprintf(stderr, "MaxFragmentSize mismatch: %d vs %d.\n",
                ctx->max_fragment_size, ctx2->max_fragment_size);
        return 0;
    }

    if (!SSL_TEST_EXTRA_CONF_equal(&ctx->extra, &ctx2->extra)) {
        fprintf(stderr, "Extra conf mismatch.\n");
        return 0;
    }
    if (!SSL_TEST_EXTRA_CONF_equal(&ctx->resume_extra, &ctx2->resume_extra)) {
        fprintf(stderr, "Resume extra conf mismatch.\n");
        return 0;
    }

    if (ctx->expected_result != ctx2->expected_result) {
        fprintf(stderr, "ExpectedResult mismatch: %s vs %s.\n",
                ssl_test_result_name(ctx->expected_result),
                ssl_test_result_name(ctx2->expected_result));
        return 0;
    }
    if (ctx->expected_client_alert != ctx2->expected_client_alert) {
        fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
                ssl_alert_name(ctx->expected_client_alert),
                ssl_alert_name(ctx2->expected_client_alert));
        return 0;
    }
    if (ctx->expected_server_alert != ctx2->expected_server_alert) {
        fprintf(stderr, "ServerAlert mismatch: %s vs %s.\n",
                ssl_alert_name(ctx->expected_server_alert),
                ssl_alert_name(ctx2->expected_server_alert));
        return 0;
    }
    if (ctx->expected_protocol != ctx2->expected_protocol) {
        fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
                ssl_protocol_name(ctx->expected_protocol),
                ssl_protocol_name(ctx2->expected_protocol));
        return 0;
    }
    if (ctx->expected_servername != ctx2->expected_servername) {
        fprintf(stderr, "ExpectedServerName mismatch: %s vs %s.\n",
                ssl_servername_name(ctx->expected_servername),
                ssl_servername_name(ctx2->expected_servername));
        return 0;
    }
    if (ctx->session_ticket_expected != ctx2->session_ticket_expected) {
        fprintf(stderr, "SessionTicketExpected mismatch: %s vs %s.\n",
                ssl_session_ticket_name(ctx->session_ticket_expected),
                ssl_session_ticket_name(ctx2->session_ticket_expected));
        return 0;
    }
    if (!strings_equal("ExpectedNPNProtocol", ctx->expected_npn_protocol,
                       ctx2->expected_npn_protocol))
        return 0;
    if (!strings_equal("ExpectedALPNProtocol", ctx->expected_alpn_protocol,
                       ctx2->expected_alpn_protocol))
        return 0;
    if (ctx->resumption_expected != ctx2->resumption_expected) {
        fprintf(stderr, "ResumptionExpected mismatch: %d vs %d.\n",
                ctx->resumption_expected, ctx2->resumption_expected);
        return 0;
    }
    return 1;
}
示例#5
0
/* Returns 1 if the contexts are equal, 0 otherwise. */
static int SSL_TEST_CTX_equal(SSL_TEST_CTX *ctx, SSL_TEST_CTX *ctx2)
{
    if (ctx->expected_result != ctx2->expected_result) {
        fprintf(stderr, "ExpectedResult mismatch: %s vs %s.\n",
                ssl_test_result_name(ctx->expected_result),
                ssl_test_result_name(ctx2->expected_result));
        return 0;
    }
    if (ctx->client_alert != ctx2->client_alert) {
        fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
                ssl_alert_name(ctx->client_alert),
                ssl_alert_name(ctx2->client_alert));
        return 0;
    }
    if (ctx->server_alert != ctx2->server_alert) {
        fprintf(stderr, "ServerAlert mismatch: %s vs %s.\n",
                ssl_alert_name(ctx->server_alert),
                ssl_alert_name(ctx2->server_alert));
        return 0;
    }
    if (ctx->protocol != ctx2->protocol) {
        fprintf(stderr, "ClientAlert mismatch: %s vs %s.\n",
                ssl_protocol_name(ctx->protocol),
                ssl_protocol_name(ctx2->protocol));
        return 0;
    }
    if (ctx->client_verify_callback != ctx2->client_verify_callback) {
        fprintf(stderr, "ClientVerifyCallback mismatch: %s vs %s.\n",
                ssl_verify_callback_name(ctx->client_verify_callback),
                ssl_verify_callback_name(ctx2->client_verify_callback));
        return 0;
    }
    if (ctx->servername != ctx2->servername) {
        fprintf(stderr, "ServerName mismatch: %s vs %s.\n",
                ssl_servername_name(ctx->servername),
                ssl_servername_name(ctx2->servername));
        return 0;
    }
    if (ctx->expected_servername != ctx2->expected_servername) {
        fprintf(stderr, "ExpectedServerName mismatch: %s vs %s.\n",
                ssl_servername_name(ctx->expected_servername),
                ssl_servername_name(ctx2->expected_servername));
        return 0;
    }
    if (ctx->servername_callback != ctx2->servername_callback) {
        fprintf(stderr, "ServerNameCallback mismatch: %s vs %s.\n",
                ssl_servername_callback_name(ctx->servername_callback),
                ssl_servername_callback_name(ctx2->servername_callback));
        return 0;
    }
    if (ctx->session_ticket_expected != ctx2->session_ticket_expected) {
        fprintf(stderr, "SessionTicketExpected mismatch: %s vs %s.\n",
                ssl_session_ticket_name(ctx->session_ticket_expected),
                ssl_session_ticket_name(ctx2->session_ticket_expected));
        return 0;
    }
#ifndef OPENSSL_NO_NEXTPROTONEG
    if (!strings_equal("ClientNPNProtocols", ctx->client_npn_protocols,
                       ctx2->client_npn_protocols))
        return 0;
    if (ctx->method != ctx2->method) {
        fprintf(stderr, "Method mismatch: %s vs %s.\n",
                ssl_test_method_name(ctx->method),
                ssl_test_method_name(ctx2->method));
        return 0;
    }
    if (!strings_equal("ServerNPNProtocols", ctx->server_npn_protocols,
                       ctx2->server_npn_protocols))
        return 0;
    if (!strings_equal("Server2NPNProtocols", ctx->server_npn_protocols,
                       ctx2->server_npn_protocols))
        return 0;
    if (!strings_equal("ExpectedNPNProtocol", ctx->expected_npn_protocol,
                       ctx2->expected_npn_protocol))
        return 0;
    if (!strings_equal("ClientALPNProtocols", ctx->client_alpn_protocols,
                       ctx2->client_alpn_protocols))
        return 0;

    if (!strings_equal("ServerALPNProtocols", ctx->server_alpn_protocols,
                       ctx2->server_alpn_protocols))
        return 0;
    if (!strings_equal("Server2ALPNProtocols", ctx->server_alpn_protocols,
                       ctx2->server_alpn_protocols))
        return 0;
    if (!strings_equal("ExpectedALPNProtocol", ctx->expected_alpn_protocol,
                       ctx2->expected_alpn_protocol))
        return 0;
#endif
    if (ctx->handshake_mode != ctx2->handshake_mode) {
        fprintf(stderr, "HandshakeMode mismatch: %s vs %s.\n",
                ssl_handshake_mode_name(ctx->handshake_mode),
                ssl_handshake_mode_name(ctx2->handshake_mode));
        return 0;
    }
    if (ctx->resumption_expected != ctx2->resumption_expected) {
        fprintf(stderr, "ResumptionExpected mismatch: %d vs %d.\n",
                ctx->resumption_expected, ctx2->resumption_expected);
        return 0;
    }
    return 1;
}