File indexing completed on 2025-08-27 09:37:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef MBEDTLS_DEBUG_H
0011 #define MBEDTLS_DEBUG_H
0012
0013 #include "mbedtls/build_info.h"
0014
0015 #include "mbedtls/ssl.h"
0016
0017 #if defined(MBEDTLS_ECP_C)
0018 #include "mbedtls/ecp.h"
0019 #endif
0020
0021 #if defined(MBEDTLS_DEBUG_C)
0022
0023 #define MBEDTLS_DEBUG_STRIP_PARENS(...) __VA_ARGS__
0024
0025 #define MBEDTLS_SSL_DEBUG_MSG(level, args) \
0026 mbedtls_debug_print_msg(ssl, level, __FILE__, __LINE__, \
0027 MBEDTLS_DEBUG_STRIP_PARENS args)
0028
0029 #define MBEDTLS_SSL_DEBUG_RET(level, text, ret) \
0030 mbedtls_debug_print_ret(ssl, level, __FILE__, __LINE__, text, ret)
0031
0032 #define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) \
0033 mbedtls_debug_print_buf(ssl, level, __FILE__, __LINE__, text, buf, len)
0034
0035 #if defined(MBEDTLS_BIGNUM_C)
0036 #define MBEDTLS_SSL_DEBUG_MPI(level, text, X) \
0037 mbedtls_debug_print_mpi(ssl, level, __FILE__, __LINE__, text, X)
0038 #endif
0039
0040 #if defined(MBEDTLS_ECP_C)
0041 #define MBEDTLS_SSL_DEBUG_ECP(level, text, X) \
0042 mbedtls_debug_print_ecp(ssl, level, __FILE__, __LINE__, text, X)
0043 #endif
0044
0045 #if defined(MBEDTLS_X509_CRT_PARSE_C)
0046 #if !defined(MBEDTLS_X509_REMOVE_INFO)
0047 #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) \
0048 mbedtls_debug_print_crt(ssl, level, __FILE__, __LINE__, text, crt)
0049 #else
0050 #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0)
0051 #endif
0052 #endif
0053
0054 #if defined(MBEDTLS_ECDH_C)
0055 #define MBEDTLS_SSL_DEBUG_ECDH(level, ecdh, attr) \
0056 mbedtls_debug_printf_ecdh(ssl, level, __FILE__, __LINE__, ecdh, attr)
0057 #endif
0058
0059 #else
0060
0061 #define MBEDTLS_SSL_DEBUG_MSG(level, args) do { } while (0)
0062 #define MBEDTLS_SSL_DEBUG_RET(level, text, ret) do { } while (0)
0063 #define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) do { } while (0)
0064 #define MBEDTLS_SSL_DEBUG_MPI(level, text, X) do { } while (0)
0065 #define MBEDTLS_SSL_DEBUG_ECP(level, text, X) do { } while (0)
0066 #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0)
0067 #define MBEDTLS_SSL_DEBUG_ECDH(level, ecdh, attr) do { } while (0)
0068
0069 #endif
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083 #if defined(__has_attribute)
0084 #if __has_attribute(format)
0085 #if defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1
0086 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \
0087 __attribute__((__format__(gnu_printf, string_index, first_to_check)))
0088 #else
0089 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \
0090 __attribute__((format(printf, string_index, first_to_check)))
0091 #endif
0092 #else
0093 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
0094 #endif
0095 #else
0096 #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check)
0097 #endif
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111 #if (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800)
0112 #include <inttypes.h>
0113 #define MBEDTLS_PRINTF_SIZET PRIuPTR
0114 #define MBEDTLS_PRINTF_LONGLONG "I64d"
0115 #else \
0116
0117 #define MBEDTLS_PRINTF_SIZET "zu"
0118 #define MBEDTLS_PRINTF_LONGLONG "lld"
0119 #endif \
0120
0121
0122 #if !defined(MBEDTLS_PRINTF_MS_TIME)
0123 #include <inttypes.h>
0124 #if !defined(PRId64)
0125 #define MBEDTLS_PRINTF_MS_TIME MBEDTLS_PRINTF_LONGLONG
0126 #else
0127 #define MBEDTLS_PRINTF_MS_TIME PRId64
0128 #endif
0129 #endif
0130
0131 #ifdef __cplusplus
0132 extern "C" {
0133 #endif
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150 void mbedtls_debug_set_threshold(int threshold);
0151
0152 #ifdef __cplusplus
0153 }
0154 #endif
0155
0156 #endif