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