Merge remote-tracking branch 'origin/pr/603' into baremetal

This commit is contained in:
Simon Butcher 2019-07-10 15:40:32 +01:00
commit fabfb8578a
12 changed files with 44 additions and 0 deletions

View File

@ -978,9 +978,11 @@ struct mbedtls_ssl_config
const int *ciphersuite_list[4]; /*!< allowed ciphersuites per version */
#endif /* MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE */
#if defined(MBEDTLS_DEBUG_C)
/** Callback for printing debug output */
void (*f_dbg)(void *, int, const char *, int, const char *);
void *p_dbg; /*!< context for the debug function */
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RNG)
/** Callback for getting (pseudo-)random numbers */
@ -1579,6 +1581,7 @@ void mbedtls_ssl_conf_rng_ctx( mbedtls_ssl_config *conf,
void *p_rng );
#endif /* MBEDTLS_SSL_CONF_RNG */
#if defined(MBEDTLS_DEBUG_C)
/**
* \brief Set the debug callback
*
@ -1596,6 +1599,7 @@ void mbedtls_ssl_conf_rng_ctx( mbedtls_ssl_config *conf,
void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
void (*f_dbg)(void *, int, const char *, int, const char *),
void *p_dbg );
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \

View File

@ -8221,6 +8221,7 @@ void mbedtls_ssl_conf_rng_ctx( mbedtls_ssl_config *conf,
}
#endif
#if defined(MBEDTLS_DEBUG_C)
void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
void (*f_dbg)(void *, int, const char *, int, const char *),
void *p_dbg )
@ -8228,6 +8229,7 @@ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
conf->f_dbg = f_dbg;
conf->p_dbg = p_dbg;
}
#endif /* MBEDTLS_DEBUG_C */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \

View File

@ -83,6 +83,7 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
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_ca_chain( &conf, &cacert, NULL );
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{

View File

@ -92,6 +92,7 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
int main( void )
{
@ -223,7 +225,9 @@ int main( void )
}
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE)
mbedtls_ssl_conf_session_cache( &conf, &cache,

View File

@ -73,6 +73,7 @@ int main( void )
#define DEBUG_LEVEL 1
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
int main( void )
{
@ -178,7 +180,9 @@ int main( void )
mbedtls_ssl_conf_authmode( &conf, MBEDTLS_SSL_VERIFY_OPTIONAL );
mbedtls_ssl_conf_ca_chain( &conf, &cacert, NULL );
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{

View File

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

View File

@ -90,6 +90,7 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
int main( void )
{
@ -195,7 +197,9 @@ int main( void )
}
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
mbedtls_ssl_conf_ca_chain( &conf, srvcert.next, NULL );
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 */
} opt;
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
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_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if !defined(MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE)
if( opt.force_ciphersuite[0] != DFL_FORCE_CIPHER )

View File

@ -433,7 +433,9 @@ int main( void )
}
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 );
#endif
/* mbedtls_ssl_cache_get() and mbedtls_ssl_cache_set() are thread-safe if
* MBEDTLS_THREADING_C is set.

View File

@ -85,6 +85,7 @@ int main( void )
#define DEBUG_LEVEL 0
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
int main( void )
{
@ -211,7 +213,9 @@ int main( void )
}
mbedtls_ssl_conf_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
#if defined(MBEDTLS_SSL_CACHE_C) && !defined(MBEDTLS_SSL_NO_SESSION_CACHE)
mbedtls_ssl_conf_session_cache( &conf, &cache,

View File

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

View File

@ -117,6 +117,7 @@ struct options
int permissive; /* permissive parsing */
} opt;
#if defined(MBEDTLS_DEBUG_C)
static void my_debug( void *ctx, int level,
const char *file, int line,
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 );
fflush( (FILE *) ctx );
}
#endif /* MBEDTLS_DEBUG_C */
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_rng( &conf, mbedtls_ctr_drbg_random, &ctr_drbg );
#if defined(MBEDTLS_DEBUG_C)
mbedtls_ssl_conf_dbg( &conf, my_debug, stdout );
#endif
if( ( ret = mbedtls_ssl_setup( &ssl, &conf ) ) != 0 )
{