Skip to content

Commit

Permalink
tests: ssl: Add hostname checks in session serialization tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
  • Loading branch information
ronald-cron-arm committed Mar 27, 2024
1 parent ad0ee1a commit 8d15e01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/src/test_helpers/ssl_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 6 additions & 0 deletions tests/suites/test_suite_ssl.function
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 8d15e01

Please sign in to comment.