mbed TLS v2.7.6
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
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  * This file is part of mbed TLS (https://tls.mbed.org)
23  */
24 #ifndef MBEDTLS_DEBUG_H
25 #define MBEDTLS_DEBUG_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include "ssl.h"
34 
35 #if defined(MBEDTLS_ECP_C)
36 #include "ecp.h"
37 #endif
38 
39 #if defined(MBEDTLS_DEBUG_C)
40 
41 #define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__
42 
43 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
44  mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \
45  MBEDTLS_DEBUG_STRIP_PARENS args )
46 
47 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
48  mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
49 
50 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \
51  mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len )
52 
53 #if defined(MBEDTLS_BIGNUM_C)
54 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \
55  mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X )
56 #endif
57 
58 #if defined(MBEDTLS_ECP_C)
59 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \
60  mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X )
61 #endif
62 
63 #if defined(MBEDTLS_X509_CRT_PARSE_C)
64 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \
65  mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt )
66 #endif
67 
68 #else /* MBEDTLS_DEBUG_C */
69 
70 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 )
71 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
72 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
73 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
74 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
75 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
76 
77 #endif /* MBEDTLS_DEBUG_C */
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
98 void mbedtls_debug_set_threshold( int threshold );
99 
115 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
116  const char *file, int line,
117  const char *format, ... );
118 
134 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
135  const char *file, int line,
136  const char *text, int ret );
137 
155 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
156  const char *file, int line, const char *text,
157  const unsigned char *buf, size_t len );
158 
159 #if defined(MBEDTLS_BIGNUM_C)
160 
176 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
177  const char *file, int line,
178  const char *text, const mbedtls_mpi *X );
179 #endif
180 
181 #if defined(MBEDTLS_ECP_C)
182 
198 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
199  const char *file, int line,
200  const char *text, const mbedtls_ecp_point *X );
201 #endif
202 
203 #if defined(MBEDTLS_X509_CRT_PARSE_C)
204 
219 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
220  const char *file, int line,
221  const char *text, const mbedtls_x509_crt *crt );
222 #endif
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif /* debug.h */
229 
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:180
SSL/TLS functions.
ECP point structure (jacobian coordinates)
Definition: ecp.h:108
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...