mbed TLS v2.7.16
debug.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
8  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9  *
10  * This file is provided under the Apache License 2.0, or the
11  * GNU General Public License v2.0 or later.
12  *
13  * **********
14  * Apache License 2.0:
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may
17  * not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
24  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  *
28  * **********
29  *
30  * **********
31  * GNU General Public License v2.0 or later:
32  *
33  * This program is free software; you can redistribute it and/or modify
34  * it under the terms of the GNU General Public License as published by
35  * the Free Software Foundation; either version 2 of the License, or
36  * (at your option) any later version.
37  *
38  * This program is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41  * GNU General Public License for more details.
42  *
43  * You should have received a copy of the GNU General Public License along
44  * with this program; if not, write to the Free Software Foundation, Inc.,
45  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
46  *
47  * **********
48  *
49  * This file is part of mbed TLS (https://tls.mbed.org)
50  */
51 #ifndef MBEDTLS_DEBUG_H
52 #define MBEDTLS_DEBUG_H
53 
54 #if !defined(MBEDTLS_CONFIG_FILE)
55 #include "config.h"
56 #else
57 #include MBEDTLS_CONFIG_FILE
58 #endif
59 
60 #include "ssl.h"
61 
62 #if defined(MBEDTLS_ECP_C)
63 #include "ecp.h"
64 #endif
65 
66 #if defined(MBEDTLS_DEBUG_C)
67 
68 #define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__
69 
70 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
71  mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \
72  MBEDTLS_DEBUG_STRIP_PARENS args )
73 
74 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
75  mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
76 
77 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \
78  mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len )
79 
80 #if defined(MBEDTLS_BIGNUM_C)
81 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \
82  mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X )
83 #endif
84 
85 #if defined(MBEDTLS_ECP_C)
86 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \
87  mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X )
88 #endif
89 
90 #if defined(MBEDTLS_X509_CRT_PARSE_C)
91 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \
92  mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt )
93 #endif
94 
95 #else /* MBEDTLS_DEBUG_C */
96 
97 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 )
98 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
99 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
100 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
101 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
102 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
103 
104 #endif /* MBEDTLS_DEBUG_C */
105 
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109 
125 void mbedtls_debug_set_threshold( int threshold );
126 
142 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
143  const char *file, int line,
144  const char *format, ... );
145 
161 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
162  const char *file, int line,
163  const char *text, int ret );
164 
182 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
183  const char *file, int line, const char *text,
184  const unsigned char *buf, size_t len );
185 
186 #if defined(MBEDTLS_BIGNUM_C)
187 
203 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
204  const char *file, int line,
205  const char *text, const mbedtls_mpi *X );
206 #endif
207 
208 #if defined(MBEDTLS_ECP_C)
209 
225 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
226  const char *file, int line,
227  const char *text, const mbedtls_ecp_point *X );
228 #endif
229 
230 #if defined(MBEDTLS_X509_CRT_PARSE_C)
231 
246 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
247  const char *file, int line,
248  const char *text, const mbedtls_x509_crt *crt );
249 #endif
250 
251 #ifdef __cplusplus
252 }
253 #endif
254 
255 #endif /* debug.h */
256 
void mbedtls_debug_print_crt(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_x509_crt *crt)
Print a X.509 certificate structure to the debug output. This function is always used through the MBE...
void mbedtls_debug_print_mpi(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_mpi *X)
Print a MPI variable to the debug output. This function is always used through the MBEDTLS_SSL_DEBUG_...
Elliptic curves over GF(p)
Configuration options (set of defines)
void mbedtls_debug_set_threshold(int threshold)
Set the threshold error level to handle globally all debug output. Debug messages that have a level o...
void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, int ret)
Print the return value of a function to the debug output. This function is always used through the MB...
void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *format,...)
Print a message to the debug output. This function is always used through the MBEDTLS_SSL_DEBUG_MSG()...
MPI structure.
Definition: bignum.h:207
SSL/TLS functions.
ECP point structure (jacobian coordinates)
Definition: ecp.h:141
void mbedtls_debug_print_ecp(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const mbedtls_ecp_point *X)
Print an ECP point to the debug output. This function is always used through the MBEDTLS_SSL_DEBUG_EC...
void mbedtls_debug_print_buf(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const char *text, const unsigned char *buf, size_t len)
Output a buffer of size len bytes to the debug output. This function is always used through the MBEDT...