From 15bbefa354dfd7bda261a57f4955aeafe401384f Mon Sep 17 00:00:00 2001 From: Sam Clark <3758302+goatgoose@users.noreply.github.com> Date: Wed, 20 Sep 2023 13:23:51 -0400 Subject: [PATCH] test for unparsed client hello --- ...n_client_hello_get_supported_groups_test.c | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/unit/s2n_client_hello_get_supported_groups_test.c b/tests/unit/s2n_client_hello_get_supported_groups_test.c index c08483c983c..729d6c09f61 100644 --- a/tests/unit/s2n_client_hello_get_supported_groups_test.c +++ b/tests/unit/s2n_client_hello_get_supported_groups_test.c @@ -99,7 +99,13 @@ int main(int argc, char **argv) /* Ensure that s2n_client_hello_get_supported_groups fails before the client hello is parsed. */ { - + struct s2n_client_hello client_hello = { 0 }; + + uint16_t supported_groups[TEST_SUPPORTED_GROUPS_LIST_COUNT] = { 0 }; + uint16_t supported_groups_count = 0; + EXPECT_FAILURE_WITH_ERRNO(s2n_client_hello_get_supported_groups(&client_hello, supported_groups, &supported_groups_count, + s2n_array_len(supported_groups)), + S2N_ERR_NULL); } /* Ensure that s2n_client_hello_get_supported_groups fails if a supported groups extension @@ -233,8 +239,8 @@ int main(int argc, char **argv) } /* Ensure that s2n_client_hello_get_supported_groups writes what is contained in the parsed - * supported groups extension in the client hello. - */ + * supported groups extension in the client hello. + */ { struct s2n_client_hello client_hello = { 0 }; @@ -274,7 +280,6 @@ int main(int argc, char **argv) for (size_t i = 0; i < supported_groups_count; i++) { uint16_t test_group = 0; EXPECT_SUCCESS(s2n_stuffer_read_uint16(&test_groups_list_stuffer, &test_group)); - uint16_t written_group = supported_groups[i]; EXPECT_EQUAL(test_group, written_group); @@ -283,10 +288,10 @@ int main(int argc, char **argv) } /* Self-talk: Ensure that the retrieved supported groups match what was sent by the client. - * - * This test also ensures that s2n_client_hello_get_supported_groups is usable from within - * the client hello callback. - */ + * + * This test also ensures that s2n_client_hello_get_supported_groups is usable from within + * the client hello callback. + */ { }