]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add a test for the new PACKET_msg_start() function feature/ech
authorMatt Caswell <matt@openssl.org>
Thu, 5 Jun 2025 14:29:01 +0000 (15:29 +0100)
committerMatt Caswell <matt@openssl.org>
Tue, 10 Jun 2025 16:19:04 +0000 (17:19 +0100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27776)

test/packettest.c

index 40b68d310a7246e2649fb10336c2a9ed8b7964c8..3eb0f73f044c768dc63eb1fad731241a6e3fda3c 100644 (file)
@@ -570,9 +570,39 @@ static int test_PACKET_get_quic_length_prefixed(void)
 
     return 1;
 }
-
 #endif
 
+static int test_PACKET_msg_start(void)
+{
+    unsigned char buf[16] = { 0 };
+    PACKET pkt, subpkt;
+
+    if (!TEST_true(PACKET_buf_init(&pkt, buf, sizeof(buf))))
+        return 0;
+
+    if (!TEST_ptr_eq(PACKET_msg_start(&pkt), buf))
+        return 0;
+
+    if (!TEST_true(PACKET_forward(&pkt, 1))
+            || !TEST_ptr_eq(PACKET_msg_start(&pkt), buf))
+        return 0;
+
+    if (!TEST_true(PACKET_get_sub_packet(&pkt, &subpkt, 1))
+            || !TEST_ptr_eq(PACKET_msg_start(&subpkt), buf)
+            || !TEST_ptr_eq(PACKET_msg_start(&pkt), buf))
+        return 0;
+
+    if (!TEST_true(PACKET_forward(&subpkt, 1))
+            || !TEST_ptr_eq(PACKET_msg_start(&pkt), buf))
+        return 0;
+
+    PACKET_null_init(&pkt);
+    if (!TEST_ptr_null(PACKET_msg_start(&pkt)))
+        return 0;
+
+    return 1;
+}
+
 int setup_tests(void)
 {
     unsigned int i;
@@ -607,5 +637,6 @@ int setup_tests(void)
     ADD_TEST(test_PACKET_get_quic_vlint);
     ADD_TEST(test_PACKET_get_quic_length_prefixed);
 #endif
+    ADD_TEST(test_PACKET_msg_start);
     return 1;
 }