tests: ssl: Add hostname checks in session serialization tests

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
Ronald Cron 2024-03-27 09:30:13 +01:00
parent 1fb585492d
commit 346b81877d
2 changed files with 14 additions and 0 deletions

View File

@ -1831,6 +1831,14 @@ int mbedtls_test_ssl_tls13_populate_session(mbedtls_ssl_session *session,
}
memset(session->ticket, 33, ticket_len);
}
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
char hostname[] = "hostname example";
session->hostname = mbedtls_calloc(1, sizeof(hostname));
if (session->hostname == NULL) {
return -1;
}
memcpy(session->hostname, hostname, sizeof(hostname));
#endif
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
}
#endif /* MBEDTLS_SSL_CLI_C */

View File

@ -2134,6 +2134,12 @@ void ssl_serialize_session_save_load(int ticket_len, char *crt_file,
restored.ticket,
original.ticket_len) == 0);
}
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
TEST_ASSERT(original.hostname != NULL);
TEST_ASSERT(restored.hostname != NULL);
TEST_MEMORY_COMPARE(original.hostname, strlen(original.hostname),
restored.hostname, strlen(restored.hostname));
#endif
#endif /* MBEDTLS_SSL_SESSION_TICKETS */
}
#endif /* MBEDTLS_SSL_CLI_C */