2009-01-03 22:22:43 +01:00
|
|
|
/*
|
|
|
|
* Debugging routines
|
|
|
|
*
|
2015-01-23 10:45:19 +01:00
|
|
|
* Copyright (C) 2006-2014, ARM Limited, All Rights Reserved
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2015-03-06 14:17:10 +01:00
|
|
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
2010-07-18 22:36:00 +02:00
|
|
|
*
|
2009-01-03 22:22:43 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/config.h"
|
2014-04-29 12:39:06 +02:00
|
|
|
#else
|
2015-04-08 12:49:31 +02:00
|
|
|
#include MBEDTLS_CONFIG_FILE
|
2014-04-29 12:39:06 +02:00
|
|
|
#endif
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_DEBUG_C)
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/debug.h"
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
2013-10-28 18:48:30 +01:00
|
|
|
#include <stdio.h>
|
2015-02-06 14:43:58 +01:00
|
|
|
#include <string.h>
|
2013-10-28 18:48:30 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_PLATFORM_C)
|
2015-03-09 18:05:11 +01:00
|
|
|
#include "mbedtls/platform.h"
|
2015-01-30 12:10:20 +01:00
|
|
|
#else
|
2015-06-23 12:04:52 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#define mbedtls_calloc calloc
|
|
|
|
#define mbedtls_free free
|
|
|
|
#define mbedtls_snprintf snprintf
|
2015-01-30 12:10:20 +01:00
|
|
|
#endif
|
|
|
|
|
2015-06-23 12:04:52 +02:00
|
|
|
#define DEBUG_BUF_SIZE 512
|
|
|
|
|
2014-04-25 16:34:30 +02:00
|
|
|
static int debug_threshold = 0;
|
2014-04-25 15:04:14 +02:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_debug_set_threshold( int threshold )
|
2014-04-25 16:34:30 +02:00
|
|
|
{
|
|
|
|
debug_threshold = threshold;
|
|
|
|
}
|
|
|
|
|
2015-06-29 20:14:19 +02:00
|
|
|
void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
|
2015-06-29 20:08:23 +02:00
|
|
|
const char *file, int line,
|
|
|
|
const char *format, ... )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
|
|
|
va_list argp;
|
2015-06-29 20:08:23 +02:00
|
|
|
char str[DEBUG_BUF_SIZE];
|
|
|
|
int ret;
|
2015-06-23 12:04:52 +02:00
|
|
|
|
2015-06-29 20:08:23 +02:00
|
|
|
if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
|
|
|
|
return;
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
va_start( argp, format );
|
2015-06-22 11:50:58 +02:00
|
|
|
#if defined(_WIN32)
|
2015-07-08 16:46:13 +02:00
|
|
|
#if defined(_TRUNCATE)
|
2015-06-29 20:08:23 +02:00
|
|
|
ret = _vsnprintf_s( str, DEBUG_BUF_SIZE, _TRUNCATE, format, argp );
|
2015-07-08 16:46:13 +02:00
|
|
|
#else
|
|
|
|
ret = _vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
|
|
|
|
if( ret < 0 || (size_t) ret == DEBUG_BUF_SIZE )
|
|
|
|
{
|
|
|
|
str[DEBUG_BUF_SIZE-1] = '\0';
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
#endif
|
2015-06-22 11:50:58 +02:00
|
|
|
#else
|
2015-06-29 20:08:23 +02:00
|
|
|
ret = vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
|
2015-06-22 11:50:58 +02:00
|
|
|
#endif
|
2009-01-03 22:22:43 +01:00
|
|
|
va_end( argp );
|
|
|
|
|
2015-06-29 20:08:23 +02:00
|
|
|
if( ret >= 0 && ret < DEBUG_BUF_SIZE - 1 )
|
|
|
|
{
|
|
|
|
str[ret] = '\n';
|
|
|
|
str[ret + 1] = '\0';
|
|
|
|
}
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-29 20:08:23 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2015-06-23 12:04:52 +02:00
|
|
|
}
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
|
2010-03-16 22:09:09 +01:00
|
|
|
const char *file, int line,
|
|
|
|
const char *text, int ret )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2015-06-23 12:04:52 +02:00
|
|
|
char str[DEBUG_BUF_SIZE];
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-05-12 12:19:09 +02:00
|
|
|
if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
|
2009-01-03 22:22:43 +01:00
|
|
|
return;
|
|
|
|
|
2015-05-11 18:52:25 +02:00
|
|
|
/*
|
|
|
|
* With non-blocking I/O and examples that just retry immediately,
|
|
|
|
* the logs would be quickly flooded with WANT_READ, so ignore that.
|
|
|
|
* Don't ignore WANT_WRITE however, since is is usually rare.
|
|
|
|
*/
|
|
|
|
if( ret == MBEDTLS_ERR_SSL_WANT_READ )
|
|
|
|
return;
|
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
mbedtls_snprintf( str, sizeof( str ), "%s() returned %d (-0x%04x)\n",
|
2014-04-25 15:04:14 +02:00
|
|
|
text, ret, -ret );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2009-01-03 22:22:43 +01:00
|
|
|
}
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
|
2010-03-16 22:09:09 +01:00
|
|
|
const char *file, int line, const char *text,
|
2015-03-19 18:16:11 +01:00
|
|
|
const unsigned char *buf, size_t len )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2015-06-23 12:04:52 +02:00
|
|
|
char str[DEBUG_BUF_SIZE];
|
2014-11-19 10:17:21 +01:00
|
|
|
char txt[17];
|
2015-06-22 11:50:58 +02:00
|
|
|
size_t i, idx = 0;
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-05-12 12:19:09 +02:00
|
|
|
if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
|
2009-01-03 22:22:43 +01:00
|
|
|
return;
|
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str + idx, sizeof( str ) - idx, "dumping '%s' (%u bytes)\n",
|
2014-04-25 15:04:14 +02:00
|
|
|
text, (unsigned int) len );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2014-04-25 15:18:34 +02:00
|
|
|
idx = 0;
|
2014-11-19 10:17:21 +01:00
|
|
|
memset( txt, 0, sizeof( txt ) );
|
2009-01-03 22:22:43 +01:00
|
|
|
for( i = 0; i < len; i++ )
|
|
|
|
{
|
|
|
|
if( i >= 4096 )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if( i % 16 == 0 )
|
|
|
|
{
|
|
|
|
if( i > 0 )
|
2014-04-25 15:18:34 +02:00
|
|
|
{
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %s\n", txt );
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2014-11-19 10:17:21 +01:00
|
|
|
|
2014-04-25 15:18:34 +02:00
|
|
|
idx = 0;
|
2014-11-19 10:17:21 +01:00
|
|
|
memset( txt, 0, sizeof( txt ) );
|
2014-04-25 15:18:34 +02:00
|
|
|
}
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, "%04x: ",
|
2014-04-25 15:18:34 +02:00
|
|
|
(unsigned int) i );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x",
|
2014-04-25 15:18:34 +02:00
|
|
|
(unsigned int) buf[i] );
|
2014-11-19 10:17:21 +01:00
|
|
|
txt[i % 16] = ( buf[i] > 31 && buf[i] < 127 ) ? buf[i] : '.' ;
|
2009-01-03 22:22:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if( len > 0 )
|
2014-04-25 15:18:34 +02:00
|
|
|
{
|
2014-11-19 10:17:21 +01:00
|
|
|
for( /* i = i */; i % 16 != 0; i++ )
|
2015-06-22 11:50:58 +02:00
|
|
|
idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " " );
|
2014-11-19 10:17:21 +01:00
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %s\n", txt );
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2014-04-25 15:18:34 +02:00
|
|
|
}
|
2009-01-03 22:22:43 +01:00
|
|
|
}
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_ECP_C)
|
|
|
|
void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
|
2013-03-20 14:39:14 +01:00
|
|
|
const char *file, int line,
|
2015-04-08 12:49:31 +02:00
|
|
|
const char *text, const mbedtls_ecp_point *X )
|
2013-03-20 14:39:14 +01:00
|
|
|
{
|
2015-06-23 12:04:52 +02:00
|
|
|
char str[DEBUG_BUF_SIZE];
|
2013-03-20 14:39:14 +01:00
|
|
|
|
2015-05-12 12:19:09 +02:00
|
|
|
if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
|
2014-04-25 16:34:30 +02:00
|
|
|
return;
|
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str, sizeof( str ), "%s(X)", text );
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->X );
|
2013-03-20 14:39:14 +01:00
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str, sizeof( str ), "%s(Y)", text );
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->Y );
|
2013-03-20 14:39:14 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_ECP_C */
|
2013-03-20 14:39:14 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_BIGNUM_C)
|
|
|
|
void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
|
2010-03-16 22:09:09 +01:00
|
|
|
const char *file, int line,
|
2015-04-08 12:49:31 +02:00
|
|
|
const char *text, const mbedtls_mpi *X )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2015-06-23 12:04:52 +02:00
|
|
|
char str[DEBUG_BUF_SIZE];
|
2015-06-22 11:50:58 +02:00
|
|
|
int j, k, zeros = 1;
|
2014-04-25 15:04:14 +02:00
|
|
|
size_t i, n, idx = 0;
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-05-12 12:19:09 +02:00
|
|
|
if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || X == NULL || level > debug_threshold )
|
2009-01-03 22:22:43 +01:00
|
|
|
return;
|
|
|
|
|
2011-03-14 21:41:31 +01:00
|
|
|
for( n = X->n - 1; n > 0; n-- )
|
2009-01-03 22:22:43 +01:00
|
|
|
if( X->p[n] != 0 )
|
|
|
|
break;
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
for( j = ( sizeof(mbedtls_mpi_uint) << 3 ) - 1; j >= 0; j-- )
|
2011-03-14 21:41:31 +01:00
|
|
|
if( ( ( X->p[n] >> j ) & 1 ) != 0 )
|
|
|
|
break;
|
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str + idx, sizeof( str ) - idx, "value of '%s' (%d bits) is:\n",
|
2015-04-08 12:49:31 +02:00
|
|
|
text, (int) ( ( n * ( sizeof(mbedtls_mpi_uint) << 3 ) ) + j + 1 ) );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2014-04-25 15:18:34 +02:00
|
|
|
idx = 0;
|
2011-04-24 10:57:21 +02:00
|
|
|
for( i = n + 1, j = 0; i > 0; i-- )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2011-04-24 10:57:21 +02:00
|
|
|
if( zeros && X->p[i - 1] == 0 )
|
2011-03-14 21:41:31 +01:00
|
|
|
continue;
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
for( k = sizeof( mbedtls_mpi_uint ) - 1; k >= 0; k-- )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2014-06-17 16:39:18 +02:00
|
|
|
if( zeros && ( ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ) == 0 )
|
2011-03-14 21:41:31 +01:00
|
|
|
continue;
|
|
|
|
else
|
|
|
|
zeros = 0;
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2011-03-14 21:41:31 +01:00
|
|
|
if( j % 16 == 0 )
|
|
|
|
{
|
|
|
|
if( j > 0 )
|
2014-04-25 15:04:14 +02:00
|
|
|
{
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" );
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2014-04-25 15:18:34 +02:00
|
|
|
idx = 0;
|
2014-04-25 15:04:14 +02:00
|
|
|
}
|
2014-04-25 15:18:34 +02:00
|
|
|
}
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x", (unsigned int)
|
2014-06-17 16:39:18 +02:00
|
|
|
( X->p[i - 1] >> ( k << 3 ) ) & 0xFF );
|
2011-03-14 21:41:31 +01:00
|
|
|
|
|
|
|
j++;
|
2009-01-03 22:22:43 +01:00
|
|
|
}
|
2011-03-14 21:41:31 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if( zeros == 1 )
|
2015-06-22 11:50:58 +02:00
|
|
|
idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " 00" );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-22 11:50:58 +02:00
|
|
|
mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" );
|
2015-06-23 16:34:24 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2009-01-03 22:22:43 +01:00
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_BIGNUM_C */
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
|
|
|
static void debug_print_pk( const mbedtls_ssl_context *ssl, int level,
|
2013-08-14 18:04:18 +02:00
|
|
|
const char *file, int line,
|
2015-04-08 12:49:31 +02:00
|
|
|
const char *text, const mbedtls_pk_context *pk )
|
2013-08-14 18:04:18 +02:00
|
|
|
{
|
|
|
|
size_t i;
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_pk_debug_item items[MBEDTLS_PK_DEBUG_MAX_ITEMS];
|
2013-08-14 18:04:18 +02:00
|
|
|
char name[16];
|
|
|
|
|
|
|
|
memset( items, 0, sizeof( items ) );
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
if( mbedtls_pk_debug( pk, items ) != 0 )
|
2013-08-14 18:04:18 +02:00
|
|
|
{
|
2015-06-29 20:12:51 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line,
|
|
|
|
"invalid PK context\n" );
|
2013-08-14 18:04:18 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
for( i = 0; i < MBEDTLS_PK_DEBUG_MAX_ITEMS; i++ )
|
2013-08-14 18:04:18 +02:00
|
|
|
{
|
2015-04-08 12:49:31 +02:00
|
|
|
if( items[i].type == MBEDTLS_PK_DEBUG_NONE )
|
2013-08-14 18:04:18 +02:00
|
|
|
return;
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
mbedtls_snprintf( name, sizeof( name ), "%s%s", text, items[i].name );
|
2013-08-14 18:04:18 +02:00
|
|
|
name[sizeof( name ) - 1] = '\0';
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
if( items[i].type == MBEDTLS_PK_DEBUG_MPI )
|
|
|
|
mbedtls_debug_print_mpi( ssl, level, file, line, name, items[i].value );
|
2013-10-15 11:54:47 +02:00
|
|
|
else
|
2015-04-08 12:49:31 +02:00
|
|
|
#if defined(MBEDTLS_ECP_C)
|
|
|
|
if( items[i].type == MBEDTLS_PK_DEBUG_ECP )
|
|
|
|
mbedtls_debug_print_ecp( ssl, level, file, line, name, items[i].value );
|
2013-08-14 18:04:18 +02:00
|
|
|
else
|
2013-10-15 11:54:47 +02:00
|
|
|
#endif
|
2015-06-29 20:12:51 +02:00
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line,
|
|
|
|
"should not happen\n" );
|
2013-08-14 18:04:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
static void debug_print_line_by_line( const mbedtls_ssl_context *ssl, int level,
|
|
|
|
const char *file, int line, const char *text )
|
|
|
|
{
|
|
|
|
char str[DEBUG_BUF_SIZE];
|
|
|
|
const char *start, *cur;
|
|
|
|
|
|
|
|
start = text;
|
|
|
|
for( cur = text; *cur != '\0'; cur++ )
|
|
|
|
{
|
|
|
|
if( *cur == '\n' )
|
|
|
|
{
|
|
|
|
size_t len = cur - start + 1;
|
|
|
|
if( len > DEBUG_BUF_SIZE - 1 )
|
|
|
|
len = DEBUG_BUF_SIZE - 1;
|
|
|
|
|
|
|
|
memcpy( str, start, len );
|
|
|
|
str[len] = '\0';
|
|
|
|
|
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
|
|
|
|
|
|
|
start = cur + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
|
2010-03-16 22:09:09 +01:00
|
|
|
const char *file, int line,
|
2015-04-08 12:49:31 +02:00
|
|
|
const char *text, const mbedtls_x509_crt *crt )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2015-06-23 16:34:24 +02:00
|
|
|
char str[DEBUG_BUF_SIZE];
|
|
|
|
int i = 0;
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-05-12 12:19:09 +02:00
|
|
|
if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || crt == NULL || level > debug_threshold )
|
2009-01-03 22:22:43 +01:00
|
|
|
return;
|
|
|
|
|
2010-03-21 22:03:34 +01:00
|
|
|
while( crt != NULL )
|
2009-01-03 22:22:43 +01:00
|
|
|
{
|
2009-05-02 17:13:40 +02:00
|
|
|
char buf[1024];
|
2014-04-25 15:04:14 +02:00
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
mbedtls_snprintf( str, sizeof( str ), "%s #%d:\n", text, ++i );
|
|
|
|
ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-06-23 16:34:24 +02:00
|
|
|
mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt );
|
|
|
|
debug_print_line_by_line( ssl, level, file, line, buf );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2013-08-14 18:04:18 +02:00
|
|
|
debug_print_pk( ssl, level, file, line, "crt->", &crt->pk );
|
2009-01-03 22:22:43 +01:00
|
|
|
|
|
|
|
crt = crt->next;
|
|
|
|
}
|
|
|
|
}
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
2009-01-03 22:22:43 +01:00
|
|
|
|
2015-04-08 12:49:31 +02:00
|
|
|
#endif /* MBEDTLS_DEBUG_C */
|