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