mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
markrad
Date:
Thu Jan 05 00:18:44 2017 +0000
Revision:
0:cdf462088d13
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 /*
markrad 0:cdf462088d13 2 * Debugging routines
markrad 0:cdf462088d13 3 *
markrad 0:cdf462088d13 4 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 5 * SPDX-License-Identifier: Apache-2.0
markrad 0:cdf462088d13 6 *
markrad 0:cdf462088d13 7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
markrad 0:cdf462088d13 8 * not use this file except in compliance with the License.
markrad 0:cdf462088d13 9 * You may obtain a copy of the License at
markrad 0:cdf462088d13 10 *
markrad 0:cdf462088d13 11 * http://www.apache.org/licenses/LICENSE-2.0
markrad 0:cdf462088d13 12 *
markrad 0:cdf462088d13 13 * Unless required by applicable law or agreed to in writing, software
markrad 0:cdf462088d13 14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
markrad 0:cdf462088d13 15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
markrad 0:cdf462088d13 16 * See the License for the specific language governing permissions and
markrad 0:cdf462088d13 17 * limitations under the License.
markrad 0:cdf462088d13 18 *
markrad 0:cdf462088d13 19 * This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 20 */
markrad 0:cdf462088d13 21
markrad 0:cdf462088d13 22 #if !defined(MBEDTLS_CONFIG_FILE)
markrad 0:cdf462088d13 23 #include "mbedtls/config.h"
markrad 0:cdf462088d13 24 #else
markrad 0:cdf462088d13 25 #include MBEDTLS_CONFIG_FILE
markrad 0:cdf462088d13 26 #endif
markrad 0:cdf462088d13 27
markrad 0:cdf462088d13 28 #if defined(MBEDTLS_DEBUG_C)
markrad 0:cdf462088d13 29
markrad 0:cdf462088d13 30 #if defined(MBEDTLS_PLATFORM_C)
markrad 0:cdf462088d13 31 #include "mbedtls/platform.h"
markrad 0:cdf462088d13 32 #else
markrad 0:cdf462088d13 33 #include <stdlib.h>
markrad 0:cdf462088d13 34 #define mbedtls_calloc calloc
markrad 0:cdf462088d13 35 #define mbedtls_free free
markrad 0:cdf462088d13 36 #define mbedtls_time_t time_t
markrad 0:cdf462088d13 37 #define mbedtls_snprintf snprintf
markrad 0:cdf462088d13 38 #endif
markrad 0:cdf462088d13 39
markrad 0:cdf462088d13 40 #include "mbedtls/debug.h"
markrad 0:cdf462088d13 41
markrad 0:cdf462088d13 42 #include <stdarg.h>
markrad 0:cdf462088d13 43 #include <stdio.h>
markrad 0:cdf462088d13 44 #include <string.h>
markrad 0:cdf462088d13 45
markrad 0:cdf462088d13 46 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
markrad 0:cdf462088d13 47 !defined(inline) && !defined(__cplusplus)
markrad 0:cdf462088d13 48 #define inline __inline
markrad 0:cdf462088d13 49 #endif
markrad 0:cdf462088d13 50
markrad 0:cdf462088d13 51 #define DEBUG_BUF_SIZE 512
markrad 0:cdf462088d13 52
markrad 0:cdf462088d13 53 static int debug_threshold = 0;
markrad 0:cdf462088d13 54
markrad 0:cdf462088d13 55 void mbedtls_debug_set_threshold( int threshold )
markrad 0:cdf462088d13 56 {
markrad 0:cdf462088d13 57 debug_threshold = threshold;
markrad 0:cdf462088d13 58 }
markrad 0:cdf462088d13 59
markrad 0:cdf462088d13 60 /*
markrad 0:cdf462088d13 61 * All calls to f_dbg must be made via this function
markrad 0:cdf462088d13 62 */
markrad 0:cdf462088d13 63 static inline void debug_send_line( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 64 const char *file, int line,
markrad 0:cdf462088d13 65 const char *str )
markrad 0:cdf462088d13 66 {
markrad 0:cdf462088d13 67 /*
markrad 0:cdf462088d13 68 * If in a threaded environment, we need a thread identifier.
markrad 0:cdf462088d13 69 * Since there is no portable way to get one, use the address of the ssl
markrad 0:cdf462088d13 70 * context instead, as it shouldn't be shared between threads.
markrad 0:cdf462088d13 71 */
markrad 0:cdf462088d13 72 #if defined(MBEDTLS_THREADING_C)
markrad 0:cdf462088d13 73 char idstr[20 + DEBUG_BUF_SIZE]; /* 0x + 16 nibbles + ': ' */
markrad 0:cdf462088d13 74 mbedtls_snprintf( idstr, sizeof( idstr ), "%p: %s", ssl, str );
markrad 0:cdf462088d13 75 ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, idstr );
markrad 0:cdf462088d13 76 #else
markrad 0:cdf462088d13 77 ssl->conf->f_dbg( ssl->conf->p_dbg, level, file, line, str );
markrad 0:cdf462088d13 78 #endif
markrad 0:cdf462088d13 79 }
markrad 0:cdf462088d13 80
markrad 0:cdf462088d13 81 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 82 const char *file, int line,
markrad 0:cdf462088d13 83 const char *format, ... )
markrad 0:cdf462088d13 84 {
markrad 0:cdf462088d13 85 va_list argp;
markrad 0:cdf462088d13 86 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 87 int ret;
markrad 0:cdf462088d13 88
markrad 0:cdf462088d13 89 if( NULL == ssl || NULL == ssl->conf || NULL == ssl->conf->f_dbg || level > debug_threshold )
markrad 0:cdf462088d13 90 return;
markrad 0:cdf462088d13 91
markrad 0:cdf462088d13 92 va_start( argp, format );
markrad 0:cdf462088d13 93 #if defined(_WIN32)
markrad 0:cdf462088d13 94 #if defined(_TRUNCATE)
markrad 0:cdf462088d13 95 ret = _vsnprintf_s( str, DEBUG_BUF_SIZE, _TRUNCATE, format, argp );
markrad 0:cdf462088d13 96 #else
markrad 0:cdf462088d13 97 ret = _vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
markrad 0:cdf462088d13 98 if( ret < 0 || (size_t) ret == DEBUG_BUF_SIZE )
markrad 0:cdf462088d13 99 {
markrad 0:cdf462088d13 100 str[DEBUG_BUF_SIZE-1] = '\0';
markrad 0:cdf462088d13 101 ret = -1;
markrad 0:cdf462088d13 102 }
markrad 0:cdf462088d13 103 #endif
markrad 0:cdf462088d13 104 #else
markrad 0:cdf462088d13 105 ret = vsnprintf( str, DEBUG_BUF_SIZE, format, argp );
markrad 0:cdf462088d13 106 #endif
markrad 0:cdf462088d13 107 va_end( argp );
markrad 0:cdf462088d13 108
markrad 0:cdf462088d13 109 if( ret >= 0 && ret < DEBUG_BUF_SIZE - 1 )
markrad 0:cdf462088d13 110 {
markrad 0:cdf462088d13 111 str[ret] = '\n';
markrad 0:cdf462088d13 112 str[ret + 1] = '\0';
markrad 0:cdf462088d13 113 }
markrad 0:cdf462088d13 114
markrad 0:cdf462088d13 115 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 116 }
markrad 0:cdf462088d13 117
markrad 0:cdf462088d13 118 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 119 const char *file, int line,
markrad 0:cdf462088d13 120 const char *text, int ret )
markrad 0:cdf462088d13 121 {
markrad 0:cdf462088d13 122 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 123
markrad 0:cdf462088d13 124 if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
markrad 0:cdf462088d13 125 return;
markrad 0:cdf462088d13 126
markrad 0:cdf462088d13 127 /*
markrad 0:cdf462088d13 128 * With non-blocking I/O and examples that just retry immediately,
markrad 0:cdf462088d13 129 * the logs would be quickly flooded with WANT_READ, so ignore that.
markrad 0:cdf462088d13 130 * Don't ignore WANT_WRITE however, since is is usually rare.
markrad 0:cdf462088d13 131 */
markrad 0:cdf462088d13 132 if( ret == MBEDTLS_ERR_SSL_WANT_READ )
markrad 0:cdf462088d13 133 return;
markrad 0:cdf462088d13 134
markrad 0:cdf462088d13 135 mbedtls_snprintf( str, sizeof( str ), "%s() returned %d (-0x%04x)\n",
markrad 0:cdf462088d13 136 text, ret, -ret );
markrad 0:cdf462088d13 137
markrad 0:cdf462088d13 138 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 139 }
markrad 0:cdf462088d13 140
markrad 0:cdf462088d13 141 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 142 const char *file, int line, const char *text,
markrad 0:cdf462088d13 143 const unsigned char *buf, size_t len )
markrad 0:cdf462088d13 144 {
markrad 0:cdf462088d13 145 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 146 char txt[17];
markrad 0:cdf462088d13 147 size_t i, idx = 0;
markrad 0:cdf462088d13 148
markrad 0:cdf462088d13 149 if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
markrad 0:cdf462088d13 150 return;
markrad 0:cdf462088d13 151
markrad 0:cdf462088d13 152 mbedtls_snprintf( str + idx, sizeof( str ) - idx, "dumping '%s' (%u bytes)\n",
markrad 0:cdf462088d13 153 text, (unsigned int) len );
markrad 0:cdf462088d13 154
markrad 0:cdf462088d13 155 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 156
markrad 0:cdf462088d13 157 idx = 0;
markrad 0:cdf462088d13 158 memset( txt, 0, sizeof( txt ) );
markrad 0:cdf462088d13 159 for( i = 0; i < len; i++ )
markrad 0:cdf462088d13 160 {
markrad 0:cdf462088d13 161 if( i >= 4096 )
markrad 0:cdf462088d13 162 break;
markrad 0:cdf462088d13 163
markrad 0:cdf462088d13 164 if( i % 16 == 0 )
markrad 0:cdf462088d13 165 {
markrad 0:cdf462088d13 166 if( i > 0 )
markrad 0:cdf462088d13 167 {
markrad 0:cdf462088d13 168 mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %s\n", txt );
markrad 0:cdf462088d13 169 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 170
markrad 0:cdf462088d13 171 idx = 0;
markrad 0:cdf462088d13 172 memset( txt, 0, sizeof( txt ) );
markrad 0:cdf462088d13 173 }
markrad 0:cdf462088d13 174
markrad 0:cdf462088d13 175 idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, "%04x: ",
markrad 0:cdf462088d13 176 (unsigned int) i );
markrad 0:cdf462088d13 177
markrad 0:cdf462088d13 178 }
markrad 0:cdf462088d13 179
markrad 0:cdf462088d13 180 idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x",
markrad 0:cdf462088d13 181 (unsigned int) buf[i] );
markrad 0:cdf462088d13 182 txt[i % 16] = ( buf[i] > 31 && buf[i] < 127 ) ? buf[i] : '.' ;
markrad 0:cdf462088d13 183 }
markrad 0:cdf462088d13 184
markrad 0:cdf462088d13 185 if( len > 0 )
markrad 0:cdf462088d13 186 {
markrad 0:cdf462088d13 187 for( /* i = i */; i % 16 != 0; i++ )
markrad 0:cdf462088d13 188 idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " " );
markrad 0:cdf462088d13 189
markrad 0:cdf462088d13 190 mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %s\n", txt );
markrad 0:cdf462088d13 191 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 192 }
markrad 0:cdf462088d13 193 }
markrad 0:cdf462088d13 194
markrad 0:cdf462088d13 195 #if defined(MBEDTLS_ECP_C)
markrad 0:cdf462088d13 196 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 197 const char *file, int line,
markrad 0:cdf462088d13 198 const char *text, const mbedtls_ecp_point *X )
markrad 0:cdf462088d13 199 {
markrad 0:cdf462088d13 200 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 201
markrad 0:cdf462088d13 202 if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || level > debug_threshold )
markrad 0:cdf462088d13 203 return;
markrad 0:cdf462088d13 204
markrad 0:cdf462088d13 205 mbedtls_snprintf( str, sizeof( str ), "%s(X)", text );
markrad 0:cdf462088d13 206 mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->X );
markrad 0:cdf462088d13 207
markrad 0:cdf462088d13 208 mbedtls_snprintf( str, sizeof( str ), "%s(Y)", text );
markrad 0:cdf462088d13 209 mbedtls_debug_print_mpi( ssl, level, file, line, str, &X->Y );
markrad 0:cdf462088d13 210 }
markrad 0:cdf462088d13 211 #endif /* MBEDTLS_ECP_C */
markrad 0:cdf462088d13 212
markrad 0:cdf462088d13 213 #if defined(MBEDTLS_BIGNUM_C)
markrad 0:cdf462088d13 214 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 215 const char *file, int line,
markrad 0:cdf462088d13 216 const char *text, const mbedtls_mpi *X )
markrad 0:cdf462088d13 217 {
markrad 0:cdf462088d13 218 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 219 int j, k, zeros = 1;
markrad 0:cdf462088d13 220 size_t i, n, idx = 0;
markrad 0:cdf462088d13 221
markrad 0:cdf462088d13 222 if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || X == NULL || level > debug_threshold )
markrad 0:cdf462088d13 223 return;
markrad 0:cdf462088d13 224
markrad 0:cdf462088d13 225 for( n = X->n - 1; n > 0; n-- )
markrad 0:cdf462088d13 226 if( X->p[n] != 0 )
markrad 0:cdf462088d13 227 break;
markrad 0:cdf462088d13 228
markrad 0:cdf462088d13 229 for( j = ( sizeof(mbedtls_mpi_uint) << 3 ) - 1; j >= 0; j-- )
markrad 0:cdf462088d13 230 if( ( ( X->p[n] >> j ) & 1 ) != 0 )
markrad 0:cdf462088d13 231 break;
markrad 0:cdf462088d13 232
markrad 0:cdf462088d13 233 mbedtls_snprintf( str + idx, sizeof( str ) - idx, "value of '%s' (%d bits) is:\n",
markrad 0:cdf462088d13 234 text, (int) ( ( n * ( sizeof(mbedtls_mpi_uint) << 3 ) ) + j + 1 ) );
markrad 0:cdf462088d13 235
markrad 0:cdf462088d13 236 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 237
markrad 0:cdf462088d13 238 idx = 0;
markrad 0:cdf462088d13 239 for( i = n + 1, j = 0; i > 0; i-- )
markrad 0:cdf462088d13 240 {
markrad 0:cdf462088d13 241 if( zeros && X->p[i - 1] == 0 )
markrad 0:cdf462088d13 242 continue;
markrad 0:cdf462088d13 243
markrad 0:cdf462088d13 244 for( k = sizeof( mbedtls_mpi_uint ) - 1; k >= 0; k-- )
markrad 0:cdf462088d13 245 {
markrad 0:cdf462088d13 246 if( zeros && ( ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF ) == 0 )
markrad 0:cdf462088d13 247 continue;
markrad 0:cdf462088d13 248 else
markrad 0:cdf462088d13 249 zeros = 0;
markrad 0:cdf462088d13 250
markrad 0:cdf462088d13 251 if( j % 16 == 0 )
markrad 0:cdf462088d13 252 {
markrad 0:cdf462088d13 253 if( j > 0 )
markrad 0:cdf462088d13 254 {
markrad 0:cdf462088d13 255 mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" );
markrad 0:cdf462088d13 256 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 257 idx = 0;
markrad 0:cdf462088d13 258 }
markrad 0:cdf462088d13 259 }
markrad 0:cdf462088d13 260
markrad 0:cdf462088d13 261 idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " %02x", (unsigned int)
markrad 0:cdf462088d13 262 ( X->p[i - 1] >> ( k << 3 ) ) & 0xFF );
markrad 0:cdf462088d13 263
markrad 0:cdf462088d13 264 j++;
markrad 0:cdf462088d13 265 }
markrad 0:cdf462088d13 266
markrad 0:cdf462088d13 267 }
markrad 0:cdf462088d13 268
markrad 0:cdf462088d13 269 if( zeros == 1 )
markrad 0:cdf462088d13 270 idx += mbedtls_snprintf( str + idx, sizeof( str ) - idx, " 00" );
markrad 0:cdf462088d13 271
markrad 0:cdf462088d13 272 mbedtls_snprintf( str + idx, sizeof( str ) - idx, "\n" );
markrad 0:cdf462088d13 273 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 274 }
markrad 0:cdf462088d13 275 #endif /* MBEDTLS_BIGNUM_C */
markrad 0:cdf462088d13 276
markrad 0:cdf462088d13 277 #if defined(MBEDTLS_X509_CRT_PARSE_C)
markrad 0:cdf462088d13 278 static void debug_print_pk( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 279 const char *file, int line,
markrad 0:cdf462088d13 280 const char *text, const mbedtls_pk_context *pk )
markrad 0:cdf462088d13 281 {
markrad 0:cdf462088d13 282 size_t i;
markrad 0:cdf462088d13 283 mbedtls_pk_debug_item items[MBEDTLS_PK_DEBUG_MAX_ITEMS];
markrad 0:cdf462088d13 284 char name[16];
markrad 0:cdf462088d13 285
markrad 0:cdf462088d13 286 memset( items, 0, sizeof( items ) );
markrad 0:cdf462088d13 287
markrad 0:cdf462088d13 288 if( mbedtls_pk_debug( pk, items ) != 0 )
markrad 0:cdf462088d13 289 {
markrad 0:cdf462088d13 290 debug_send_line( ssl, level, file, line,
markrad 0:cdf462088d13 291 "invalid PK context\n" );
markrad 0:cdf462088d13 292 return;
markrad 0:cdf462088d13 293 }
markrad 0:cdf462088d13 294
markrad 0:cdf462088d13 295 for( i = 0; i < MBEDTLS_PK_DEBUG_MAX_ITEMS; i++ )
markrad 0:cdf462088d13 296 {
markrad 0:cdf462088d13 297 if( items[i].type == MBEDTLS_PK_DEBUG_NONE )
markrad 0:cdf462088d13 298 return;
markrad 0:cdf462088d13 299
markrad 0:cdf462088d13 300 mbedtls_snprintf( name, sizeof( name ), "%s%s", text, items[i].name );
markrad 0:cdf462088d13 301 name[sizeof( name ) - 1] = '\0';
markrad 0:cdf462088d13 302
markrad 0:cdf462088d13 303 if( items[i].type == MBEDTLS_PK_DEBUG_MPI )
markrad 0:cdf462088d13 304 mbedtls_debug_print_mpi( ssl, level, file, line, name, items[i].value );
markrad 0:cdf462088d13 305 else
markrad 0:cdf462088d13 306 #if defined(MBEDTLS_ECP_C)
markrad 0:cdf462088d13 307 if( items[i].type == MBEDTLS_PK_DEBUG_ECP )
markrad 0:cdf462088d13 308 mbedtls_debug_print_ecp( ssl, level, file, line, name, items[i].value );
markrad 0:cdf462088d13 309 else
markrad 0:cdf462088d13 310 #endif
markrad 0:cdf462088d13 311 debug_send_line( ssl, level, file, line,
markrad 0:cdf462088d13 312 "should not happen\n" );
markrad 0:cdf462088d13 313 }
markrad 0:cdf462088d13 314 }
markrad 0:cdf462088d13 315
markrad 0:cdf462088d13 316 static void debug_print_line_by_line( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 317 const char *file, int line, const char *text )
markrad 0:cdf462088d13 318 {
markrad 0:cdf462088d13 319 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 320 const char *start, *cur;
markrad 0:cdf462088d13 321
markrad 0:cdf462088d13 322 start = text;
markrad 0:cdf462088d13 323 for( cur = text; *cur != '\0'; cur++ )
markrad 0:cdf462088d13 324 {
markrad 0:cdf462088d13 325 if( *cur == '\n' )
markrad 0:cdf462088d13 326 {
markrad 0:cdf462088d13 327 size_t len = cur - start + 1;
markrad 0:cdf462088d13 328 if( len > DEBUG_BUF_SIZE - 1 )
markrad 0:cdf462088d13 329 len = DEBUG_BUF_SIZE - 1;
markrad 0:cdf462088d13 330
markrad 0:cdf462088d13 331 memcpy( str, start, len );
markrad 0:cdf462088d13 332 str[len] = '\0';
markrad 0:cdf462088d13 333
markrad 0:cdf462088d13 334 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 335
markrad 0:cdf462088d13 336 start = cur + 1;
markrad 0:cdf462088d13 337 }
markrad 0:cdf462088d13 338 }
markrad 0:cdf462088d13 339 }
markrad 0:cdf462088d13 340
markrad 0:cdf462088d13 341 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 342 const char *file, int line,
markrad 0:cdf462088d13 343 const char *text, const mbedtls_x509_crt *crt )
markrad 0:cdf462088d13 344 {
markrad 0:cdf462088d13 345 char str[DEBUG_BUF_SIZE];
markrad 0:cdf462088d13 346 int i = 0;
markrad 0:cdf462088d13 347
markrad 0:cdf462088d13 348 if( ssl->conf == NULL || ssl->conf->f_dbg == NULL || crt == NULL || level > debug_threshold )
markrad 0:cdf462088d13 349 return;
markrad 0:cdf462088d13 350
markrad 0:cdf462088d13 351 while( crt != NULL )
markrad 0:cdf462088d13 352 {
markrad 0:cdf462088d13 353 char buf[1024];
markrad 0:cdf462088d13 354
markrad 0:cdf462088d13 355 mbedtls_snprintf( str, sizeof( str ), "%s #%d:\n", text, ++i );
markrad 0:cdf462088d13 356 debug_send_line( ssl, level, file, line, str );
markrad 0:cdf462088d13 357
markrad 0:cdf462088d13 358 mbedtls_x509_crt_info( buf, sizeof( buf ) - 1, "", crt );
markrad 0:cdf462088d13 359 debug_print_line_by_line( ssl, level, file, line, buf );
markrad 0:cdf462088d13 360
markrad 0:cdf462088d13 361 debug_print_pk( ssl, level, file, line, "crt->", &crt->pk );
markrad 0:cdf462088d13 362
markrad 0:cdf462088d13 363 crt = crt->next;
markrad 0:cdf462088d13 364 }
markrad 0:cdf462088d13 365 }
markrad 0:cdf462088d13 366 #endif /* MBEDTLS_X509_CRT_PARSE_C */
markrad 0:cdf462088d13 367
markrad 0:cdf462088d13 368 #endif /* MBEDTLS_DEBUG_C */