summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2017-01-23 15:09:25 +0000
committerMatt Caswell <matt@openssl.org>2017-01-30 10:18:24 +0000
commit342543426d19ad948e3e7a37209baa78d0032d86 (patch)
treebeaca9db745e0c42e112f5530223e7704cf00faf /test
parente463cb39d32d3621183e9a1d487daae13ff716e3 (diff)
Add a test for WPACKET_fill_lengths()
Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2259)
Diffstat (limited to 'test')
-rw-r--r--test/wpackettest.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/wpackettest.c b/test/wpackettest.c
index 52c98271da..3ab293e0e9 100644
--- a/test/wpackettest.c
+++ b/test/wpackettest.c
@@ -254,6 +254,27 @@ static int test_WPACKET_start_sub_packet(void)
return 0;
}
+ /* Nested sub-packets with lengths filled before finish */
+ if (!WPACKET_init(&pkt, buf)
+ || !WPACKET_start_sub_packet_u8(&pkt)
+ || !WPACKET_put_bytes_u8(&pkt, 0xff)
+ || !WPACKET_start_sub_packet_u8(&pkt)
+ || !WPACKET_put_bytes_u8(&pkt, 0xff)
+ || !WPACKET_get_length(&pkt, &len)
+ || len != 1
+ || !WPACKET_close(&pkt)
+ || !WPACKET_get_length(&pkt, &len)
+ || len != 3
+ || !WPACKET_close(&pkt)
+ || !WPACKET_fill_lengths(&pkt)
+ || !WPACKET_get_total_written(&pkt, &written)
+ || written != sizeof(nestedsub)
+ || memcmp(buf->data, &nestedsub, written) != 0
+ || !WPACKET_finish(&pkt)) {
+ testfail("test_WPACKET_start_sub_packet():5 failed\n", &pkt);
+ return 0;
+ }
+
return 1;
}