test_suite_ssl: Introduced hrr_reject_unadvertised_group

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
This commit is contained in:
Minos Galanakis 2026-04-23 13:53:40 +01:00
parent 9027620393
commit a9a8385747
2 changed files with 80 additions and 0 deletions

View File

@ -3347,6 +3347,9 @@ cookie_parsing:"16fefd0000000000000000002F010000de000000000000011efefd7b72727272
TLS 1.3 srv Certificate msg - wrong vector lengths
tls13_server_certificate_msg_invalid_vector_len
TLS 1.3 cli rejects HRR selected_group not in original supported_groups
hrr_reject_unadvertised_group
EC-JPAKE set password
depends_on:MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED
ssl_ecjpake_set_password:0

View File

@ -3995,6 +3995,83 @@ exit:
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_SSL_PROTO_TLS1_3:MBEDTLS_SSL_CLI_C:MBEDTLS_SSL_SRV_C:MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED:PSA_WANT_ALG_ECDH:PSA_WANT_ECC_SECP_R1_256:PSA_WANT_ECC_SECP_R1_384 */
void hrr_reject_unadvertised_group(void)
{
int ret = -1;
mbedtls_test_ssl_endpoint client_ep, server_ep;
mbedtls_test_handshake_test_options client_options, server_options;
uint16_t offered_group_before_hrr_parse = 0;
uint16_t offered_group_after_hrr_parse = 0;
/* Group order is intentional: client offers secp256r1 first, while server only
* accepts secp384r1. This prevents immediate group agreement and forces HRR. */
uint16_t client_group_list[] = {
MBEDTLS_SSL_IANA_TLS_GROUP_SECP256R1,
MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1,
MBEDTLS_SSL_IANA_TLS_GROUP_NONE
};
uint16_t server_group_list[] = { MBEDTLS_SSL_IANA_TLS_GROUP_SECP384R1,
MBEDTLS_SSL_IANA_TLS_GROUP_NONE };
memset(&client_ep, 0, sizeof(client_ep));
memset(&server_ep, 0, sizeof(server_ep));
mbedtls_test_init_handshake_options(&client_options);
mbedtls_test_init_handshake_options(&server_options);
MD_OR_USE_PSA_INIT();
client_options.pk_alg = MBEDTLS_PK_ECDSA;
client_options.client_min_version = MBEDTLS_SSL_VERSION_TLS1_3;
client_options.client_max_version = MBEDTLS_SSL_VERSION_TLS1_3;
client_options.group_list = client_group_list;
server_options.pk_alg = MBEDTLS_PK_ECDSA;
server_options.server_min_version = MBEDTLS_SSL_VERSION_TLS1_3;
server_options.server_max_version = MBEDTLS_SSL_VERSION_TLS1_3;
server_options.group_list = server_group_list;
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&client_ep, MBEDTLS_SSL_IS_CLIENT,
&client_options), 0);
TEST_EQUAL(mbedtls_test_ssl_endpoint_init(&server_ep, MBEDTLS_SSL_IS_SERVER,
&server_options), 0);
TEST_EQUAL(mbedtls_test_mock_socket_connect(&(client_ep.socket),
&(server_ep.socket), 4096), 0);
ret = mbedtls_test_move_handshake_to_state(
&(server_ep.ssl), &(client_ep.ssl),
MBEDTLS_SSL_HELLO_RETRY_REQUEST);
TEST_EQUAL(ret, 0);
server_ep.ssl.handshake->hrr_selected_group = MBEDTLS_SSL_IANA_TLS_GROUP_X25519;
TEST_EQUAL(mbedtls_ssl_handshake_step(&(server_ep.ssl)), 0);
/* Push the HRR with unadvertised group into the wire*/
TEST_EQUAL(mbedtls_ssl_flush_output(&(server_ep.ssl)), 0);
offered_group_before_hrr_parse = client_ep.ssl.handshake->offered_group_id;
/* Client should reject malformed selected_group with illegal_parameter. */
TEST_EQUAL(mbedtls_ssl_handshake_step(&(client_ep.ssl)), MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER);
/* The server send a non advertised group during HRR. Client shouldnt accept it as offered_group_id */
offered_group_after_hrr_parse = client_ep.ssl.handshake->offered_group_id;
TEST_EQUAL(offered_group_after_hrr_parse, offered_group_before_hrr_parse);
exit:
mbedtls_test_ssl_endpoint_free(&client_ep);
mbedtls_test_ssl_endpoint_free(&server_ep);
mbedtls_test_free_handshake_options(&client_options);
mbedtls_test_free_handshake_options(&server_options);
MD_OR_USE_PSA_DONE();
}
/* END_CASE */
/* BEGIN_CASE depends_on:MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */
void ssl_ecjpake_set_password(int use_opaque_arg)
{