1*b0563631STom Van Eyck /** 2*b0563631STom Van Eyck * \file debug_internal.h 3*b0563631STom Van Eyck * 4*b0563631STom Van Eyck * \brief Internal part of the public "debug.h". 5*b0563631STom Van Eyck */ 6*b0563631STom Van Eyck /* 7*b0563631STom Van Eyck * Copyright The Mbed TLS Contributors 8*b0563631STom Van Eyck * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 9*b0563631STom Van Eyck */ 10*b0563631STom Van Eyck #ifndef MBEDTLS_DEBUG_INTERNAL_H 11*b0563631STom Van Eyck #define MBEDTLS_DEBUG_INTERNAL_H 12*b0563631STom Van Eyck 13*b0563631STom Van Eyck #include "mbedtls/debug.h" 14*b0563631STom Van Eyck 15*b0563631STom Van Eyck /** 16*b0563631STom Van Eyck * \brief Print a message to the debug output. This function is always used 17*b0563631STom Van Eyck * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl 18*b0563631STom Van Eyck * context, file and line number parameters. 19*b0563631STom Van Eyck * 20*b0563631STom Van Eyck * \param ssl SSL context 21*b0563631STom Van Eyck * \param level error level of the debug message 22*b0563631STom Van Eyck * \param file file the message has occurred in 23*b0563631STom Van Eyck * \param line line number the message has occurred at 24*b0563631STom Van Eyck * \param format format specifier, in printf format 25*b0563631STom Van Eyck * \param ... variables used by the format specifier 26*b0563631STom Van Eyck * 27*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 28*b0563631STom Van Eyck * library only. 29*b0563631STom Van Eyck */ 30*b0563631STom Van Eyck void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level, 31*b0563631STom Van Eyck const char *file, int line, 32*b0563631STom Van Eyck const char *format, ...) MBEDTLS_PRINTF_ATTRIBUTE(5, 6); 33*b0563631STom Van Eyck 34*b0563631STom Van Eyck /** 35*b0563631STom Van Eyck * \brief Print the return value of a function to the debug output. This 36*b0563631STom Van Eyck * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro, 37*b0563631STom Van Eyck * which supplies the ssl context, file and line number parameters. 38*b0563631STom Van Eyck * 39*b0563631STom Van Eyck * \param ssl SSL context 40*b0563631STom Van Eyck * \param level error level of the debug message 41*b0563631STom Van Eyck * \param file file the error has occurred in 42*b0563631STom Van Eyck * \param line line number the error has occurred in 43*b0563631STom Van Eyck * \param text the name of the function that returned the error 44*b0563631STom Van Eyck * \param ret the return code value 45*b0563631STom Van Eyck * 46*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 47*b0563631STom Van Eyck * library only. 48*b0563631STom Van Eyck */ 49*b0563631STom Van Eyck void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level, 50*b0563631STom Van Eyck const char *file, int line, 51*b0563631STom Van Eyck const char *text, int ret); 52*b0563631STom Van Eyck 53*b0563631STom Van Eyck /** 54*b0563631STom Van Eyck * \brief Output a buffer of size len bytes to the debug output. This function 55*b0563631STom Van Eyck * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro, 56*b0563631STom Van Eyck * which supplies the ssl context, file and line number parameters. 57*b0563631STom Van Eyck * 58*b0563631STom Van Eyck * \param ssl SSL context 59*b0563631STom Van Eyck * \param level error level of the debug message 60*b0563631STom Van Eyck * \param file file the error has occurred in 61*b0563631STom Van Eyck * \param line line number the error has occurred in 62*b0563631STom Van Eyck * \param text a name or label for the buffer being dumped. Normally the 63*b0563631STom Van Eyck * variable or buffer name 64*b0563631STom Van Eyck * \param buf the buffer to be outputted 65*b0563631STom Van Eyck * \param len length of the buffer 66*b0563631STom Van Eyck * 67*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 68*b0563631STom Van Eyck * library only. 69*b0563631STom Van Eyck */ 70*b0563631STom Van Eyck void mbedtls_debug_print_buf(const mbedtls_ssl_context *ssl, int level, 71*b0563631STom Van Eyck const char *file, int line, const char *text, 72*b0563631STom Van Eyck const unsigned char *buf, size_t len); 73*b0563631STom Van Eyck 74*b0563631STom Van Eyck #if defined(MBEDTLS_BIGNUM_C) 75*b0563631STom Van Eyck /** 76*b0563631STom Van Eyck * \brief Print a MPI variable to the debug output. This function is always 77*b0563631STom Van Eyck * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the 78*b0563631STom Van Eyck * ssl context, file and line number parameters. 79*b0563631STom Van Eyck * 80*b0563631STom Van Eyck * \param ssl SSL context 81*b0563631STom Van Eyck * \param level error level of the debug message 82*b0563631STom Van Eyck * \param file file the error has occurred in 83*b0563631STom Van Eyck * \param line line number the error has occurred in 84*b0563631STom Van Eyck * \param text a name or label for the MPI being output. Normally the 85*b0563631STom Van Eyck * variable name 86*b0563631STom Van Eyck * \param X the MPI variable 87*b0563631STom Van Eyck * 88*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 89*b0563631STom Van Eyck * library only. 90*b0563631STom Van Eyck */ 91*b0563631STom Van Eyck void mbedtls_debug_print_mpi(const mbedtls_ssl_context *ssl, int level, 92*b0563631STom Van Eyck const char *file, int line, 93*b0563631STom Van Eyck const char *text, const mbedtls_mpi *X); 94*b0563631STom Van Eyck #endif 95*b0563631STom Van Eyck 96*b0563631STom Van Eyck #if defined(MBEDTLS_ECP_LIGHT) 97*b0563631STom Van Eyck /** 98*b0563631STom Van Eyck * \brief Print an ECP point to the debug output. This function is always 99*b0563631STom Van Eyck * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the 100*b0563631STom Van Eyck * ssl context, file and line number parameters. 101*b0563631STom Van Eyck * 102*b0563631STom Van Eyck * \param ssl SSL context 103*b0563631STom Van Eyck * \param level error level of the debug message 104*b0563631STom Van Eyck * \param file file the error has occurred in 105*b0563631STom Van Eyck * \param line line number the error has occurred in 106*b0563631STom Van Eyck * \param text a name or label for the ECP point being output. Normally the 107*b0563631STom Van Eyck * variable name 108*b0563631STom Van Eyck * \param X the ECP point 109*b0563631STom Van Eyck * 110*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 111*b0563631STom Van Eyck * library only. 112*b0563631STom Van Eyck */ 113*b0563631STom Van Eyck void mbedtls_debug_print_ecp(const mbedtls_ssl_context *ssl, int level, 114*b0563631STom Van Eyck const char *file, int line, 115*b0563631STom Van Eyck const char *text, const mbedtls_ecp_point *X); 116*b0563631STom Van Eyck #endif 117*b0563631STom Van Eyck 118*b0563631STom Van Eyck #if defined(MBEDTLS_X509_CRT_PARSE_C) && !defined(MBEDTLS_X509_REMOVE_INFO) 119*b0563631STom Van Eyck /** 120*b0563631STom Van Eyck * \brief Print a X.509 certificate structure to the debug output. This 121*b0563631STom Van Eyck * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro, 122*b0563631STom Van Eyck * which supplies the ssl context, file and line number parameters. 123*b0563631STom Van Eyck * 124*b0563631STom Van Eyck * \param ssl SSL context 125*b0563631STom Van Eyck * \param level error level of the debug message 126*b0563631STom Van Eyck * \param file file the error has occurred in 127*b0563631STom Van Eyck * \param line line number the error has occurred in 128*b0563631STom Van Eyck * \param text a name or label for the certificate being output 129*b0563631STom Van Eyck * \param crt X.509 certificate structure 130*b0563631STom Van Eyck * 131*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 132*b0563631STom Van Eyck * library only. 133*b0563631STom Van Eyck */ 134*b0563631STom Van Eyck void mbedtls_debug_print_crt(const mbedtls_ssl_context *ssl, int level, 135*b0563631STom Van Eyck const char *file, int line, 136*b0563631STom Van Eyck const char *text, const mbedtls_x509_crt *crt); 137*b0563631STom Van Eyck #endif 138*b0563631STom Van Eyck 139*b0563631STom Van Eyck /* Note: the MBEDTLS_ECDH_C guard here is mandatory because this debug function 140*b0563631STom Van Eyck only works for the built-in implementation. */ 141*b0563631STom Van Eyck #if defined(MBEDTLS_KEY_EXCHANGE_SOME_ECDH_OR_ECDHE_ANY_ENABLED) && \ 142*b0563631STom Van Eyck defined(MBEDTLS_ECDH_C) 143*b0563631STom Van Eyck typedef enum { 144*b0563631STom Van Eyck MBEDTLS_DEBUG_ECDH_Q, 145*b0563631STom Van Eyck MBEDTLS_DEBUG_ECDH_QP, 146*b0563631STom Van Eyck MBEDTLS_DEBUG_ECDH_Z, 147*b0563631STom Van Eyck } mbedtls_debug_ecdh_attr; 148*b0563631STom Van Eyck 149*b0563631STom Van Eyck /** 150*b0563631STom Van Eyck * \brief Print a field of the ECDH structure in the SSL context to the debug 151*b0563631STom Van Eyck * output. This function is always used through the 152*b0563631STom Van Eyck * MBEDTLS_SSL_DEBUG_ECDH() macro, which supplies the ssl context, file 153*b0563631STom Van Eyck * and line number parameters. 154*b0563631STom Van Eyck * 155*b0563631STom Van Eyck * \param ssl SSL context 156*b0563631STom Van Eyck * \param level error level of the debug message 157*b0563631STom Van Eyck * \param file file the error has occurred in 158*b0563631STom Van Eyck * \param line line number the error has occurred in 159*b0563631STom Van Eyck * \param ecdh the ECDH context 160*b0563631STom Van Eyck * \param attr the identifier of the attribute being output 161*b0563631STom Van Eyck * 162*b0563631STom Van Eyck * \attention This function is intended for INTERNAL usage within the 163*b0563631STom Van Eyck * library only. 164*b0563631STom Van Eyck */ 165*b0563631STom Van Eyck void mbedtls_debug_printf_ecdh(const mbedtls_ssl_context *ssl, int level, 166*b0563631STom Van Eyck const char *file, int line, 167*b0563631STom Van Eyck const mbedtls_ecdh_context *ecdh, 168*b0563631STom Van Eyck mbedtls_debug_ecdh_attr attr); 169*b0563631STom Van Eyck #endif /* MBEDTLS_KEY_EXCHANGE_SOME_ECDH_OR_ECDHE_ANY_ENABLED && 170*b0563631STom Van Eyck MBEDTLS_ECDH_C */ 171*b0563631STom Van Eyck 172*b0563631STom Van Eyck #endif /* MBEDTLS_DEBUG_INTERNAL_H */ 173