summaryrefslogtreecommitdiff
path: root/test/clienthellotest.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/clienthellotest.c')
-rw-r--r--test/clienthellotest.c89
1 files changed, 43 insertions, 46 deletions
diff --git a/test/clienthellotest.c b/test/clienthellotest.c
index 2f6d336dbc15..6f0a2cccabf9 100644
--- a/test/clienthellotest.c
+++ b/test/clienthellotest.c
@@ -21,39 +21,37 @@
#include "testutil.h"
-#define CLIENT_VERSION_LEN 2
+#define CLIENT_VERSION_LEN 2
-#define TOTAL_NUM_TESTS 4
+#define TOTAL_NUM_TESTS 4
/*
* Test that explicitly setting ticket data results in it appearing in the
* ClientHello for a negotiated SSL/TLS version
*/
-#define TEST_SET_SESSION_TICK_DATA_VER_NEG 0
+#define TEST_SET_SESSION_TICK_DATA_VER_NEG 0
/* Enable padding and make sure ClientHello is long enough to require it */
-#define TEST_ADD_PADDING 1
+#define TEST_ADD_PADDING 1
/* Enable padding and make sure ClientHello is short enough to not need it */
-#define TEST_PADDING_NOT_NEEDED 2
+#define TEST_PADDING_NOT_NEEDED 2
/*
* Enable padding and add a PSK to the ClientHello (this will also ensure the
* ClientHello is long enough to need padding)
*/
-#define TEST_ADD_PADDING_AND_PSK 3
+#define TEST_ADD_PADDING_AND_PSK 3
-#define F5_WORKAROUND_MIN_MSG_LEN 0x7f
-#define F5_WORKAROUND_MAX_MSG_LEN 0x200
+#define F5_WORKAROUND_MIN_MSG_LEN 0x7f
+#define F5_WORKAROUND_MAX_MSG_LEN 0x200
static const char *sessionfile = NULL;
/* Dummy ALPN protocols used to pad out the size of the ClientHello */
/* ASCII 'O' = 79 = 0x4F = EBCDIC '|'*/
#ifdef CHARSET_EBCDIC
-static const char alpn_prots[] =
- "|1234567890123456789012345678901234567890123456789012345678901234567890123456789"
- "|1234567890123456789012345678901234567890123456789012345678901234567890123456789";
+static const char alpn_prots[] = "|1234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ "|1234567890123456789012345678901234567890123456789012345678901234567890123456789";
#else
-static const char alpn_prots[] =
- "O1234567890123456789012345678901234567890123456789012345678901234567890123456789"
- "O1234567890123456789012345678901234567890123456789012345678901234567890123456789";
+static const char alpn_prots[] = "O1234567890123456789012345678901234567890123456789012345678901234567890123456789"
+ "O1234567890123456789012345678901234567890123456789012345678901234567890123456789";
#endif
static int test_client_hello(int currtest)
@@ -91,7 +89,7 @@ static int test_client_hello(int currtest)
if (!TEST_true(SSL_CTX_set_max_proto_version(ctx, 0)))
goto end;
- switch(currtest) {
+ switch (currtest) {
case TEST_SET_SESSION_TICK_DATA_VER_NEG:
#if !defined(OPENSSL_NO_TLS1_3) && defined(OPENSSL_NO_TLS1_2)
/* TLSv1.3 is enabled and TLSv1.2 is disabled so can't do this test */
@@ -113,7 +111,7 @@ static int test_client_hello(int currtest)
if (!TEST_false(SSL_CTX_set_cipher_list(ctx, "")))
goto end;
ERR_clear_error();
- /* Fall through */
+ /* Fall through */
case TEST_ADD_PADDING:
case TEST_PADDING_NOT_NEEDED:
SSL_CTX_set_options(ctx, SSL_OP_TLSEXT_PADDING);
@@ -125,18 +123,18 @@ static int test_client_hello(int currtest)
* needed.
*/
if (currtest == TEST_ADD_PADDING) {
- if (!TEST_false(SSL_CTX_set_alpn_protos(ctx,
- (unsigned char *)alpn_prots,
- sizeof(alpn_prots) - 1)))
+ if (!TEST_false(SSL_CTX_set_alpn_protos(ctx,
+ (unsigned char *)alpn_prots,
+ sizeof(alpn_prots) - 1)))
goto end;
- /*
- * Otherwise we need to make sure we have a small enough message to
- * not need padding.
- */
+ /*
+ * Otherwise we need to make sure we have a small enough message to
+ * not need padding.
+ */
} else if (!TEST_true(SSL_CTX_set_cipher_list(ctx,
- "AES128-SHA"))
- || !TEST_true(SSL_CTX_set_ciphersuites(ctx,
- "TLS_AES_128_GCM_SHA256"))) {
+ "AES128-SHA"))
+ || !TEST_true(SSL_CTX_set_ciphersuites(ctx,
+ "TLS_AES_128_GCM_SHA256"))) {
goto end;
}
break;
@@ -165,13 +163,13 @@ static int test_client_hello(int currtest)
* too old.
*/
if (!TEST_true(SSL_SESSION_set_time(sess, (long)time(NULL)))
- || !TEST_true(SSL_set_session(con, sess)))
+ || !TEST_true(SSL_set_session(con, sess)))
goto end;
}
rbio = BIO_new(BIO_s_mem());
wbio = BIO_new(BIO_s_mem());
- if (!TEST_ptr(rbio)|| !TEST_ptr(wbio)) {
+ if (!TEST_ptr(rbio) || !TEST_ptr(wbio)) {
BIO_free(rbio);
BIO_free(wbio);
goto end;
@@ -182,7 +180,7 @@ static int test_client_hello(int currtest)
if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) {
if (!TEST_true(SSL_set_session_ticket_ext(con, dummytick,
- strlen(dummytick))))
+ strlen(dummytick))))
goto end;
}
@@ -192,39 +190,38 @@ static int test_client_hello(int currtest)
}
if (!TEST_long_ge(len = BIO_get_mem_data(wbio, (char **)&data), 0)
- || !TEST_true(PACKET_buf_init(&pkt, data, len))
- /* Skip the record header */
- || !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH))
+ || !TEST_true(PACKET_buf_init(&pkt, data, len))
+ /* Skip the record header */
+ || !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH))
goto end;
msglen = PACKET_remaining(&pkt);
/* Skip the handshake message header */
if (!TEST_true(PACKET_forward(&pkt, SSL3_HM_HEADER_LENGTH))
- /* Skip client version and random */
- || !TEST_true(PACKET_forward(&pkt, CLIENT_VERSION_LEN
- + SSL3_RANDOM_SIZE))
- /* Skip session id */
- || !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
- /* Skip ciphers */
- || !TEST_true(PACKET_get_length_prefixed_2(&pkt, &pkt2))
- /* Skip compression */
- || !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
- /* Extensions len */
- || !TEST_true(PACKET_as_length_prefixed_2(&pkt, &pkt2)))
+ /* Skip client version and random */
+ || !TEST_true(PACKET_forward(&pkt, CLIENT_VERSION_LEN + SSL3_RANDOM_SIZE))
+ /* Skip session id */
+ || !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
+ /* Skip ciphers */
+ || !TEST_true(PACKET_get_length_prefixed_2(&pkt, &pkt2))
+ /* Skip compression */
+ || !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
+ /* Extensions len */
+ || !TEST_true(PACKET_as_length_prefixed_2(&pkt, &pkt2)))
goto end;
/* Loop through all extensions */
while (PACKET_remaining(&pkt2)) {
if (!TEST_true(PACKET_get_net_2(&pkt2, &type))
- || !TEST_true(PACKET_get_length_prefixed_2(&pkt2, &pkt3)))
+ || !TEST_true(PACKET_get_length_prefixed_2(&pkt2, &pkt3)))
goto end;
if (type == TLSEXT_TYPE_session_ticket) {
if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) {
if (TEST_true(PACKET_equal(&pkt3, dummytick,
- strlen(dummytick)))) {
+ strlen(dummytick)))) {
/* Ticket data is as we expected */
testresult = 1;
}
@@ -235,7 +232,7 @@ static int test_client_hello(int currtest)
if (!TEST_false(currtest == TEST_PADDING_NOT_NEEDED))
goto end;
else if (TEST_true(currtest == TEST_ADD_PADDING
- || currtest == TEST_ADD_PADDING_AND_PSK))
+ || currtest == TEST_ADD_PADDING_AND_PSK))
testresult = TEST_true(msglen == F5_WORKAROUND_MAX_MSG_LEN);
}
}