fix build failure
Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c
index 0277bfa..61c87be 100644
--- a/library/ssl_ticket.c
+++ b/library/ssl_ticket.c
@@ -498,7 +498,18 @@
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
if (session->tls_version == MBEDTLS_SSL_VERSION_TLS1_3) {
/* Check for expiration */
- mbedtls_ms_time_t ticket_age = mbedtls_ms_time() - session->ticket_creation_time;
+ mbedtls_ms_time_t ticket_age = -1;
+#if defined(MBEDTLS_SSL_SRV_C)
+ if (session->endpoint == MBEDTLS_SSL_IS_SERVER) {
+ ticket_age = mbedtls_ms_time() - session->ticket_creation_time;
+ }
+#endif
+#if defined(MBEDTLS_SSL_CLI_C)
+ if (session->endpoint == MBEDTLS_SSL_IS_CLIENT) {
+ ticket_age = mbedtls_ms_time() - session->ticket_reception_time;
+ }
+#endif
+
mbedtls_ms_time_t ticket_lifetime = ctx->ticket_lifetime * 1000;
if (ticket_age < 0 || ticket_age > ticket_lifetime) {
diff --git a/tests/src/test_helpers/ssl_helpers.c b/tests/src/test_helpers/ssl_helpers.c
index dd06d17..d02d305 100644
--- a/tests/src/test_helpers/ssl_helpers.c
+++ b/tests/src/test_helpers/ssl_helpers.c
@@ -1752,7 +1752,7 @@
session->max_early_data_size = 0x87654321;
#endif
-#if defined(MBEDTLS_HAVE_TIME)
+#if defined(MBEDTLS_HAVE_TIME) && defined(MBEDTLS_SSL_SRV_C)
if (session->endpoint == MBEDTLS_SSL_IS_SERVER) {
session->ticket_creation_time = mbedtls_ms_time() - 42;
}