Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 1 | /** |
| 2 | * \file debug.h |
Paul Bakker | e0ccd0a | 2009-01-04 16:27:10 +0000 | [diff] [blame] | 3 | * |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 4 | * \brief Functions for controlling and providing debug output from the library. |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 7 | * Copyright The Mbed TLS Contributors |
Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 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. |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 21 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 22 | #ifndef MBEDTLS_DEBUG_H |
| 23 | #define MBEDTLS_DEBUG_H |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 24 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 25 | #include "mbedtls/build_info.h" |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 26 | |
Jaeden Amero | 6609aef | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 27 | #include "mbedtls/ssl.h" |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 28 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 29 | #if defined(MBEDTLS_ECP_C) |
Jaeden Amero | 6609aef | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 30 | #include "mbedtls/ecp.h" |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 31 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 32 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 33 | #if defined(MBEDTLS_DEBUG_C) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 34 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 35 | #define MBEDTLS_DEBUG_STRIP_PARENS(...) __VA_ARGS__ |
Manuel Pégourié-Gonnard | b74c245 | 2015-06-29 20:08:23 +0200 | [diff] [blame] | 36 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 37 | #define MBEDTLS_SSL_DEBUG_MSG(level, args) \ |
| 38 | mbedtls_debug_print_msg(ssl, level, __FILE__, __LINE__, \ |
| 39 | MBEDTLS_DEBUG_STRIP_PARENS args) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 40 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 41 | #define MBEDTLS_SSL_DEBUG_RET(level, text, ret) \ |
| 42 | mbedtls_debug_print_ret(ssl, level, __FILE__, __LINE__, text, ret) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 43 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 44 | #define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) \ |
| 45 | mbedtls_debug_print_buf(ssl, level, __FILE__, __LINE__, text, buf, len) |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 46 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 47 | #if defined(MBEDTLS_BIGNUM_C) |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 48 | #define MBEDTLS_SSL_DEBUG_MPI(level, text, X) \ |
| 49 | mbedtls_debug_print_mpi(ssl, level, __FILE__, __LINE__, text, X) |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 50 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 51 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 52 | #if defined(MBEDTLS_ECP_C) |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 53 | #define MBEDTLS_SSL_DEBUG_ECP(level, text, X) \ |
| 54 | mbedtls_debug_print_ecp(ssl, level, __FILE__, __LINE__, text, X) |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 55 | #endif |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 56 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 57 | #if defined(MBEDTLS_X509_CRT_PARSE_C) |
Hanno Becker | 612a2f1 | 2020-10-09 09:19:39 +0100 | [diff] [blame] | 58 | #if !defined(MBEDTLS_X509_REMOVE_INFO) |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 59 | #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) \ |
| 60 | mbedtls_debug_print_crt(ssl, level, __FILE__, __LINE__, text, crt) |
Peter Kolbus | 9a969b6 | 2018-12-11 13:55:56 -0600 | [diff] [blame] | 61 | #else |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 62 | #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0) |
Hanno Becker | 612a2f1 | 2020-10-09 09:19:39 +0100 | [diff] [blame] | 63 | #endif /* MBEDTLS_X509_REMOVE_INFO */ |
Peter Kolbus | 9a969b6 | 2018-12-11 13:55:56 -0600 | [diff] [blame] | 64 | #endif /* MBEDTLS_X509_CRT_PARSE_C */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 65 | |
Janos Follath | 948f4be | 2018-08-22 01:37:55 +0100 | [diff] [blame] | 66 | #if defined(MBEDTLS_ECDH_C) |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 67 | #define MBEDTLS_SSL_DEBUG_ECDH(level, ecdh, attr) \ |
| 68 | mbedtls_debug_printf_ecdh(ssl, level, __FILE__, __LINE__, ecdh, attr) |
Janos Follath | 948f4be | 2018-08-22 01:37:55 +0100 | [diff] [blame] | 69 | #endif |
| 70 | |
Pengyu Lv | 5b8dcd2 | 2022-11-17 15:11:39 +0800 | [diff] [blame] | 71 | #if defined(MBEDTLS_SSL_PROTO_TLS1_3) && defined(MBEDTLS_SSL_SESSION_TICKETS) |
| 72 | #define MBEDTLS_SSL_DEBUG_TICKET_FLAGS(level, flag) \ |
| 73 | mbedtls_debug_print_ticket_flags(ssl, level, __FILE__, __LINE__, flag) |
| 74 | #endif |
| 75 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 76 | #else /* MBEDTLS_DEBUG_C */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 77 | |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 78 | #define MBEDTLS_SSL_DEBUG_MSG(level, args) do { } while (0) |
| 79 | #define MBEDTLS_SSL_DEBUG_RET(level, text, ret) do { } while (0) |
| 80 | #define MBEDTLS_SSL_DEBUG_BUF(level, text, buf, len) do { } while (0) |
| 81 | #define MBEDTLS_SSL_DEBUG_MPI(level, text, X) do { } while (0) |
| 82 | #define MBEDTLS_SSL_DEBUG_ECP(level, text, X) do { } while (0) |
| 83 | #define MBEDTLS_SSL_DEBUG_CRT(level, text, crt) do { } while (0) |
| 84 | #define MBEDTLS_SSL_DEBUG_ECDH(level, ecdh, attr) do { } while (0) |
Pengyu Lv | a1aa31b | 2022-12-13 13:49:59 +0800 | [diff] [blame] | 85 | #if defined(MBEDTLS_SSL_PROTO_TLS1_3) && defined(MBEDTLS_SSL_SESSION_TICKETS) |
Pengyu Lv | 5b8dcd2 | 2022-11-17 15:11:39 +0800 | [diff] [blame] | 86 | #define MBEDTLS_SSL_DEBUG_TICKET_FLAGS(level, flag) do { } while (0) |
Pengyu Lv | a1aa31b | 2022-12-13 13:49:59 +0800 | [diff] [blame] | 87 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 88 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 89 | #endif /* MBEDTLS_DEBUG_C */ |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 90 | |
Paul Elliott | 4e58970 | 2020-12-09 14:38:01 +0000 | [diff] [blame] | 91 | /** |
| 92 | * \def MBEDTLS_PRINTF_ATTRIBUTE |
| 93 | * |
| 94 | * Mark a function as having printf attributes, and thus enable checking |
Paul Elliott | aa5e132 | 2021-03-05 15:52:25 +0000 | [diff] [blame] | 95 | * via -wFormat and other flags. This does nothing on builds with compilers |
| 96 | * that do not support the format attribute |
Paul Elliott | 4e58970 | 2020-12-09 14:38:01 +0000 | [diff] [blame] | 97 | * |
| 98 | * Module: library/debug.c |
| 99 | * Caller: |
| 100 | * |
| 101 | * This module provides debugging functions. |
| 102 | */ |
Paul Elliott | aa5e132 | 2021-03-05 15:52:25 +0000 | [diff] [blame] | 103 | #if defined(__has_attribute) |
| 104 | #if __has_attribute(format) |
eugene | e42a50d | 2021-05-12 12:33:36 -0400 | [diff] [blame] | 105 | #if defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1 |
Paul Elliott | 4e58970 | 2020-12-09 14:38:01 +0000 | [diff] [blame] | 106 | #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 107 | __attribute__((__format__(gnu_printf, string_index, first_to_check))) |
eugene | e42a50d | 2021-05-12 12:33:36 -0400 | [diff] [blame] | 108 | #else /* defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 1 */ |
| 109 | #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) \ |
| 110 | __attribute__((format(printf, string_index, first_to_check))) |
| 111 | #endif |
Paul Elliott | aa5e132 | 2021-03-05 15:52:25 +0000 | [diff] [blame] | 112 | #else /* __has_attribute(format) */ |
| 113 | #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) |
| 114 | #endif /* __has_attribute(format) */ |
| 115 | #else /* defined(__has_attribute) */ |
Paul Elliott | abb3af7 | 2020-12-18 16:43:22 +0000 | [diff] [blame] | 116 | #define MBEDTLS_PRINTF_ATTRIBUTE(string_index, first_to_check) |
Paul Elliott | 4e58970 | 2020-12-09 14:38:01 +0000 | [diff] [blame] | 117 | #endif |
| 118 | |
Paul Elliott | d48d5c6 | 2021-01-07 14:47:05 +0000 | [diff] [blame] | 119 | /** |
| 120 | * \def MBEDTLS_PRINTF_SIZET |
| 121 | * |
| 122 | * MBEDTLS_PRINTF_xxx: Due to issues with older window compilers |
| 123 | * and MinGW we need to define the printf specifier for size_t |
| 124 | * and long long per platform. |
| 125 | * |
| 126 | * Module: library/debug.c |
| 127 | * Caller: |
| 128 | * |
| 129 | * This module provides debugging functions. |
| 130 | */ |
eugene | e42a50d | 2021-05-12 12:33:36 -0400 | [diff] [blame] | 131 | #if (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) |
Paul Elliott | 48438c7 | 2021-01-08 17:05:25 +0000 | [diff] [blame] | 132 | #include <inttypes.h> |
| 133 | #define MBEDTLS_PRINTF_SIZET PRIuPTR |
| 134 | #define MBEDTLS_PRINTF_LONGLONG "I64d" |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 135 | #else \ |
| 136 | /* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */ |
Paul Elliott | d48d5c6 | 2021-01-07 14:47:05 +0000 | [diff] [blame] | 137 | #define MBEDTLS_PRINTF_SIZET "zu" |
| 138 | #define MBEDTLS_PRINTF_LONGLONG "lld" |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 139 | #endif \ |
| 140 | /* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */ |
Paul Elliott | d48d5c6 | 2021-01-07 14:47:05 +0000 | [diff] [blame] | 141 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 142 | #ifdef __cplusplus |
| 143 | extern "C" { |
| 144 | #endif |
| 145 | |
Paul Bakker | c73079a | 2014-04-25 16:34:30 +0200 | [diff] [blame] | 146 | /** |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 147 | * \brief Set the threshold error level to handle globally all debug output. |
| 148 | * Debug messages that have a level over the threshold value are |
| 149 | * discarded. |
| 150 | * (Default value: 0 = No debug ) |
Paul Bakker | c73079a | 2014-04-25 16:34:30 +0200 | [diff] [blame] | 151 | * |
Shaun Case | 8b0ecbc | 2021-12-20 21:14:10 -0800 | [diff] [blame] | 152 | * \param threshold threshold level of messages to filter on. Messages at a |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 153 | * higher level will be discarded. |
| 154 | * - Debug levels |
| 155 | * - 0 No debug |
| 156 | * - 1 Error |
| 157 | * - 2 State change |
| 158 | * - 3 Informational |
| 159 | * - 4 Verbose |
Paul Bakker | c73079a | 2014-04-25 16:34:30 +0200 | [diff] [blame] | 160 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 161 | void mbedtls_debug_set_threshold(int threshold); |
Paul Bakker | c73079a | 2014-04-25 16:34:30 +0200 | [diff] [blame] | 162 | |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 163 | /** |
Janos Follath | d75b782 | 2016-03-18 16:28:20 +0000 | [diff] [blame] | 164 | * \brief Print a message to the debug output. This function is always used |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 165 | * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl |
| 166 | * context, file and line number parameters. |
| 167 | * |
| 168 | * \param ssl SSL context |
| 169 | * \param level error level of the debug message |
| 170 | * \param file file the message has occurred in |
| 171 | * \param line line number the message has occurred at |
| 172 | * \param format format specifier, in printf format |
| 173 | * \param ... variables used by the format specifier |
| 174 | * |
| 175 | * \attention This function is intended for INTERNAL usage within the |
| 176 | * library only. |
| 177 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 178 | void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level, |
| 179 | const char *file, int line, |
| 180 | const char *format, ...) MBEDTLS_PRINTF_ATTRIBUTE(5, 6); |
Manuel Pégourié-Gonnard | d23f593 | 2015-06-23 12:04:52 +0200 | [diff] [blame] | 181 | |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 182 | /** |
| 183 | * \brief Print the return value of a function to the debug output. This |
| 184 | * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro, |
| 185 | * which supplies the ssl context, file and line number parameters. |
| 186 | * |
| 187 | * \param ssl SSL context |
| 188 | * \param level error level of the debug message |
| 189 | * \param file file the error has occurred in |
| 190 | * \param line line number the error has occurred in |
| 191 | * \param text the name of the function that returned the error |
| 192 | * \param ret the return code value |
| 193 | * |
| 194 | * \attention This function is intended for INTERNAL usage within the |
| 195 | * library only. |
| 196 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 197 | void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level, |
| 198 | const char *file, int line, |
| 199 | const char *text, int ret); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 200 | |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 201 | /** |
| 202 | * \brief Output a buffer of size len bytes to the debug output. This function |
| 203 | * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro, |
| 204 | * which supplies the ssl context, file and line number parameters. |
| 205 | * |
| 206 | * \param ssl SSL context |
| 207 | * \param level error level of the debug message |
| 208 | * \param file file the error has occurred in |
| 209 | * \param line line number the error has occurred in |
| 210 | * \param text a name or label for the buffer being dumped. Normally the |
| 211 | * variable or buffer name |
| 212 | * \param buf the buffer to be outputted |
| 213 | * \param len length of the buffer |
| 214 | * |
| 215 | * \attention This function is intended for INTERNAL usage within the |
| 216 | * library only. |
| 217 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 218 | void mbedtls_debug_print_buf(const mbedtls_ssl_context *ssl, int level, |
| 219 | const char *file, int line, const char *text, |
| 220 | const unsigned char *buf, size_t len); |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 221 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 222 | #if defined(MBEDTLS_BIGNUM_C) |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 223 | /** |
| 224 | * \brief Print a MPI variable to the debug output. This function is always |
| 225 | * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the |
| 226 | * ssl context, file and line number parameters. |
| 227 | * |
| 228 | * \param ssl SSL context |
| 229 | * \param level error level of the debug message |
| 230 | * \param file file the error has occurred in |
| 231 | * \param line line number the error has occurred in |
| 232 | * \param text a name or label for the MPI being output. Normally the |
| 233 | * variable name |
| 234 | * \param X the MPI variable |
| 235 | * |
| 236 | * \attention This function is intended for INTERNAL usage within the |
| 237 | * library only. |
| 238 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 239 | void mbedtls_debug_print_mpi(const mbedtls_ssl_context *ssl, int level, |
| 240 | const char *file, int line, |
| 241 | const char *text, const mbedtls_mpi *X); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 242 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 243 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 244 | #if defined(MBEDTLS_ECP_C) |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 245 | /** |
| 246 | * \brief Print an ECP point to the debug output. This function is always |
| 247 | * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the |
| 248 | * ssl context, file and line number parameters. |
| 249 | * |
| 250 | * \param ssl SSL context |
| 251 | * \param level error level of the debug message |
| 252 | * \param file file the error has occurred in |
| 253 | * \param line line number the error has occurred in |
| 254 | * \param text a name or label for the ECP point being output. Normally the |
| 255 | * variable name |
| 256 | * \param X the ECP point |
| 257 | * |
| 258 | * \attention This function is intended for INTERNAL usage within the |
| 259 | * library only. |
| 260 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 261 | void mbedtls_debug_print_ecp(const mbedtls_ssl_context *ssl, int level, |
| 262 | const char *file, int line, |
| 263 | const char *text, const mbedtls_ecp_point *X); |
Paul Bakker | 41c83d3 | 2013-03-20 14:39:14 +0100 | [diff] [blame] | 264 | #endif |
| 265 | |
Hanno Becker | 612a2f1 | 2020-10-09 09:19:39 +0100 | [diff] [blame] | 266 | #if defined(MBEDTLS_X509_CRT_PARSE_C) && !defined(MBEDTLS_X509_REMOVE_INFO) |
Simon Butcher | 7ef5cf3 | 2016-02-13 22:20:04 +0000 | [diff] [blame] | 267 | /** |
| 268 | * \brief Print a X.509 certificate structure to the debug output. This |
| 269 | * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro, |
| 270 | * which supplies the ssl context, file and line number parameters. |
| 271 | * |
| 272 | * \param ssl SSL context |
| 273 | * \param level error level of the debug message |
| 274 | * \param file file the error has occurred in |
| 275 | * \param line line number the error has occurred in |
| 276 | * \param text a name or label for the certificate being output |
| 277 | * \param crt X.509 certificate structure |
| 278 | * |
| 279 | * \attention This function is intended for INTERNAL usage within the |
| 280 | * library only. |
| 281 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 282 | void mbedtls_debug_print_crt(const mbedtls_ssl_context *ssl, int level, |
| 283 | const char *file, int line, |
| 284 | const char *text, const mbedtls_x509_crt *crt); |
Paul Bakker | ed27a04 | 2013-04-18 22:46:23 +0200 | [diff] [blame] | 285 | #endif |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 286 | |
Janos Follath | 948f4be | 2018-08-22 01:37:55 +0100 | [diff] [blame] | 287 | #if defined(MBEDTLS_ECDH_C) |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 288 | typedef enum { |
Janos Follath | 948f4be | 2018-08-22 01:37:55 +0100 | [diff] [blame] | 289 | MBEDTLS_DEBUG_ECDH_Q, |
| 290 | MBEDTLS_DEBUG_ECDH_QP, |
| 291 | MBEDTLS_DEBUG_ECDH_Z, |
| 292 | } mbedtls_debug_ecdh_attr; |
| 293 | |
| 294 | /** |
| 295 | * \brief Print a field of the ECDH structure in the SSL context to the debug |
| 296 | * output. This function is always used through the |
| 297 | * MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file |
| 298 | * and line number parameters. |
| 299 | * |
| 300 | * \param ssl SSL context |
| 301 | * \param level error level of the debug message |
| 302 | * \param file file the error has occurred in |
| 303 | * \param line line number the error has occurred in |
| 304 | * \param ecdh the ECDH context |
| 305 | * \param attr the identifier of the attribute being output |
| 306 | * |
| 307 | * \attention This function is intended for INTERNAL usage within the |
| 308 | * library only. |
| 309 | */ |
Gilles Peskine | 449bd83 | 2023-01-11 14:50:10 +0100 | [diff] [blame] | 310 | void mbedtls_debug_printf_ecdh(const mbedtls_ssl_context *ssl, int level, |
| 311 | const char *file, int line, |
| 312 | const mbedtls_ecdh_context *ecdh, |
| 313 | mbedtls_debug_ecdh_attr attr); |
Janos Follath | 948f4be | 2018-08-22 01:37:55 +0100 | [diff] [blame] | 314 | #endif |
| 315 | |
Pengyu Lv | 5b8dcd2 | 2022-11-17 15:11:39 +0800 | [diff] [blame] | 316 | #if defined(MBEDTLS_SSL_PROTO_TLS1_3) && defined(MBEDTLS_SSL_SESSION_TICKETS) |
| 317 | void mbedtls_debug_print_ticket_flags( |
| 318 | const mbedtls_ssl_context *ssl, int level, |
| 319 | const char *file, int line, |
| 320 | mbedtls_ssl_tls13_ticket_flags flag); |
| 321 | #endif /* MBEDTLS_SSL_PROTO_TLS1_3 && MBEDTLS_SSL_SESSION_TICKETS */ |
| 322 | |
Paul Bakker | 5121ce5 | 2009-01-03 21:22:43 +0000 | [diff] [blame] | 323 | #ifdef __cplusplus |
| 324 | } |
| 325 | #endif |
| 326 | |
| 327 | #endif /* debug.h */ |