mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-16 23:29:56 +00:00
library: ssl: rework macro to define known TLS ID <-> group name list
- let the macro be an initializer for the array of known TLS IDs, not a variable declarator; - last item's group name is NULL, not an empty string - change then name of the macro from MBEDTLS_TLS_ID_GROUP_NAME_TABLE to MBEDTLS_SSL_IANA_TLS_GROUPS_INFO - define a new public structure "mbedtls_ssl_iana_tls_group_info_t" to hold each element of the table and that can be used the go over the list from user code. Signed-off-by: Valerio Setti <[email protected]>
This commit is contained in:
@@ -3596,13 +3596,17 @@ exit:;
|
||||
/* BEGIN_CASE */
|
||||
void test_mbedtls_tls_id_group_name_table(int group_id, char *group_name)
|
||||
{
|
||||
MBEDTLS_TLS_ID_GROUP_NAME_TABLE(test_table);
|
||||
mbedtls_ssl_iana_tls_group_info_t test_table[] = MBEDTLS_SSL_IANA_TLS_GROUPS_INFO;
|
||||
mbedtls_ssl_iana_tls_group_info_t *item;
|
||||
const char *table_name = NULL;
|
||||
size_t table_name_len = 0;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_LENGTH(test_table); i++) {
|
||||
if (test_table[i].tls_id == group_id) {
|
||||
table_name = test_table[i].group_name;
|
||||
/* Ensure that the list includes at least 1 valid entry. */
|
||||
TEST_ASSERT(test_table[0].tls_id != MBEDTLS_SSL_IANA_TLS_GROUP_NONE);
|
||||
|
||||
for (item = &test_table[0]; item->tls_id != MBEDTLS_SSL_IANA_TLS_GROUP_NONE; item++) {
|
||||
if (item->tls_id == group_id) {
|
||||
table_name = item->group_name;
|
||||
table_name_len = strlen(table_name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user