SSL Test and Benchmark now handle missing POLARSSL_TIMING_C
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index 7c73e61..c33f5b5 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -53,6 +53,7 @@
#define BUFSIZE 1024
#define HEADER_FORMAT " %-15s : "
+#if defined(POLARSSL_TIMING_C)
static int myrand( void *rng_state, unsigned char *output, size_t len )
{
size_t use_len;
@@ -77,6 +78,7 @@
}
unsigned char buf[BUFSIZE];
+#endif
#if !defined(POLARSSL_TIMING_C)
int main( int argc, char *argv[] )
diff --git a/programs/test/ssl_test.c b/programs/test/ssl_test.c
index 420484b..607b092 100644
--- a/programs/test/ssl_test.c
+++ b/programs/test/ssl_test.c
@@ -37,8 +37,10 @@
#include "polarssl/ssl.h"
#include "polarssl/entropy.h"
#include "polarssl/ctr_drbg.h"
-#include "polarssl/timing.h"
#include "polarssl/certs.h"
+#if defined(POLARSSL_TIMING_C)
+#include "polarssl/timing.h"
+#endif
#define OPMODE_NONE 0
#define OPMODE_CLIENT 1
@@ -80,7 +82,9 @@
int buffer_size; /* size of the send/receive buffer */
int max_bytes; /* max. # of bytes before a reconnect */
int debug_level; /* level of debugging */
+#if defined(POLARSSL_TIMING_C)
int conn_timeout; /* max. delay before a reconnect */
+#endif
int max_connections; /* max. number of reconnections */
int session_reuse; /* flag to reuse the keying material */
int session_lifetime; /* if reached, session data is expired */
@@ -155,7 +159,9 @@
const char *pers = "ssl_test";
+#if defined(POLARSSL_TIMING_C)
struct hr_time t;
+#endif
entropy_context entropy;
ctr_drbg_context ctr_drbg;
ssl_context ssl;
@@ -173,7 +179,9 @@
goto exit;
}
+#if defined(POLARSSL_TIMING_C)
get_timer( &t, 1 );
+#endif
memset( read_state, 0, sizeof( read_state ) );
memset( write_state, 0, sizeof( write_state ) );
@@ -373,9 +381,11 @@
opt->max_bytes <= nb_written ) )
break;
+#if defined(POLARSSL_TIMING_C)
if( opt->conn_timeout != 0 &&
opt->conn_timeout <= (int) get_timer( &t, 0 ) )
break;
+#endif
}
exit:
@@ -397,6 +407,13 @@
return( ret );
}
+#if defined(POLARSSL_TIMING_C)
+#define USAGE_TIMING \
+ " conn_timeout=%%d (ms) default: 0 (no timeout)\n"
+#else
+#define USAGE_TIMING ""
+#endif
+
#define USAGE \
"\n usage: ssl_test opmode=<> command=<>...\n" \
"\n acceptable parameters:\n" \
@@ -408,7 +425,7 @@
" buffer_size=%%d (bytes) default: 1024\n" \
" max_bytes=%%d (bytes) default: 0 (no limit)\n" \
" debug_level=%%d default: 0 (disabled)\n" \
- " conn_timeout=%%d (ms) default: 0 (no timeout)\n" \
+ USAGE_TIMING \
" max_connections=%%d default: 0 (no limit)\n" \
" session_reuse=on/off default: on (enabled)\n" \
" session_lifetime=%%d (s) default: 86400\n" \
@@ -428,7 +445,7 @@
{
usage:
printf( USAGE );
-
+
list = ssl_list_ciphersuites();
while( *list )
{
@@ -447,7 +464,9 @@
opt.buffer_size = DFL_BUFFER_SIZE;
opt.max_bytes = DFL_MAX_BYTES;
opt.debug_level = DFL_DEBUG_LEVEL;
+#if defined(POLARSSL_TIMING_C)
opt.conn_timeout = DFL_CONN_TIMEOUT;
+#endif
opt.max_connections = DFL_MAX_CONNECTIONS;
opt.session_reuse = DFL_SESSION_REUSE;
opt.session_lifetime = DFL_SESSION_LIFETIME;
@@ -526,10 +545,10 @@
if( strcmp( p, "debug_level" ) == 0 )
opt.debug_level = atoi( q );
-
+#if defined(POLARSSL_TIMING_C)
if( strcmp( p, "conn_timeout" ) == 0 )
opt.conn_timeout = atoi( q );
-
+#endif
if( strcmp( p, "max_connections" ) == 0 )
opt.max_connections = atoi( q );