@@ -62942,6 +62942,53 @@ static int test_dtls_no_extensions(void)
6294262942 return EXPECT_RESULT();
6294362943}
6294462944
62945+ static int test_TLSX_CA_NAMES_bad_extension(void)
62946+ {
62947+ EXPECT_DECLS;
62948+ #if defined(HAVE_MANUAL_MEMIO_TESTS_DEPENDENCIES) && defined(WOLFSSL_TLS13) && \
62949+ !defined(NO_CERTS) && !defined(WOLFSSL_NO_CA_NAMES) && \
62950+ defined(OPENSSL_EXTRA)
62951+ /* This test should only fail (with BUFFER_ERROR) when we actually try to
62952+ * parse the CA Names extension. Otherwise it will return other non-related
62953+ * errors. If CA Names will be parsed in more configurations, that should
62954+ * be reflected in the macro guard above. */
62955+ WOLFSSL *ssl_c = NULL;
62956+ WOLFSSL_CTX *ctx_c = NULL;
62957+ struct test_memio_ctx test_ctx;
62958+ const byte shBadCaNamesExt[] = {
62959+ 0x16, 0x03, 0x04, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x3b, 0x03, 0x03, 0xcf,
62960+ 0x21, 0xad, 0x74, 0xe5, 0x9a, 0x61, 0x11, 0xbe, 0x1d, 0x8c, 0x02, 0x1e,
62961+ 0x65, 0xb8, 0x91, 0xc2, 0xa2, 0x11, 0x16, 0x7a, 0xbb, 0x8c, 0x5e, 0x07,
62962+ 0x9e, 0x09, 0xe2, 0xc8, 0xa8, 0x33, 0x9c, 0x00, 0x13, 0x03, 0x00, 0x00,
62963+ 0x13, 0x94, 0x7e, 0x00, 0x03, 0x0b, 0xf7, 0x03, 0x00, 0x2b, 0x00, 0x02,
62964+ 0x03, 0x04, 0x00, 0x33, 0x00, 0x02, 0x00, 0x19, 0x16, 0x03, 0x03, 0x00,
62965+ 0x5c, 0x02, 0x00, 0x00, 0x3b, 0x03, 0x03, 0x03, 0xcf, 0x21, 0xad, 0x74,
62966+ 0x00, 0x00, 0x83, 0x3f, 0x3b, 0x80, 0x01, 0xac, 0x65, 0x8c, 0x19, 0x2a,
62967+ 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x02, 0x00, 0x9e, 0x09, 0x1c, 0xe8,
62968+ 0xa8, 0x09, 0x9c, 0x00, 0xc0, 0xb5, 0x00, 0x00, 0x11, 0x8f, 0x00, 0x00,
62969+ 0x03, 0x3f, 0x00, 0x0c, 0x00, 0x2b, 0x00, 0x02, 0x03, 0x04, 0x13, 0x05,
62970+ 0x00, 0x00, 0x08, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00,
62971+ 0x0d, 0x00, 0x00, 0x11, 0x00, 0x00, 0x0d, 0x00, 0x2f, 0x00, 0x01, 0xff,
62972+ 0xff, 0xff, 0xff, 0xfa, 0x0d, 0x00, 0x00, 0x00, 0xad, 0x02
62973+ };
62974+
62975+ XMEMSET(&test_ctx, 0, sizeof(test_ctx));
62976+
62977+ ExpectIntEQ(test_memio_setup(&test_ctx, &ctx_c, NULL, &ssl_c, NULL,
62978+ wolfTLSv1_3_client_method, NULL), 0);
62979+
62980+ XMEMCPY(test_ctx.c_buff, shBadCaNamesExt, sizeof(shBadCaNamesExt));
62981+ test_ctx.c_len = sizeof(shBadCaNamesExt);
62982+
62983+ ExpectIntEQ(wolfSSL_connect(ssl_c), -1);
62984+ ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), BUFFER_ERROR);
62985+
62986+ wolfSSL_free(ssl_c);
62987+ wolfSSL_CTX_free(ctx_c);
62988+ #endif
62989+ return EXPECT_RESULT();
62990+ }
62991+
6294562992/*----------------------------------------------------------------------------*
6294662993 | Main
6294762994 *----------------------------------------------------------------------------*/
@@ -64192,6 +64239,7 @@ TEST_CASE testCases[] = {
6419264239 TEST_DECL(test_dtls_ipv6_check),
6419364240 TEST_DECL(test_wolfSSL_SCR_after_resumption),
6419464241 TEST_DECL(test_dtls_no_extensions),
64242+ TEST_DECL(test_TLSX_CA_NAMES_bad_extension),
6419564243 /* This test needs to stay at the end to clean up any caches allocated. */
6419664244 TEST_DECL(test_wolfSSL_Cleanup)
6419764245};
0 commit comments