Remove mbedtls_ssl_conf_dbg() if !MBEDTLS_DEBUG_C

This commit is contained in:
Hanno Becker 2019-07-02 17:00:34 +01:00
parent 272063abfd
commit 14a4a44e60
12 changed files with 42 additions and 6 deletions

View file

@ -1501,6 +1501,7 @@ void mbedtls_ssl_conf_rng_ctx( mbedtls_ssl_config *conf,
void *p_rng ); void *p_rng );
#endif /* MBEDTLS_SSL_CONF_RNG */ #endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_DEBUG_C)
/** /**
* \brief Set the debug callback * \brief Set the debug callback
* *
@ -1518,6 +1519,7 @@ void mbedtls_ssl_conf_rng_ctx( mbedtls_ssl_config *conf,
void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf, void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
void (*f_dbg)(void *, int, const char *, int, const char *), void (*f_dbg)(void *, int, const char *, int, const char *),
void *p_dbg ); void *p_dbg );
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \ #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \ !defined(MBEDTLS_SSL_CONF_SEND) && \

View file

@ -8213,19 +8213,15 @@ void mbedtls_ssl_conf_rng_ctx( mbedtls_ssl_config *conf,
} }
#endif #endif
#if defined(MBEDTLS_DEBUG_C)
void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf, void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
void (*f_dbg)(void *, int, const char *, int, const char *), void (*f_dbg)(void *, int, const char *, int, const char *),
void *p_dbg ) void *p_dbg )
{ {
#if defined(MBEDTLS_DEBUG_C)
conf->f_dbg = f_dbg; conf->f_dbg = f_dbg;
conf->p_dbg = p_dbg; conf->p_dbg = p_dbg;
#else
((void) conf);
((void) f_dbg);
((void) p_dbg);
#endif /* MBEDTLS_DEBUG_C */
} }
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \ #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \ !defined(MBEDTLS_SSL_CONF_SEND) && \

View file

@ -83,6 +83,7 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -92,6 +93,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
@ -191,7 +193,9 @@ int main( int argc, char *argv[] )
mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{ {

View file

@ -92,6 +92,7 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -101,6 +102,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
int main( void ) int main( void )
{ {
@ -223,7 +225,9 @@ int main( void )
} }
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) #if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE)
mbedtls_ssl_conf_session_cache( &conf, &cache, mbedtls_ssl_conf_session_cache( &conf, &cache,

View file

@ -73,6 +73,7 @@ int main( void )
#define DEBUG_LEVEL 1 #define DEBUG_LEVEL 1
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -82,6 +83,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
int main( void ) int main( void )
{ {
@ -178,7 +180,9 @@ int main( void )
mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL ); mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{ {

View file

@ -450,6 +450,7 @@ struct options
int query_config( const char *config ); int query_config( const char *config );
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -465,6 +466,7 @@ static void my_debug( void *ctx, int level,
basename, line, level, str ); basename, line, level, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \ #if !defined(MBEDTLS_SSL_CONF_RECV) && \
@ -1777,7 +1779,9 @@ int main( int argc, char *argv[] )
mbedtls_ssl_conf_rng_ctx( &conf, &ctr_drbg ); mbedtls_ssl_conf_rng_ctx( &conf, &ctr_drbg );
#endif #endif
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if !defined(MBEDTLS_SSL_CONF_READ_TIMEOUT) #if !defined(MBEDTLS_SSL_CONF_READ_TIMEOUT)
mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout ); mbedtls_ssl_conf_read_timeout( &conf, opt.read_timeout );

View file

@ -90,6 +90,7 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -99,6 +100,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
int main( void ) int main( void )
{ {
@ -195,7 +197,9 @@ int main( void )
} }
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL ); mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL );
if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 ) if( ( ret = mbedtls_ssl_conf_own_cert( &conf, &srvcert, &pkey ) ) != 0 )

View file

@ -163,6 +163,7 @@ struct options
int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */ int force_ciphersuite[2]; /* protocol/ciphersuite to use, or all */
} opt; } opt;
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -172,6 +173,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
static int do_handshake( mbedtls_ssl_context *ssl ) static int do_handshake( mbedtls_ssl_context *ssl )
{ {
@ -619,7 +621,9 @@ int main( int argc, char *argv[] )
mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL ); mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER ) if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER )
mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite ); mbedtls_ssl_conf_ciphersuites( &conf, opt.force_ciphersuite );

View file

@ -433,7 +433,9 @@ int main( void )
} }
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_mutexed_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_mutexed_debug, stdout );
#endif
/* mbedtls_ssl_cache_get() and mbedtls_ssl_cache_set() are thread-safe if /* mbedtls_ssl_cache_get() and mbedtls_ssl_cache_set() are thread-safe if
* MBEDTLS_THREADING_C is set. * MBEDTLS_THREADING_C is set.

View file

@ -85,6 +85,7 @@ int main( void )
#define DEBUG_LEVEL 0 #define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -94,6 +95,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
int main( void ) int main( void )
{ {
@ -211,7 +213,9 @@ int main( void )
} }
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE) #if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE)
mbedtls_ssl_conf_session_cache( &conf, &cache, mbedtls_ssl_conf_session_cache( &conf, &cache,

View file

@ -582,6 +582,7 @@ struct options
int query_config( const char *config ); int query_config( const char *config );
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -596,6 +597,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: |%d| %s", basename, line, level, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \ #if !defined(MBEDTLS_SSL_CONF_RECV) && \
@ -2583,7 +2585,9 @@ int main( int argc, char *argv[] )
mbedtls_ssl_conf_rng_ctx( &conf, &ctr_drbg ); mbedtls_ssl_conf_rng_ctx( &conf, &ctr_drbg );
#endif #endif
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if defined(MBEDTLS_SSL_CACHE_C) #if defined(MBEDTLS_SSL_CACHE_C)
if( opt.cache_max != -1 ) if( opt.cache_max != -1 )

View file

@ -117,6 +117,7 @@ struct options
int permissive; /* permissive parsing */ int permissive; /* permissive parsing */
} opt; } opt;
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level, static void my_debug( void *ctx, int level,
const char *file, int line, const char *file, int line,
const char *str ) const char *str )
@ -126,6 +127,7 @@ static void my_debug( void *ctx, int level,
mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str ); mbedtls_fprintf( (FILE *) ctx, "%s:%04d: %s", file, line, str );
fflush( (FILE *) ctx ); fflush( (FILE *) ctx );
} }
#endif /* MBEDTLS_DEBUG_C */
static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags ) static int my_verify( void *data, mbedtls_x509_crt *crt, int depth, uint32_t *flags )
{ {
@ -423,7 +425,9 @@ int main( int argc, char *argv[] )
mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_NONE ); mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_NONE );
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg ); mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout ); mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 ) if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{ {