@@ -103,12 +103,14 @@ if [ -n "${OPENSSL_NEXT:-}" ]; then
103
103
O_NEXT_SRV_NO_CERT="$OPENSSL_NEXT s_server -www "
104
104
O_NEXT_CLI="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client -CAfile $DATA_FILES_PATH/test-ca_cat12.crt"
105
105
O_NEXT_CLI_NO_CERT="echo 'GET / HTTP/1.0' | $OPENSSL_NEXT s_client"
106
+ O_NEXT_CLI_RENEGOTIATE="echo 'R' | $OPENSSL_NEXT s_client -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key"
106
107
else
107
108
O_NEXT_SRV=false
108
109
O_NEXT_SRV_NO_CERT=false
109
110
O_NEXT_SRV_EARLY_DATA=false
110
111
O_NEXT_CLI_NO_CERT=false
111
112
O_NEXT_CLI=false
113
+ O_NEXT_CLI_RENEGOTIATE=false
112
114
fi
113
115
114
116
if [ -n "${GNUTLS_NEXT_SERV:-}" ]; then
@@ -13711,14 +13713,173 @@ run_test "TLS 1.2 ClientHello indicating support for deflate compression meth
13711
13713
13712
13714
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13713
13715
requires_certificate_authentication
13714
- run_test "Handshake defragmentation on server: len=32, TLS 1.2 ClientHello" \
13716
+ run_test "Handshake defragmentation on server: len=32, TLS 1.2 ClientHello (unsupported) " \
13715
13717
"$P_SRV debug_level=4 force_version=tls12 auth_mode=required" \
13716
13718
"$O_NEXT_CLI -tls1_2 -split_send_frag 32 -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key" \
13717
13719
1 \
13718
13720
-s "The SSL configuration is tls12 only" \
13719
13721
-s "bad client hello message" \
13720
13722
-s "SSL - A message could not be parsed due to a syntactic error"
13721
13723
13724
+ # Test server-side buffer resizing with fragmented handshake on TLS1.2
13725
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13726
+ requires_config_enabled MBEDTLS_SSL_MAX_FRAGMENT_LENGTH
13727
+ requires_config_enabled MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH
13728
+ requires_max_content_len 1025
13729
+ run_test "Handshake defragmentation on server: len=256, buffer resizing with MFL=1024" \
13730
+ "$P_SRV debug_level=4 auth_mode=required" \
13731
+ "$O_NEXT_CLI -tls1_2 -split_send_frag 256 -maxfraglen 1024 -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key" \
13732
+ 0 \
13733
+ -s "Reallocating in_buf" \
13734
+ -s "Reallocating out_buf" \
13735
+ -s "reassembled record" \
13736
+ -s "initial handshake fragment: 256, 0\\.\\.256 of [0-9]\\+" \
13737
+ -s "Prepare: waiting for more handshake fragments 256/" \
13738
+ -s "Consume: waiting for more handshake fragments 256/"
13739
+
13740
+ # Test client-initiated renegotiation with fragmented handshake on TLS1.2
13741
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13742
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13743
+ run_test "Handshake defragmentation on server: len=512, client-initiated renegotiation" \
13744
+ "$P_SRV debug_level=4 exchanges=2 renegotiation=1 auth_mode=required" \
13745
+ "$O_NEXT_CLI_RENEGOTIATE -tls1_2 -split_send_frag 512 -connect 127.0.0.1:+$SRV_PORT" \
13746
+ 0 \
13747
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
13748
+ -s "found renegotiation extension" \
13749
+ -s "server hello, secure renegotiation extension" \
13750
+ -s "=> renegotiate" \
13751
+ -S "write hello request" \
13752
+ -s "reassembled record" \
13753
+ -s "initial handshake fragment: 512, 0\\.\\.512 of [0-9]\\+" \
13754
+ -s "Prepare: waiting for more handshake fragments 512/" \
13755
+ -s "Consume: waiting for more handshake fragments 512/" \
13756
+
13757
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13758
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13759
+ run_test "Handshake defragmentation on server: len=256, client-initiated renegotiation" \
13760
+ "$P_SRV debug_level=4 exchanges=2 renegotiation=1 auth_mode=required" \
13761
+ "$O_NEXT_CLI_RENEGOTIATE -tls1_2 -split_send_frag 256 -connect 127.0.0.1:+$SRV_PORT" \
13762
+ 0 \
13763
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
13764
+ -s "found renegotiation extension" \
13765
+ -s "server hello, secure renegotiation extension" \
13766
+ -s "=> renegotiate" \
13767
+ -S "write hello request" \
13768
+ -s "reassembled record" \
13769
+ -s "initial handshake fragment: 256, 0\\.\\.256 of [0-9]\\+" \
13770
+ -s "Prepare: waiting for more handshake fragments 256/" \
13771
+ -s "Consume: waiting for more handshake fragments 256/" \
13772
+
13773
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13774
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3
13775
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13776
+ run_test "Handshake defragmentation on server: len=128, client-initiated renegotiation" \
13777
+ "$P_SRV debug_level=4 exchanges=2 renegotiation=1 auth_mode=required" \
13778
+ "$O_NEXT_CLI_RENEGOTIATE -tls1_2 -split_send_frag 128 -connect 127.0.0.1:+$SRV_PORT" \
13779
+ 0 \
13780
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
13781
+ -s "found renegotiation extension" \
13782
+ -s "server hello, secure renegotiation extension" \
13783
+ -s "=> renegotiate" \
13784
+ -S "write hello request" \
13785
+ -s "reassembled record" \
13786
+ -s "initial handshake fragment: 128, 0\\.\\.128 of [0-9]\\+" \
13787
+ -s "Prepare: waiting for more handshake fragments 128/" \
13788
+ -s "Consume: waiting for more handshake fragments 128/" \
13789
+
13790
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13791
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3
13792
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13793
+ run_test "Handshake defragmentation on server: len=4, client-initiated renegotiation" \
13794
+ "$P_SRV debug_level=4 exchanges=2 renegotiation=1 auth_mode=required" \
13795
+ "$O_NEXT_CLI_RENEGOTIATE -tls1_2 -split_send_frag 4 -connect 127.0.0.1:+$SRV_PORT" \
13796
+ 0 \
13797
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
13798
+ -s "found renegotiation extension" \
13799
+ -s "server hello, secure renegotiation extension" \
13800
+ -s "=> renegotiate" \
13801
+ -S "write hello request" \
13802
+ -s "reassembled record" \
13803
+ -s "initial handshake fragment: 4, 0\\.\\.4 of [0-9]\\+" \
13804
+ -s "Prepare: waiting for more handshake fragments 4/" \
13805
+ -s "Consume: waiting for more handshake fragments 4/" \
13806
+
13807
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13808
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_3
13809
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13810
+ run_test "Handshake defragmentation on server: len=4, client-initiated server-rejected renegotiation" \
13811
+ "$P_SRV debug_level=4 exchanges=2 renegotiation=0 auth_mode=required" \
13812
+ "$O_NEXT_CLI_RENEGOTIATE -tls1_2 -split_send_frag 4 -connect 127.0.0.1:+$SRV_PORT" \
13813
+ 1 \
13814
+ -s "received TLS_EMPTY_RENEGOTIATION_INFO" \
13815
+ -s "refusing renegotiation, sending alert" \
13816
+ -s "server hello, secure renegotiation extension" \
13817
+ -s "initial handshake fragment: 4, 0\\.\\.4 of [0-9]\\+" \
13818
+ -s "Prepare: waiting for more handshake fragments 4/" \
13819
+ -s "Consume: waiting for more handshake fragments 4/" \
13820
+
13821
+ # Test server-initiated renegotiation with fragmented handshake on TLS1.2
13822
+
13823
+ # Note: The /reneg endpoint serves as a directive for OpenSSL's s_server
13824
+ # to initiate a handshake renegotiation.
13825
+ # Note: Adjusting the renegotiation delay beyond the library's default
13826
+ # value of 16 is necessary. This parameter defines the maximum
13827
+ # number of records received before renegotiation is completed.
13828
+ # By fragmenting records and thereby increasing their quantity,
13829
+ # the default threshold can be reached more quickly.
13830
+ # Setting it to -1 disables that policy's enforment.
13831
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13832
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13833
+ run_test "Handshake defragmentation on client: len=512, server-initiated renegotiation" \
13834
+ "$O_NEXT_SRV -tls1_2 -split_send_frag 512 -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key" \
13835
+ "$P_CLI debug_level=3 renegotiation=1 request_page=/reneg" \
13836
+ 0 \
13837
+ -c "initial handshake fragment: 512, 0\\.\\.512 of [0-9]\\+" \
13838
+ -c "Prepare: waiting for more handshake fragments 512/" \
13839
+ -c "Consume: waiting for more handshake fragments 512/" \
13840
+ -c "client hello, adding renegotiation extension" \
13841
+ -c "found renegotiation extension" \
13842
+ -c "=> renegotiate"
13843
+
13844
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13845
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13846
+ run_test "Handshake defragmentation on client: len=256, server-initiated renegotiation" \
13847
+ "$O_NEXT_SRV -tls1_2 -split_send_frag 256 -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key" \
13848
+ "$P_CLI debug_level=3 renegotiation=1 renego_delay=-1 request_page=/reneg" \
13849
+ 0 \
13850
+ -c "initial handshake fragment: 256, 0\\.\\.256 of [0-9]\\+" \
13851
+ -c "Prepare: waiting for more handshake fragments 256/" \
13852
+ -c "Consume: waiting for more handshake fragments 256/" \
13853
+ -c "client hello, adding renegotiation extension" \
13854
+ -c "found renegotiation extension" \
13855
+ -c "=> renegotiate"
13856
+
13857
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13858
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13859
+ run_test "Handshake defragmentation on client: len=128, server-initiated renegotiation" \
13860
+ "$O_NEXT_SRV -tls1_2 -split_send_frag 128 -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key" \
13861
+ "$P_CLI debug_level=3 renegotiation=1 renego_delay=-1 request_page=/reneg" \
13862
+ 0 \
13863
+ -c "initial handshake fragment: 128, 0\\.\\.128 of [0-9]\\+" \
13864
+ -c "Prepare: waiting for more handshake fragments 128/" \
13865
+ -c "Consume: waiting for more handshake fragments 128/" \
13866
+ -c "client hello, adding renegotiation extension" \
13867
+ -c "found renegotiation extension" \
13868
+ -c "=> renegotiate"
13869
+
13870
+ requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13871
+ requires_config_enabled MBEDTLS_SSL_RENEGOTIATION
13872
+ run_test "Handshake defragmentation on client: len=4, server-initiated renegotiation" \
13873
+ "$O_NEXT_SRV -tls1_2 -split_send_frag 4 -cert $DATA_FILES_PATH/server5.crt -key $DATA_FILES_PATH/server5.key" \
13874
+ "$P_CLI debug_level=3 renegotiation=1 renego_delay=-1 request_page=/reneg" \
13875
+ 0 \
13876
+ -c "initial handshake fragment: 4, 0\\.\\.4 of [0-9]\\+" \
13877
+ -c "Prepare: waiting for more handshake fragments 4/" \
13878
+ -c "Consume: waiting for more handshake fragments 4/" \
13879
+ -c "client hello, adding renegotiation extension" \
13880
+ -c "found renegotiation extension" \
13881
+ -c "=> renegotiate"
13882
+
13722
13883
# Test heap memory usage after handshake
13723
13884
requires_config_enabled MBEDTLS_SSL_PROTO_TLS1_2
13724
13885
requires_config_enabled MBEDTLS_MEMORY_DEBUG
0 commit comments