blob: 3ffcee12bce5a0d10e90df747b814b13200fc58f [file] [log] [blame]
Valerio Settib4f50762024-01-17 10:24:52 +01001/**
2 * \file debug_internal.h
3 *
4 * \brief Internal part of the public "debug.h".
5 */
6/*
7 * Copyright The Mbed TLS Contributors
8 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
9 */
10#ifndef MBEDTLS_DEBUG_INTERNAL_H
11#define MBEDTLS_DEBUG_INTERNAL_H
12
13#include "mbedtls/debug.h"
14
15/**
16 * \brief Print a message to the debug output. This function is always used
17 * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl
18 * context, file and line number parameters.
19 *
20 * \param ssl SSL context
21 * \param level error level of the debug message
22 * \param file file the message has occurred in
23 * \param line line number the message has occurred at
24 * \param format format specifier, in printf format
25 * \param ... variables used by the format specifier
26 *
27 * \attention This function is intended for INTERNAL usage within the
28 * library only.
29 */
30void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level,
31 const char *file, int line,
32 const char *format, ...) MBEDTLS_PRINTF_ATTRIBUTE(5, 6);
33
34/**
35 * \brief Print the return value of a function to the debug output. This
36 * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro,
37 * which supplies the ssl context, file and line number parameters.
38 *
39 * \param ssl SSL context
40 * \param level error level of the debug message
41 * \param file file the error has occurred in
42 * \param line line number the error has occurred in
43 * \param text the name of the function that returned the error
44 * \param ret the return code value
45 *
46 * \attention This function is intended for INTERNAL usage within the
47 * library only.
48 */
49void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level,
50 const char *file, int line,
51 const char *text, int ret);
52
53/**
54 * \brief Output a buffer of size len bytes to the debug output. This function
55 * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro,
56 * which supplies the ssl context, file and line number parameters.
57 *
58 * \param ssl SSL context
59 * \param level error level of the debug message
60 * \param file file the error has occurred in
61 * \param line line number the error has occurred in
62 * \param text a name or label for the buffer being dumped. Normally the
63 * variable or buffer name
64 * \param buf the buffer to be outputted
65 * \param len length of the buffer
66 *
67 * \attention This function is intended for INTERNAL usage within the
68 * library only.
69 */
70void mbedtls_debug_print_buf(const mbedtls_ssl_context *ssl, int level,
71 const char *file, int line, const char *text,
72 const unsigned char *buf, size_t len);
73
74#if defined(MBEDTLS_BIGNUM_C)
75/**
76 * \brief Print a MPI variable to the debug output. This function is always
77 * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the
78 * ssl context, file and line number parameters.
79 *
80 * \param ssl SSL context
81 * \param level error level of the debug message
82 * \param file file the error has occurred in
83 * \param line line number the error has occurred in
84 * \param text a name or label for the MPI being output. Normally the
85 * variable name
86 * \param X the MPI variable
87 *
88 * \attention This function is intended for INTERNAL usage within the
89 * library only.
90 */
91void mbedtls_debug_print_mpi(const mbedtls_ssl_context *ssl, int level,
92 const char *file, int line,
93 const char *text, const mbedtls_mpi *X);
94#endif
95
Valerio Settib4f50762024-01-17 10:24:52 +010096#if defined(MBEDTLS_X509_CRT_PARSE_C) && !defined(MBEDTLS_X509_REMOVE_INFO)
97/**
98 * \brief Print a X.509 certificate structure to the debug output. This
99 * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro,
100 * which supplies the ssl context, file and line number parameters.
101 *
102 * \param ssl SSL context
103 * \param level error level of the debug message
104 * \param file file the error has occurred in
105 * \param line line number the error has occurred in
106 * \param text a name or label for the certificate being output
107 * \param crt X.509 certificate structure
108 *
109 * \attention This function is intended for INTERNAL usage within the
110 * library only.
111 */
112void mbedtls_debug_print_crt(const mbedtls_ssl_context *ssl, int level,
113 const char *file, int line,
114 const char *text, const mbedtls_x509_crt *crt);
115#endif
116
Valerio Settib4f50762024-01-17 10:24:52 +0100117#endif /* MBEDTLS_DEBUG_INTERNAL_H */