diff options
author | Emilia Kasper <emilia@openssl.org> | 2016-07-04 20:16:14 +0200 |
---|---|---|
committer | Emilia Kasper <emilia@openssl.org> | 2016-07-19 14:17:48 +0200 |
commit | ce2cdac2787da32bcde210c7d6acdcbe41b1cd40 (patch) | |
tree | aa513a318f435fd51c82df0f83aa09219d55e1cc /test/ssl_test_ctx.c | |
parent | 02f730b34706150f8f40715d647cce3be5baf2ab (diff) |
SSL test framework: port NPN and ALPN tests
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test/ssl_test_ctx.c')
-rw-r--r-- | test/ssl_test_ctx.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/test/ssl_test_ctx.c b/test/ssl_test_ctx.c index 4d038d2c23..090e1a330e 100644 --- a/test/ssl_test_ctx.c +++ b/test/ssl_test_ctx.c @@ -83,7 +83,8 @@ static const test_enum ssl_alerts[] = { {"UnknownCA", SSL_AD_UNKNOWN_CA}, {"HandshakeFailure", SSL_AD_HANDSHAKE_FAILURE}, {"UnrecognizedName", SSL_AD_UNRECOGNIZED_NAME}, - {"BadCertificate", SSL_AD_BAD_CERTIFICATE} + {"BadCertificate", SSL_AD_BAD_CERTIFICATE}, + {"NoApplicationProtocol", SSL_AD_NO_APPLICATION_PROTOCOL}, }; __owur static int parse_alert(int *alert, const char *value) @@ -281,6 +282,28 @@ const char *ssl_test_method_name(ssl_test_method_t method) return enum_name(ssl_test_methods, OSSL_NELEM(ssl_test_methods), method); } +#define IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(field) \ + static int parse_##field(SSL_TEST_CTX *test_ctx, const char *value) \ + { \ + OPENSSL_free(test_ctx->field); \ + test_ctx->field = OPENSSL_strdup(value); \ + OPENSSL_assert(test_ctx->field != NULL); \ + return 1; \ + } + +/************************************/ +/* NPN and ALPN options */ +/************************************/ + +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(client_npn_protocols) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server_npn_protocols) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server2_npn_protocols) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(expected_npn_protocol) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(client_alpn_protocols) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server_alpn_protocols) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(server2_alpn_protocols) +IMPLEMENT_SSL_TEST_CTX_STRING_OPTION(expected_alpn_protocol) + /*************************************************************/ /* Known test options and their corresponding parse methods. */ /*************************************************************/ @@ -301,9 +324,16 @@ static const ssl_test_ctx_option ssl_test_ctx_options[] = { { "ServerNameCallback", &parse_servername_callback }, { "SessionTicketExpected", &parse_session_ticket }, { "Method", &parse_test_method }, + { "ClientNPNProtocols", &parse_client_npn_protocols }, + { "ServerNPNProtocols", &parse_server_npn_protocols }, + { "Server2NPNProtocols", &parse_server2_npn_protocols }, + { "ExpectedNPNProtocol", &parse_expected_npn_protocol }, + { "ClientALPNProtocols", &parse_client_alpn_protocols }, + { "ServerALPNProtocols", &parse_server_alpn_protocols }, + { "Server2ALPNProtocols", &parse_server2_alpn_protocols }, + { "ExpectedALPNProtocol", &parse_expected_alpn_protocol }, }; - /* * Since these methods are used to create tests, we use OPENSSL_assert liberally * for malloc failures and other internal errors. @@ -318,6 +348,15 @@ SSL_TEST_CTX *SSL_TEST_CTX_new() void SSL_TEST_CTX_free(SSL_TEST_CTX *ctx) { + + OPENSSL_free(ctx->client_npn_protocols); + OPENSSL_free(ctx->server_npn_protocols); + OPENSSL_free(ctx->server2_npn_protocols); + OPENSSL_free(ctx->client_alpn_protocols); + OPENSSL_free(ctx->server_alpn_protocols); + OPENSSL_free(ctx->server2_alpn_protocols); + OPENSSL_free(ctx->expected_npn_protocol); + OPENSSL_free(ctx->expected_alpn_protocol); OPENSSL_free(ctx); } |