tests: ssl: Move min/max TLS version setting to endpoint init

Move min/max TLS version setting to endpoint init
where it fits better: before the call to
mbedtls_ssl_setup() and available for all tests
not only those calling perform_handshake().

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2023-03-09 17:47:42 +01:00
parent 56f59d749c
commit a697a71a14

View File

@ -804,6 +804,28 @@ int mbedtls_test_ssl_endpoint_init(
MBEDTLS_SSL_PRESET_DEFAULT);
TEST_ASSERT(ret == 0);
if (MBEDTLS_SSL_IS_CLIENT == endpoint_type) {
if (options->client_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_min_tls_version(&(ep->conf),
options->client_min_version);
}
if (options->client_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_max_tls_version(&(ep->conf),
options->client_max_version);
}
} else {
if (options->server_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_min_tls_version(&(ep->conf),
options->server_min_version);
}
if (options->server_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_max_tls_version(&(ep->conf),
options->server_max_version);
}
}
if (group_list != NULL) {
mbedtls_ssl_conf_groups(&(ep->conf), group_list);
}
@ -1784,16 +1806,6 @@ void mbedtls_test_ssl_perform_handshake(
NULL, NULL) == 0);
}
if (options->client_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_min_tls_version(&client.conf,
options->client_min_version);
}
if (options->client_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_max_tls_version(&client.conf,
options->client_max_version);
}
if (strlen(options->cipher) > 0) {
set_ciphersuite(&client.conf, options->cipher, forced_ciphersuite);
}
@ -1827,16 +1839,6 @@ void mbedtls_test_ssl_perform_handshake(
mbedtls_ssl_conf_authmode(&server.conf, options->srv_auth_mode);
if (options->server_min_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_min_tls_version(&server.conf,
options->server_min_version);
}
if (options->server_max_version != MBEDTLS_SSL_VERSION_UNKNOWN) {
mbedtls_ssl_conf_max_tls_version(&server.conf,
options->server_max_version);
}
#if defined(MBEDTLS_SSL_MAX_FRAGMENT_LENGTH)
TEST_ASSERT(mbedtls_ssl_conf_max_frag_len(&(server.conf),
(unsigned char) options->mfl)