mbed TLS v2.24.0
debug.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright The Mbed TLS Contributors
8  * SPDX-License-Identifier: Apache-2.0
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License"); you may
11  * not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  */
22 #ifndef MBEDTLS_DEBUG_H
23 #define MBEDTLS_DEBUG_H
24 
25 #if !defined(MBEDTLS_CONFIG_FILE)
26 #include "mbedtls/config.h"
27 #else
28 #include MBEDTLS_CONFIG_FILE
29 #endif
30 
31 #include "mbedtls/ssl.h"
32 
33 #if defined(MBEDTLS_ECP_C)
34 #include "mbedtls/ecp.h"
35 #endif
36 
37 #if defined(MBEDTLS_DEBUG_C)
38 
39 #define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__
40 
41 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
42  mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \
43  MBEDTLS_DEBUG_STRIP_PARENS args )
44 
45 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
46  mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
47 
48 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \
49  mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len )
50 
51 #if defined(MBEDTLS_BIGNUM_C)
52 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \
53  mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X )
54 #endif
55 
56 #if defined(MBEDTLS_ECP_C)
57 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \
58  mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X )
59 #endif
60 
61 #if defined(MBEDTLS_X509_CRT_PARSE_C)
62 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \
63  mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt )
64 #endif
65 
66 #if defined(MBEDTLS_ECDH_C)
67 #define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) \
68  mbedtls_debug_printf_ecdh( ssl, level, __FILE__, __LINE__, ecdh, attr )
69 #endif
70 
71 #else /* MBEDTLS_DEBUG_C */
72 
73 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 )
74 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
75 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
76 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
77 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
78 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
79 #define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) do { } while( 0 )
80 
81 #endif /* MBEDTLS_DEBUG_C */
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
102 void mbedtls_debug_set_threshold( int threshold );
103 
119 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
120  const char *file, int line,
121  const char *format, ... );
122 
138 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
139  const char *file, int line,
140  const char *text, int ret );
141 
159 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
160  const char *file, int line, const char *text,
161  const unsigned char *buf, size_t len );
162 
163 #if defined(MBEDTLS_BIGNUM_C)
164 
180 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
181  const char *file, int line,
182  const char *text, const mbedtls_mpi *X );
183 #endif
184 
185 #if defined(MBEDTLS_ECP_C)
186 
202 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
203  const char *file, int line,
204  const char *text, const mbedtls_ecp_point *X );
205 #endif
206 
207 #if defined(MBEDTLS_X509_CRT_PARSE_C)
208 
223 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
224  const char *file, int line,
225  const char *text, const mbedtls_x509_crt *crt );
226 #endif
227 
228 #if defined(MBEDTLS_ECDH_C)
229 typedef enum
230 {
235 
252 void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level,
253  const char *file, int line,
254  const mbedtls_ecdh_context *ecdh,
256 #endif
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif /* debug.h */
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_...
This file provides an API for Elliptic Curves over GF(P) (ECP).
mbedtls_debug_ecdh_attr
Definition: debug.h:229
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_printf_ecdh(const mbedtls_ssl_context *ssl, int level, const char *file, int line, const mbedtls_ecdh_context *ecdh, mbedtls_debug_ecdh_attr attr)
Print a field of the ECDH structure in the SSL context to the debug output. This function is always u...
The ECDH context structure.
Definition: ecdh.h:104
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:184
SSL/TLS functions.
The ECP point structure, in Jacobian coordinates.
Definition: ecp.h:166
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...