Refactor ssl_context_info time printing

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
This commit is contained in:
Andrzej Kurek 2022-02-28 05:51:57 -05:00
parent 388ee8a072
commit 478181d1f3

View File

@ -312,11 +312,11 @@ void print_hex( const uint8_t *b, size_t len,
/* /*
* Print the value of time_t in format e.g. 2020-01-23 13:05:59 * 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 uint64_t *time )
void print_time( const time_t *time )
{ {
#if defined(MBEDTLS_HAVE_TIME)
char buf[20]; char buf[20];
struct tm *t = gmtime( time ); struct tm *t = gmtime( (time_t*) time );
static const char format[] = "%Y-%m-%d %H:%M:%S"; static const char format[] = "%Y-%m-%d %H:%M:%S";
if( NULL != t ) if( NULL != t )
{ {
@ -327,8 +327,11 @@ void print_time( const time_t *time )
{ {
printf( "unknown\n" ); printf( "unknown\n" );
} }
} #else
(void) time;
printf( "not supported\n" );
#endif #endif
}
/* /*
* Print the input string if the bit is set in the value * Print the input string if the bit is set in the value
@ -613,12 +616,7 @@ void print_deserialized_ssl_session( const uint8_t *ssl, uint32_t len,
( (uint64_t) ssl[7] ); ( (uint64_t) ssl[7] );
ssl += 8; ssl += 8;
printf( "\tstart time : " ); printf( "\tstart time : " );
#if defined(MBEDTLS_HAVE_TIME) print_time( &start );
print_time( (time_t*) &start );
#else
(void) start;
printf( "not supported\n" );
#endif
} }
CHECK_SSL_END( 2 ); CHECK_SSL_END( 2 );