Add small packet tests for DTLS
Add a DTLS small packet test for each of the following combinations:
- DTLS version: 1.0 or 1.2
- Encrypt then MAC extension enabled
- Truncated HMAC extension enabled
Large packets tests for DTLS are currently not possible due to parameter
constraints in ssl_server2.
diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh
index f87a742..364e16c 100755
--- a/tests/ssl-opt.sh
+++ b/tests/ssl-opt.sh
@@ -3151,6 +3151,82 @@
0 \
-s "Read from client: 1 bytes read"
+# Tests for small packets in DTLS
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.0" \
+ "$P_SRV dtls=1 force_version=dtls1" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.0, without EtM" \
+ "$P_SRV dtls=1 force_version=dtls1 etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.0, truncated hmac" \
+ "$P_SRV dtls=1 force_version=dtls1" \
+ "$P_CLI dtls=1 request_size=1 trunc_hmac=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.0, without EtM, truncated MAC" \
+ "$P_SRV dtls=1 force_version=dtls1 \
+ etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
+ trunc_hmac=1"\
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.2" \
+ "$P_SRV dtls=1 force_version=dtls1_2" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+run_test "Small packet DTLS 1.2, without EtM" \
+ "$P_SRV dtls=1 force_version=dtls1_2 \
+ etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.2, truncated hmac" \
+ "$P_SRV dtls=1 force_version=dtls1_2" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
+ trunc_hmac=1" \
+ 0 \
+ -s "Read from client: 1 bytes read"
+
+requires_config_enabled MBEDTLS_SSL_PROTO_DTLS
+requires_config_enabled MBEDTLS_SSL_TRUNCATED_HMAC
+run_test "Small packet DTLS 1.2, without EtM, truncated MAC" \
+ "$P_SRV dtls=1 force_version=dtls1_2 \
+ etm=0" \
+ "$P_CLI dtls=1 request_size=1 \
+ force_ciphersuite=TLS-RSA-WITH-AES-256-CBC-SHA \
+ trunc_hmac=1"\
+ 0 \
+ -s "Read from client: 1 bytes read"
+
# A test for extensions in SSLv3
requires_config_enabled MBEDTLS_SSL_PROTO_SSL3