programs/ssl: Fix compile errors when MBEDTLS_HAVE_TIME is not defined

Signed-off-by: Raoul Strackx <raoul.strackx@fortanix.com>
[dja: add some more fixes, tweak title]
Signed-off-by: Daniel Axtens <dja@axtens.net>
diff --git a/programs/ssl/ssl_context_info.c b/programs/ssl/ssl_context_info.c
index 7018080..349e755 100644
--- a/programs/ssl/ssl_context_info.c
+++ b/programs/ssl/ssl_context_info.c
@@ -44,7 +44,9 @@
 #include <stdint.h>
 #include <stdarg.h>
 #include <string.h>
+#if defined(MBEDTLS_HAVE_TIME)
 #include <time.h>
+#endif
 #include "mbedtls/ssl.h"
 #include "mbedtls/error.h"
 #include "mbedtls/base64.h"
@@ -310,6 +312,7 @@
 /*
  *  Print the value of time_t in format e.g. 2020-01-23 13:05:59
  */
+#if defined(MBEDTLS_HAVE_TIME)
 void print_time( const time_t *time )
 {
     char buf[20];
@@ -325,6 +328,7 @@
         printf( "unknown\n" );
     }
 }
+#endif
 
 /*
  * Print the input string if the bit is set in the value
@@ -609,7 +613,12 @@
                 ( (uint64_t) ssl[7] );
         ssl += 8;
         printf( "\tstart time     : " );
+#if defined(MBEDTLS_HAVE_TIME)
         print_time( (time_t*) &start );
+#else
+        (void) start;
+        printf( "not supported\n" );
+#endif
     }
 
     CHECK_SSL_END( 2 );
diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c
index 4db64a5..4bf6ef0 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -2705,8 +2705,10 @@
     if( opt.cache_max != -1 )
         mbedtls_ssl_cache_set_max_entries( &cache, opt.cache_max );
 
+#if defined(MBEDTLS_HAVE_TIME)
     if( opt.cache_timeout != -1 )
         mbedtls_ssl_cache_set_timeout( &cache, opt.cache_timeout );
+#endif
 
     mbedtls_ssl_conf_session_cache( &conf, &cache,
                                    mbedtls_ssl_cache_get,
diff --git a/programs/ssl/ssl_test_lib.c b/programs/ssl/ssl_test_lib.c
index 1bb9d61..70cddfa 100644
--- a/programs/ssl/ssl_test_lib.c
+++ b/programs/ssl/ssl_test_lib.c
@@ -44,11 +44,13 @@
     fflush( (FILE *) ctx  );
 }
 
+#if defined(MBEDTLS_HAVE_TIME)
 mbedtls_time_t dummy_constant_time( mbedtls_time_t* time )
 {
     (void) time;
     return 0x5af2a056;
 }
+#endif
 
 #if !defined(MBEDTLS_TEST_USE_PSA_CRYPTO_RNG)
 static int dummy_entropy( void *data, unsigned char *output, size_t len )
diff --git a/programs/ssl/ssl_test_lib.h b/programs/ssl/ssl_test_lib.h
index 98751a0..b1a2408 100644
--- a/programs/ssl/ssl_test_lib.h
+++ b/programs/ssl/ssl_test_lib.h
@@ -138,7 +138,9 @@
                const char *file, int line,
                const char *str );
 
+#if defined(MBEDTLS_HAVE_TIME)
 mbedtls_time_t dummy_constant_time( mbedtls_time_t* time );
+#endif
 
 #if defined(MBEDTLS_USE_PSA_CRYPTO)
 /* If MBEDTLS_TEST_USE_PSA_CRYPTO_RNG is defined, the SSL test programs will use