Skip to content

Commit

Permalink
Fix compile errors when MBEDTLS_HAVE_TIME is not defined
Browse files Browse the repository at this point in the history
Signed-off-by: Raoul Strackx <[email protected]>
[dja: add some more fixes]
Signed-off-by: Daniel Axtens <[email protected]>
  • Loading branch information
raoulstrackx authored and daxtens committed Sep 2, 2020
1 parent 3bd69b9 commit 67f45a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion programs/ssl/ssl_client2.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,12 +671,13 @@ static void my_debug( void *ctx, int level,
fflush( (FILE *) ctx );
}


#if defined(MBEDTLS_HAVE_TIME)
mbedtls_time_t dummy_constant_time( mbedtls_time_t* time )
{
(void) time;
return 0x5af2a056;
}
#endif

int dummy_entropy( void *data, unsigned char *output, size_t len )
{
Expand Down
9 changes: 9 additions & 0 deletions programs/ssl/ssl_context_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ int main( void )
#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"
Expand Down Expand Up @@ -300,6 +302,7 @@ 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
*/
#if defined(MBEDTLS_HAVE_TIME)
void print_time( const time_t *time )
{
char buf[20];
Expand All @@ -315,6 +318,7 @@ void print_time( const time_t *time )
printf( "unknown\n" );
}
}
#endif

/*
* Print the input string if the bit is set in the value
Expand Down Expand Up @@ -598,7 +602,12 @@ void print_deserialized_ssl_session( const uint8_t *ssl, uint32_t len,
( (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 );
Expand Down
4 changes: 4 additions & 0 deletions programs/ssl/ssl_server2.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,13 @@ static void my_debug( void *ctx, int level,
fflush( (FILE *) ctx );
}

#if defined(MBEDTLS_HAVE_TIME)
mbedtls_time_t dummy_constant_time( mbedtls_time_t* time )
{
(void) time;
return 0x5af2a056;
}
#endif

int dummy_entropy( void *data, unsigned char *output, size_t len )
{
Expand Down Expand Up @@ -3107,8 +3109,10 @@ int main( int argc, char *argv[] )
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,
Expand Down

0 comments on commit 67f45a7

Please sign in to comment.