--- /dev/null
+/**\r
+ * \file debug.h\r
+ *\r
+ * \brief Functions for controlling and providing debug output from the library.\r
+ */\r
+/*\r
+ * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\r
+ * SPDX-License-Identifier: Apache-2.0\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may\r
+ * not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT\r
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ * This file is part of mbed TLS (https://tls.mbed.org)\r
+ */\r
+#ifndef MBEDTLS_DEBUG_H\r
+#define MBEDTLS_DEBUG_H\r
+\r
+#if !defined(MBEDTLS_CONFIG_FILE)\r
+#include "config.h"\r
+#else\r
+#include MBEDTLS_CONFIG_FILE\r
+#endif\r
+\r
+#include "ssl.h"\r
+\r
+#if defined(MBEDTLS_ECP_C)\r
+#include "ecp.h"\r
+#endif\r
+\r
+#if defined(MBEDTLS_DEBUG_C)\r
+\r
+#define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__\r
+\r
+#define MBEDTLS_SSL_DEBUG_MSG( level, args ) \\r
+ mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \\r
+ MBEDTLS_DEBUG_STRIP_PARENS args )\r
+\r
+#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \\r
+ mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )\r
+\r
+#define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \\r
+ mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len )\r
+\r
+#if defined(MBEDTLS_BIGNUM_C)\r
+#define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \\r
+ mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X )\r
+#endif\r
+\r
+#if defined(MBEDTLS_ECP_C)\r
+#define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \\r
+ mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X )\r
+#endif\r
+\r
+#if defined(MBEDTLS_X509_CRT_PARSE_C)\r
+#define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \\r
+ mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt )\r
+#endif\r
+\r
+#if defined(MBEDTLS_ECDH_C)\r
+#define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) \\r
+ mbedtls_debug_printf_ecdh( ssl, level, __FILE__, __LINE__, ecdh, attr )\r
+#endif\r
+\r
+#else /* MBEDTLS_DEBUG_C */\r
+\r
+#define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 )\r
+#define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )\r
+#define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )\r
+#define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )\r
+#define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )\r
+#define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )\r
+#define MBEDTLS_SSL_DEBUG_ECDH( level, ecdh, attr ) do { } while( 0 )\r
+\r
+#endif /* MBEDTLS_DEBUG_C */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/**\r
+ * \brief Set the threshold error level to handle globally all debug output.\r
+ * Debug messages that have a level over the threshold value are\r
+ * discarded.\r
+ * (Default value: 0 = No debug )\r
+ *\r
+ * \param threshold theshold level of messages to filter on. Messages at a\r
+ * higher level will be discarded.\r
+ * - Debug levels\r
+ * - 0 No debug\r
+ * - 1 Error\r
+ * - 2 State change\r
+ * - 3 Informational\r
+ * - 4 Verbose\r
+ */\r
+void mbedtls_debug_set_threshold( int threshold );\r
+\r
+/**\r
+ * \brief Print a message to the debug output. This function is always used\r
+ * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl\r
+ * context, file and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the message has occurred in\r
+ * \param line line number the message has occurred at\r
+ * \param format format specifier, in printf format\r
+ * \param ... variables used by the format specifier\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line,\r
+ const char *format, ... );\r
+\r
+/**\r
+ * \brief Print the return value of a function to the debug output. This\r
+ * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro,\r
+ * which supplies the ssl context, file and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the error has occurred in\r
+ * \param line line number the error has occurred in\r
+ * \param text the name of the function that returned the error\r
+ * \param ret the return code value\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line,\r
+ const char *text, int ret );\r
+\r
+/**\r
+ * \brief Output a buffer of size len bytes to the debug output. This function\r
+ * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro,\r
+ * which supplies the ssl context, file and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the error has occurred in\r
+ * \param line line number the error has occurred in\r
+ * \param text a name or label for the buffer being dumped. Normally the\r
+ * variable or buffer name\r
+ * \param buf the buffer to be outputted\r
+ * \param len length of the buffer\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line, const char *text,\r
+ const unsigned char *buf, size_t len );\r
+\r
+#if defined(MBEDTLS_BIGNUM_C)\r
+/**\r
+ * \brief Print a MPI variable to the debug output. This function is always\r
+ * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the\r
+ * ssl context, file and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the error has occurred in\r
+ * \param line line number the error has occurred in\r
+ * \param text a name or label for the MPI being output. Normally the\r
+ * variable name\r
+ * \param X the MPI variable\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line,\r
+ const char *text, const mbedtls_mpi *X );\r
+#endif\r
+\r
+#if defined(MBEDTLS_ECP_C)\r
+/**\r
+ * \brief Print an ECP point to the debug output. This function is always\r
+ * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the\r
+ * ssl context, file and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the error has occurred in\r
+ * \param line line number the error has occurred in\r
+ * \param text a name or label for the ECP point being output. Normally the\r
+ * variable name\r
+ * \param X the ECP point\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line,\r
+ const char *text, const mbedtls_ecp_point *X );\r
+#endif\r
+\r
+#if defined(MBEDTLS_X509_CRT_PARSE_C)\r
+/**\r
+ * \brief Print a X.509 certificate structure to the debug output. This\r
+ * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro,\r
+ * which supplies the ssl context, file and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the error has occurred in\r
+ * \param line line number the error has occurred in\r
+ * \param text a name or label for the certificate being output\r
+ * \param crt X.509 certificate structure\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line,\r
+ const char *text, const mbedtls_x509_crt *crt );\r
+#endif\r
+\r
+#if defined(MBEDTLS_ECDH_C)\r
+typedef enum\r
+{\r
+ MBEDTLS_DEBUG_ECDH_Q,\r
+ MBEDTLS_DEBUG_ECDH_QP,\r
+ MBEDTLS_DEBUG_ECDH_Z,\r
+} mbedtls_debug_ecdh_attr;\r
+\r
+/**\r
+ * \brief Print a field of the ECDH structure in the SSL context to the debug\r
+ * output. This function is always used through the\r
+ * MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file\r
+ * and line number parameters.\r
+ *\r
+ * \param ssl SSL context\r
+ * \param level error level of the debug message\r
+ * \param file file the error has occurred in\r
+ * \param line line number the error has occurred in\r
+ * \param ecdh the ECDH context\r
+ * \param attr the identifier of the attribute being output\r
+ *\r
+ * \attention This function is intended for INTERNAL usage within the\r
+ * library only.\r
+ */\r
+void mbedtls_debug_printf_ecdh( const mbedtls_ssl_context *ssl, int level,\r
+ const char *file, int line,\r
+ const mbedtls_ecdh_context *ecdh,\r
+ mbedtls_debug_ecdh_attr attr );\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* debug.h */\r