mbed TLS Build

Dependents:   Slave-prot-prod

Committer:
williequesada
Date:
Tue Jun 04 16:03:38 2019 +0000
Revision:
1:1a219dea6cb5
Parent:
0:cdf462088d13
compartir a Pablo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
markrad 0:cdf462088d13 1 /**
markrad 0:cdf462088d13 2 * \file debug.h
markrad 0:cdf462088d13 3 *
markrad 0:cdf462088d13 4 * \brief Functions for controlling and providing debug output from the library.
markrad 0:cdf462088d13 5 *
markrad 0:cdf462088d13 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
markrad 0:cdf462088d13 7 * SPDX-License-Identifier: Apache-2.0
markrad 0:cdf462088d13 8 *
markrad 0:cdf462088d13 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
markrad 0:cdf462088d13 10 * not use this file except in compliance with the License.
markrad 0:cdf462088d13 11 * You may obtain a copy of the License at
markrad 0:cdf462088d13 12 *
markrad 0:cdf462088d13 13 * http://www.apache.org/licenses/LICENSE-2.0
markrad 0:cdf462088d13 14 *
markrad 0:cdf462088d13 15 * Unless required by applicable law or agreed to in writing, software
markrad 0:cdf462088d13 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
markrad 0:cdf462088d13 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
markrad 0:cdf462088d13 18 * See the License for the specific language governing permissions and
markrad 0:cdf462088d13 19 * limitations under the License.
markrad 0:cdf462088d13 20 *
markrad 0:cdf462088d13 21 * This file is part of mbed TLS (https://tls.mbed.org)
markrad 0:cdf462088d13 22 */
markrad 0:cdf462088d13 23 #ifndef MBEDTLS_DEBUG_H
markrad 0:cdf462088d13 24 #define MBEDTLS_DEBUG_H
markrad 0:cdf462088d13 25
markrad 0:cdf462088d13 26 #if !defined(MBEDTLS_CONFIG_FILE)
markrad 0:cdf462088d13 27 #include "config.h"
markrad 0:cdf462088d13 28 #else
markrad 0:cdf462088d13 29 #include MBEDTLS_CONFIG_FILE
markrad 0:cdf462088d13 30 #endif
markrad 0:cdf462088d13 31
markrad 0:cdf462088d13 32 #include "ssl.h"
markrad 0:cdf462088d13 33
markrad 0:cdf462088d13 34 #if defined(MBEDTLS_ECP_C)
markrad 0:cdf462088d13 35 #include "ecp.h"
markrad 0:cdf462088d13 36 #endif
markrad 0:cdf462088d13 37
markrad 0:cdf462088d13 38 #if defined(MBEDTLS_DEBUG_C)
markrad 0:cdf462088d13 39
markrad 0:cdf462088d13 40 #define MBEDTLS_DEBUG_STRIP_PARENS( ... ) __VA_ARGS__
markrad 0:cdf462088d13 41
markrad 0:cdf462088d13 42 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) \
markrad 0:cdf462088d13 43 mbedtls_debug_print_msg( ssl, level, __FILE__, __LINE__, \
markrad 0:cdf462088d13 44 MBEDTLS_DEBUG_STRIP_PARENS args )
markrad 0:cdf462088d13 45
markrad 0:cdf462088d13 46 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) \
markrad 0:cdf462088d13 47 mbedtls_debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret )
markrad 0:cdf462088d13 48
markrad 0:cdf462088d13 49 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) \
markrad 0:cdf462088d13 50 mbedtls_debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len )
markrad 0:cdf462088d13 51
markrad 0:cdf462088d13 52 #if defined(MBEDTLS_BIGNUM_C)
markrad 0:cdf462088d13 53 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) \
markrad 0:cdf462088d13 54 mbedtls_debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X )
markrad 0:cdf462088d13 55 #endif
markrad 0:cdf462088d13 56
markrad 0:cdf462088d13 57 #if defined(MBEDTLS_ECP_C)
markrad 0:cdf462088d13 58 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) \
markrad 0:cdf462088d13 59 mbedtls_debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X )
markrad 0:cdf462088d13 60 #endif
markrad 0:cdf462088d13 61
markrad 0:cdf462088d13 62 #if defined(MBEDTLS_X509_CRT_PARSE_C)
markrad 0:cdf462088d13 63 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) \
markrad 0:cdf462088d13 64 mbedtls_debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt )
markrad 0:cdf462088d13 65 #endif
markrad 0:cdf462088d13 66
markrad 0:cdf462088d13 67 #else /* MBEDTLS_DEBUG_C */
markrad 0:cdf462088d13 68
markrad 0:cdf462088d13 69 #define MBEDTLS_SSL_DEBUG_MSG( level, args ) do { } while( 0 )
markrad 0:cdf462088d13 70 #define MBEDTLS_SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
markrad 0:cdf462088d13 71 #define MBEDTLS_SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
markrad 0:cdf462088d13 72 #define MBEDTLS_SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
markrad 0:cdf462088d13 73 #define MBEDTLS_SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
markrad 0:cdf462088d13 74 #define MBEDTLS_SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
markrad 0:cdf462088d13 75
markrad 0:cdf462088d13 76 #endif /* MBEDTLS_DEBUG_C */
markrad 0:cdf462088d13 77
markrad 0:cdf462088d13 78 #ifdef __cplusplus
markrad 0:cdf462088d13 79 extern "C" {
markrad 0:cdf462088d13 80 #endif
markrad 0:cdf462088d13 81
markrad 0:cdf462088d13 82 /**
markrad 0:cdf462088d13 83 * \brief Set the threshold error level to handle globally all debug output.
markrad 0:cdf462088d13 84 * Debug messages that have a level over the threshold value are
markrad 0:cdf462088d13 85 * discarded.
markrad 0:cdf462088d13 86 * (Default value: 0 = No debug )
markrad 0:cdf462088d13 87 *
markrad 0:cdf462088d13 88 * \param threshold theshold level of messages to filter on. Messages at a
markrad 0:cdf462088d13 89 * higher level will be discarded.
markrad 0:cdf462088d13 90 * - Debug levels
markrad 0:cdf462088d13 91 * - 0 No debug
markrad 0:cdf462088d13 92 * - 1 Error
markrad 0:cdf462088d13 93 * - 2 State change
markrad 0:cdf462088d13 94 * - 3 Informational
markrad 0:cdf462088d13 95 * - 4 Verbose
markrad 0:cdf462088d13 96 */
markrad 0:cdf462088d13 97 void mbedtls_debug_set_threshold( int threshold );
markrad 0:cdf462088d13 98
markrad 0:cdf462088d13 99 /**
markrad 0:cdf462088d13 100 * \brief Print a message to the debug output. This function is always used
markrad 0:cdf462088d13 101 * through the MBEDTLS_SSL_DEBUG_MSG() macro, which supplies the ssl
markrad 0:cdf462088d13 102 * context, file and line number parameters.
markrad 0:cdf462088d13 103 *
markrad 0:cdf462088d13 104 * \param ssl SSL context
markrad 0:cdf462088d13 105 * \param level error level of the debug message
markrad 0:cdf462088d13 106 * \param file file the message has occurred in
markrad 0:cdf462088d13 107 * \param line line number the message has occurred at
markrad 0:cdf462088d13 108 * \param format format specifier, in printf format
markrad 0:cdf462088d13 109 * \param ... variables used by the format specifier
markrad 0:cdf462088d13 110 *
markrad 0:cdf462088d13 111 * \attention This function is intended for INTERNAL usage within the
markrad 0:cdf462088d13 112 * library only.
markrad 0:cdf462088d13 113 */
markrad 0:cdf462088d13 114 void mbedtls_debug_print_msg( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 115 const char *file, int line,
markrad 0:cdf462088d13 116 const char *format, ... );
markrad 0:cdf462088d13 117
markrad 0:cdf462088d13 118 /**
markrad 0:cdf462088d13 119 * \brief Print the return value of a function to the debug output. This
markrad 0:cdf462088d13 120 * function is always used through the MBEDTLS_SSL_DEBUG_RET() macro,
markrad 0:cdf462088d13 121 * which supplies the ssl context, file and line number parameters.
markrad 0:cdf462088d13 122 *
markrad 0:cdf462088d13 123 * \param ssl SSL context
markrad 0:cdf462088d13 124 * \param level error level of the debug message
markrad 0:cdf462088d13 125 * \param file file the error has occurred in
markrad 0:cdf462088d13 126 * \param line line number the error has occurred in
markrad 0:cdf462088d13 127 * \param text the name of the function that returned the error
markrad 0:cdf462088d13 128 * \param ret the return code value
markrad 0:cdf462088d13 129 *
markrad 0:cdf462088d13 130 * \attention This function is intended for INTERNAL usage within the
markrad 0:cdf462088d13 131 * library only.
markrad 0:cdf462088d13 132 */
markrad 0:cdf462088d13 133 void mbedtls_debug_print_ret( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 134 const char *file, int line,
markrad 0:cdf462088d13 135 const char *text, int ret );
markrad 0:cdf462088d13 136
markrad 0:cdf462088d13 137 /**
markrad 0:cdf462088d13 138 * \brief Output a buffer of size len bytes to the debug output. This function
markrad 0:cdf462088d13 139 * is always used through the MBEDTLS_SSL_DEBUG_BUF() macro,
markrad 0:cdf462088d13 140 * which supplies the ssl context, file and line number parameters.
markrad 0:cdf462088d13 141 *
markrad 0:cdf462088d13 142 * \param ssl SSL context
markrad 0:cdf462088d13 143 * \param level error level of the debug message
markrad 0:cdf462088d13 144 * \param file file the error has occurred in
markrad 0:cdf462088d13 145 * \param line line number the error has occurred in
markrad 0:cdf462088d13 146 * \param text a name or label for the buffer being dumped. Normally the
markrad 0:cdf462088d13 147 * variable or buffer name
markrad 0:cdf462088d13 148 * \param buf the buffer to be outputted
markrad 0:cdf462088d13 149 * \param len length of the buffer
markrad 0:cdf462088d13 150 *
markrad 0:cdf462088d13 151 * \attention This function is intended for INTERNAL usage within the
markrad 0:cdf462088d13 152 * library only.
markrad 0:cdf462088d13 153 */
markrad 0:cdf462088d13 154 void mbedtls_debug_print_buf( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 155 const char *file, int line, const char *text,
markrad 0:cdf462088d13 156 const unsigned char *buf, size_t len );
markrad 0:cdf462088d13 157
markrad 0:cdf462088d13 158 #if defined(MBEDTLS_BIGNUM_C)
markrad 0:cdf462088d13 159 /**
markrad 0:cdf462088d13 160 * \brief Print a MPI variable to the debug output. This function is always
markrad 0:cdf462088d13 161 * used through the MBEDTLS_SSL_DEBUG_MPI() macro, which supplies the
markrad 0:cdf462088d13 162 * ssl context, file and line number parameters.
markrad 0:cdf462088d13 163 *
markrad 0:cdf462088d13 164 * \param ssl SSL context
markrad 0:cdf462088d13 165 * \param level error level of the debug message
markrad 0:cdf462088d13 166 * \param file file the error has occurred in
markrad 0:cdf462088d13 167 * \param line line number the error has occurred in
markrad 0:cdf462088d13 168 * \param text a name or label for the MPI being output. Normally the
markrad 0:cdf462088d13 169 * variable name
markrad 0:cdf462088d13 170 * \param X the MPI variable
markrad 0:cdf462088d13 171 *
markrad 0:cdf462088d13 172 * \attention This function is intended for INTERNAL usage within the
markrad 0:cdf462088d13 173 * library only.
markrad 0:cdf462088d13 174 */
markrad 0:cdf462088d13 175 void mbedtls_debug_print_mpi( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 176 const char *file, int line,
markrad 0:cdf462088d13 177 const char *text, const mbedtls_mpi *X );
markrad 0:cdf462088d13 178 #endif
markrad 0:cdf462088d13 179
markrad 0:cdf462088d13 180 #if defined(MBEDTLS_ECP_C)
markrad 0:cdf462088d13 181 /**
markrad 0:cdf462088d13 182 * \brief Print an ECP point to the debug output. This function is always
markrad 0:cdf462088d13 183 * used through the MBEDTLS_SSL_DEBUG_ECP() macro, which supplies the
markrad 0:cdf462088d13 184 * ssl context, file and line number parameters.
markrad 0:cdf462088d13 185 *
markrad 0:cdf462088d13 186 * \param ssl SSL context
markrad 0:cdf462088d13 187 * \param level error level of the debug message
markrad 0:cdf462088d13 188 * \param file file the error has occurred in
markrad 0:cdf462088d13 189 * \param line line number the error has occurred in
markrad 0:cdf462088d13 190 * \param text a name or label for the ECP point being output. Normally the
markrad 0:cdf462088d13 191 * variable name
markrad 0:cdf462088d13 192 * \param X the ECP point
markrad 0:cdf462088d13 193 *
markrad 0:cdf462088d13 194 * \attention This function is intended for INTERNAL usage within the
markrad 0:cdf462088d13 195 * library only.
markrad 0:cdf462088d13 196 */
markrad 0:cdf462088d13 197 void mbedtls_debug_print_ecp( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 198 const char *file, int line,
markrad 0:cdf462088d13 199 const char *text, const mbedtls_ecp_point *X );
markrad 0:cdf462088d13 200 #endif
markrad 0:cdf462088d13 201
markrad 0:cdf462088d13 202 #if defined(MBEDTLS_X509_CRT_PARSE_C)
markrad 0:cdf462088d13 203 /**
markrad 0:cdf462088d13 204 * \brief Print a X.509 certificate structure to the debug output. This
markrad 0:cdf462088d13 205 * function is always used through the MBEDTLS_SSL_DEBUG_CRT() macro,
markrad 0:cdf462088d13 206 * which supplies the ssl context, file and line number parameters.
markrad 0:cdf462088d13 207 *
markrad 0:cdf462088d13 208 * \param ssl SSL context
markrad 0:cdf462088d13 209 * \param level error level of the debug message
markrad 0:cdf462088d13 210 * \param file file the error has occurred in
markrad 0:cdf462088d13 211 * \param line line number the error has occurred in
markrad 0:cdf462088d13 212 * \param text a name or label for the certificate being output
markrad 0:cdf462088d13 213 * \param crt X.509 certificate structure
markrad 0:cdf462088d13 214 *
markrad 0:cdf462088d13 215 * \attention This function is intended for INTERNAL usage within the
markrad 0:cdf462088d13 216 * library only.
markrad 0:cdf462088d13 217 */
markrad 0:cdf462088d13 218 void mbedtls_debug_print_crt( const mbedtls_ssl_context *ssl, int level,
markrad 0:cdf462088d13 219 const char *file, int line,
markrad 0:cdf462088d13 220 const char *text, const mbedtls_x509_crt *crt );
markrad 0:cdf462088d13 221 #endif
markrad 0:cdf462088d13 222
markrad 0:cdf462088d13 223 #ifdef __cplusplus
markrad 0:cdf462088d13 224 }
markrad 0:cdf462088d13 225 #endif
markrad 0:cdf462088d13 226
markrad 0:cdf462088d13 227 #endif /* debug.h */
markrad 0:cdf462088d13 228