Handle reassembly of handshake messages
Works only with GnuTLS for now, OpenSSL packs other records in the same
datagram after the last fragmented one, which we don't handle yet.
Also, ssl-opt.sh fails the tests with valgrind for now: we're so slow with
valgrind that gnutls-serv retransmits some messages, and we don't handle
duplicated messages yet.
diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh
index 1dac6d6..e9faa97 100755
--- a/tests/ssl-opt.sh
+++ b/tests/ssl-opt.sh
@@ -1946,6 +1946,40 @@
-c "received hello verify request" \
-S "SSL - The requested feature is not available"
+# Tests for receiving fragmented handshake messages with DTLS
+
+requires_gnutls
+run_test "DTLS reassembly: no fragmentation (gnutls server)" \
+ "$G_SRV -u --mtu 2048 -a" \
+ "$P_CLI dtls=1 debug_level=2" \
+ 0 \
+ -C "found fragmented DTLS handshake message" \
+ -C "error"
+
+requires_gnutls
+run_test "DTLS reassembly: some fragmentation (gnutls server)" \
+ "$G_SRV -u --mtu 512" \
+ "$P_CLI dtls=1 debug_level=2" \
+ 0 \
+ -c "found fragmented DTLS handshake message" \
+ -C "error"
+
+requires_gnutls
+run_test "DTLS reassembly: more fragmentation (gnutls server)" \
+ "$G_SRV -u --mtu 128" \
+ "$P_CLI dtls=1 debug_level=2" \
+ 0 \
+ -c "found fragmented DTLS handshake message" \
+ -C "error"
+
+requires_gnutls
+run_test "DTLS reassembly: more fragmentation, nbio (gnutls server)" \
+ "$G_SRV -u --mtu 128" \
+ "$P_CLI dtls=1 nbio=2 debug_level=2" \
+ 0 \
+ -c "found fragmented DTLS handshake message" \
+ -C "error"
+
# Final report
echo "------------------------------------------------------------------------"