49
49
#define MAX_CIPHER_SUITE_COUNT (CIPHER_SUITES_MAX_LENGTH / S2N_TLS_CIPHER_SUITE_LEN)
50
50
/* Drop 150 cipher suites from max, so that the total handshake message length won't exceed 64KB */
51
51
#define REDUCED_CIPHER_SUITE_COUNT (MAX_CIPHER_SUITE_COUNT - NUM_OF_CIPHER_SUITES_TO_DROP)
52
- /* Reducing cipher suites by 150 creates approximately 300 bytes margin below maximum handshake length */
53
- #define ESTIMATED_MAX_HANDSHAKE_LENGTH_MARGIN (NUM_OF_CIPHER_SUITES_TO_DROP * S2N_TLS_CIPHER_SUITE_LEN)
54
52
55
53
int s2n_parse_client_hello (struct s2n_connection * conn );
56
54
S2N_RESULT s2n_client_hello_get_raw_extension (uint16_t extension_iana ,
@@ -1963,9 +1961,6 @@ int main(int argc, char **argv)
1963
1961
1964
1962
/* Test: Client Hello is slightly less than 64KB */
1965
1963
{
1966
- DEFER_CLEANUP (struct s2n_config * client_config = s2n_config_new (), s2n_config_ptr_free );
1967
- EXPECT_NOT_NULL (client_config );
1968
-
1969
1964
DEFER_CLEANUP (struct s2n_config * server_config = s2n_config_new (), s2n_config_ptr_free );
1970
1965
EXPECT_NOT_NULL (server_config );
1971
1966
@@ -1982,23 +1977,16 @@ int main(int argc, char **argv)
1982
1977
.suites = test_cipher_suites ,
1983
1978
};
1984
1979
1985
- struct s2n_security_policy test_security_policy = {
1986
- .minimum_protocol_version = S2N_TLS12 ,
1987
- .cipher_preferences = & test_cipher_suites_preferences ,
1988
- .kem_preferences = & kem_preferences_null ,
1989
- .signature_preferences = & s2n_signature_preferences_20240501 ,
1990
- .ecc_preferences = & s2n_ecc_preferences_20240501 ,
1991
- .rules = {
1992
- [S2N_PERFECT_FORWARD_SECRECY ] = true,
1993
- },
1994
- };
1980
+ const struct s2n_security_policy * default_policy = NULL ;
1981
+ EXPECT_SUCCESS (s2n_find_security_policy_from_version ("default" , & default_policy ));
1995
1982
1996
- EXPECT_SUCCESS (s2n_config_disable_x509_verification (client_config ));
1983
+ /* Use default security policy but with custom cipher suites preferences */
1984
+ struct s2n_security_policy test_security_policy = * default_policy ;
1985
+ test_security_policy .cipher_preferences = & test_cipher_suites_preferences ;
1997
1986
1998
1987
DEFER_CLEANUP (struct s2n_connection * client = s2n_connection_new (S2N_CLIENT ),
1999
1988
s2n_connection_ptr_free );
2000
1989
EXPECT_NOT_NULL (client );
2001
- EXPECT_SUCCESS (s2n_connection_set_config (client , client_config ));
2002
1990
EXPECT_SUCCESS (s2n_connection_set_blinding (client , S2N_SELF_SERVICE_BLINDING ));
2003
1991
client -> security_policy_override = & test_security_policy ;
2004
1992
@@ -2015,22 +2003,15 @@ int main(int argc, char **argv)
2015
2003
2016
2004
EXPECT_OK (s2n_negotiate_test_server_and_client_until_message (server , client , SERVER_HELLO ));
2017
2005
2018
- /* handshake.io shouldn't be tainted after sending and receiving large client hello */
2019
- EXPECT_TRUE (client -> handshake .io .tainted == 0 );
2020
- EXPECT_TRUE (server -> handshake .io .tainted == 0 );
2021
-
2022
2006
struct s2n_client_hello * client_hello = s2n_connection_get_client_hello (server );
2023
2007
EXPECT_NOT_NULL (client_hello );
2024
- uint32_t handshake_max_len_margin = S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH - s2n_client_hello_get_raw_message_length ( client_hello );
2025
- /* Size of Client Hello is less than 300 bytes from the maximum handshake length */
2026
- EXPECT_TRUE (handshake_max_len_margin < ESTIMATED_MAX_HANDSHAKE_LENGTH_MARGIN );
2008
+
2009
+ /* Size of Client Hello should be less than S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH */
2010
+ EXPECT_TRUE (s2n_client_hello_get_raw_message_length ( client_hello ) < S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH );
2027
2011
}
2028
2012
2029
2013
/* Test: Client Hello is larger than 64KB */
2030
2014
{
2031
- DEFER_CLEANUP (struct s2n_config * client_config = s2n_config_new (), s2n_config_ptr_free );
2032
- EXPECT_NOT_NULL (client_config );
2033
-
2034
2015
DEFER_CLEANUP (struct s2n_config * server_config = s2n_config_new (), s2n_config_ptr_free );
2035
2016
EXPECT_NOT_NULL (server_config );
2036
2017
@@ -2048,23 +2029,16 @@ int main(int argc, char **argv)
2048
2029
.suites = test_cipher_suites ,
2049
2030
};
2050
2031
2051
- struct s2n_security_policy test_security_policy = {
2052
- .minimum_protocol_version = S2N_TLS12 ,
2053
- .cipher_preferences = & test_cipher_suites_preferences ,
2054
- .kem_preferences = & kem_preferences_null ,
2055
- .signature_preferences = & s2n_signature_preferences_20240501 ,
2056
- .ecc_preferences = & s2n_ecc_preferences_20240501 ,
2057
- .rules = {
2058
- [S2N_PERFECT_FORWARD_SECRECY ] = true,
2059
- },
2060
- };
2032
+ const struct s2n_security_policy * default_policy = NULL ;
2033
+ EXPECT_SUCCESS (s2n_find_security_policy_from_version ("default" , & default_policy ));
2061
2034
2062
- EXPECT_SUCCESS (s2n_config_disable_x509_verification (client_config ));
2035
+ /* Use default security policy but with custom cipher suites preferences */
2036
+ struct s2n_security_policy test_security_policy = * default_policy ;
2037
+ test_security_policy .cipher_preferences = & test_cipher_suites_preferences ;
2063
2038
2064
2039
DEFER_CLEANUP (struct s2n_connection * client = s2n_connection_new (S2N_CLIENT ),
2065
2040
s2n_connection_ptr_free );
2066
2041
EXPECT_NOT_NULL (client );
2067
- EXPECT_SUCCESS (s2n_connection_set_config (client , client_config ));
2068
2042
EXPECT_SUCCESS (s2n_connection_set_blinding (client , S2N_SELF_SERVICE_BLINDING ));
2069
2043
client -> security_policy_override = & test_security_policy ;
2070
2044
@@ -2087,10 +2061,6 @@ int main(int argc, char **argv)
2087
2061
/* The size of Client Hello exceeds S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH */
2088
2062
EXPECT_TRUE (s2n_stuffer_data_available (& io_pair .server_in ) > S2N_MAXIMUM_HANDSHAKE_MESSAGE_LENGTH );
2089
2063
EXPECT_ERROR_WITH_ERRNO (s2n_negotiate_test_server_and_client_until_message (server , client , SERVER_HELLO ), S2N_ERR_BAD_MESSAGE );
2090
-
2091
- /* handshake.io shouldn't be tainted after sending and receiving large client hello */
2092
- EXPECT_TRUE (client -> handshake .io .tainted == 0 );
2093
- EXPECT_TRUE (server -> handshake .io .tainted == 0 );
2094
2064
}
2095
2065
2096
2066
EXPECT_SUCCESS (s2n_cert_chain_and_key_free (chain_and_key ));
0 commit comments