Hannes Tschofenig
/
aes-gcm-test-program
Example program to test AES-GCM functionality. Used for a workshop
SSL/include/polarssl/debug.h@0:796d0f61a05b, 2018-09-27 (annotated)
- Committer:
- HannesTschofenig
- Date:
- Thu Sep 27 06:34:22 2018 +0000
- Revision:
- 0:796d0f61a05b
Example AES-GCM test program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
HannesTschofenig | 0:796d0f61a05b | 1 | /** |
HannesTschofenig | 0:796d0f61a05b | 2 | * \file debug.h |
HannesTschofenig | 0:796d0f61a05b | 3 | * |
HannesTschofenig | 0:796d0f61a05b | 4 | * \brief Debug functions |
HannesTschofenig | 0:796d0f61a05b | 5 | * |
HannesTschofenig | 0:796d0f61a05b | 6 | * Copyright (C) 2006-2011, Brainspark B.V. |
HannesTschofenig | 0:796d0f61a05b | 7 | * |
HannesTschofenig | 0:796d0f61a05b | 8 | * This file is part of PolarSSL (http://www.polarssl.org) |
HannesTschofenig | 0:796d0f61a05b | 9 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
HannesTschofenig | 0:796d0f61a05b | 10 | * |
HannesTschofenig | 0:796d0f61a05b | 11 | * All rights reserved. |
HannesTschofenig | 0:796d0f61a05b | 12 | * |
HannesTschofenig | 0:796d0f61a05b | 13 | * This program is free software; you can redistribute it and/or modify |
HannesTschofenig | 0:796d0f61a05b | 14 | * it under the terms of the GNU General Public License as published by |
HannesTschofenig | 0:796d0f61a05b | 15 | * the Free Software Foundation; either version 2 of the License, or |
HannesTschofenig | 0:796d0f61a05b | 16 | * (at your option) any later version. |
HannesTschofenig | 0:796d0f61a05b | 17 | * |
HannesTschofenig | 0:796d0f61a05b | 18 | * This program is distributed in the hope that it will be useful, |
HannesTschofenig | 0:796d0f61a05b | 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
HannesTschofenig | 0:796d0f61a05b | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
HannesTschofenig | 0:796d0f61a05b | 21 | * GNU General Public License for more details. |
HannesTschofenig | 0:796d0f61a05b | 22 | * |
HannesTschofenig | 0:796d0f61a05b | 23 | * You should have received a copy of the GNU General Public License along |
HannesTschofenig | 0:796d0f61a05b | 24 | * with this program; if not, write to the Free Software Foundation, Inc., |
HannesTschofenig | 0:796d0f61a05b | 25 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
HannesTschofenig | 0:796d0f61a05b | 26 | */ |
HannesTschofenig | 0:796d0f61a05b | 27 | #ifndef POLARSSL_DEBUG_H |
HannesTschofenig | 0:796d0f61a05b | 28 | #define POLARSSL_DEBUG_H |
HannesTschofenig | 0:796d0f61a05b | 29 | |
HannesTschofenig | 0:796d0f61a05b | 30 | #if !defined(POLARSSL_CONFIG_FILE) |
HannesTschofenig | 0:796d0f61a05b | 31 | #include "config.h" |
HannesTschofenig | 0:796d0f61a05b | 32 | #else |
HannesTschofenig | 0:796d0f61a05b | 33 | #include POLARSSL_CONFIG_FILE |
HannesTschofenig | 0:796d0f61a05b | 34 | #endif |
HannesTschofenig | 0:796d0f61a05b | 35 | #include "ssl.h" |
HannesTschofenig | 0:796d0f61a05b | 36 | #if defined(POLARSSL_ECP_C) |
HannesTschofenig | 0:796d0f61a05b | 37 | #include "ecp.h" |
HannesTschofenig | 0:796d0f61a05b | 38 | #endif |
HannesTschofenig | 0:796d0f61a05b | 39 | |
HannesTschofenig | 0:796d0f61a05b | 40 | #if defined(POLARSSL_DEBUG_C) |
HannesTschofenig | 0:796d0f61a05b | 41 | |
HannesTschofenig | 0:796d0f61a05b | 42 | #define POLARSSL_DEBUG_LOG_FULL 0 /**< Include file:line in log lines */ |
HannesTschofenig | 0:796d0f61a05b | 43 | #define POLARSSL_DEBUG_LOG_RAW 1 /**< Only log raw debug lines */ |
HannesTschofenig | 0:796d0f61a05b | 44 | |
HannesTschofenig | 0:796d0f61a05b | 45 | /** |
HannesTschofenig | 0:796d0f61a05b | 46 | * \name SECTION: Module settings |
HannesTschofenig | 0:796d0f61a05b | 47 | * |
HannesTschofenig | 0:796d0f61a05b | 48 | * The configuration options you can set for this module are in this section. |
HannesTschofenig | 0:796d0f61a05b | 49 | * Either change them in config.h or define them on the compiler command line. |
HannesTschofenig | 0:796d0f61a05b | 50 | * \{ |
HannesTschofenig | 0:796d0f61a05b | 51 | */ |
HannesTschofenig | 0:796d0f61a05b | 52 | |
HannesTschofenig | 0:796d0f61a05b | 53 | #if !defined(POLARSSL_DEBUG_DFL_MODE) |
HannesTschofenig | 0:796d0f61a05b | 54 | #define POLARSSL_DEBUG_DFL_MODE POLARSSL_DEBUG_LOG_FULL /**< Default log: Full or Raw */ |
HannesTschofenig | 0:796d0f61a05b | 55 | #endif |
HannesTschofenig | 0:796d0f61a05b | 56 | |
HannesTschofenig | 0:796d0f61a05b | 57 | /* \} name SECTION: Module settings */ |
HannesTschofenig | 0:796d0f61a05b | 58 | |
HannesTschofenig | 0:796d0f61a05b | 59 | |
HannesTschofenig | 0:796d0f61a05b | 60 | #define SSL_DEBUG_MSG( level, args ) \ |
HannesTschofenig | 0:796d0f61a05b | 61 | debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args ); |
HannesTschofenig | 0:796d0f61a05b | 62 | |
HannesTschofenig | 0:796d0f61a05b | 63 | #define SSL_DEBUG_RET( level, text, ret ) \ |
HannesTschofenig | 0:796d0f61a05b | 64 | debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret ); |
HannesTschofenig | 0:796d0f61a05b | 65 | |
HannesTschofenig | 0:796d0f61a05b | 66 | #define SSL_DEBUG_BUF( level, text, buf, len ) \ |
HannesTschofenig | 0:796d0f61a05b | 67 | debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len ); |
HannesTschofenig | 0:796d0f61a05b | 68 | |
HannesTschofenig | 0:796d0f61a05b | 69 | #if defined(POLARSSL_BIGNUM_C) |
HannesTschofenig | 0:796d0f61a05b | 70 | #define SSL_DEBUG_MPI( level, text, X ) \ |
HannesTschofenig | 0:796d0f61a05b | 71 | debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X ); |
HannesTschofenig | 0:796d0f61a05b | 72 | #endif |
HannesTschofenig | 0:796d0f61a05b | 73 | |
HannesTschofenig | 0:796d0f61a05b | 74 | #if defined(POLARSSL_ECP_C) |
HannesTschofenig | 0:796d0f61a05b | 75 | #define SSL_DEBUG_ECP( level, text, X ) \ |
HannesTschofenig | 0:796d0f61a05b | 76 | debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X ); |
HannesTschofenig | 0:796d0f61a05b | 77 | #endif |
HannesTschofenig | 0:796d0f61a05b | 78 | |
HannesTschofenig | 0:796d0f61a05b | 79 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
HannesTschofenig | 0:796d0f61a05b | 80 | #define SSL_DEBUG_CRT( level, text, crt ) \ |
HannesTschofenig | 0:796d0f61a05b | 81 | debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt ); |
HannesTschofenig | 0:796d0f61a05b | 82 | #endif |
HannesTschofenig | 0:796d0f61a05b | 83 | |
HannesTschofenig | 0:796d0f61a05b | 84 | #else /* POLARSSL_DEBUG_ C */ |
HannesTschofenig | 0:796d0f61a05b | 85 | |
HannesTschofenig | 0:796d0f61a05b | 86 | #define SSL_DEBUG_MSG( level, args ) do { } while( 0 ) |
HannesTschofenig | 0:796d0f61a05b | 87 | #define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 ) |
HannesTschofenig | 0:796d0f61a05b | 88 | #define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 ) |
HannesTschofenig | 0:796d0f61a05b | 89 | #define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 ) |
HannesTschofenig | 0:796d0f61a05b | 90 | #define SSL_DEBUG_ECP( level, text, X ) do { } while( 0 ) |
HannesTschofenig | 0:796d0f61a05b | 91 | #define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 ) |
HannesTschofenig | 0:796d0f61a05b | 92 | |
HannesTschofenig | 0:796d0f61a05b | 93 | #endif /* POLARSSL_DEBUG_C */ |
HannesTschofenig | 0:796d0f61a05b | 94 | |
HannesTschofenig | 0:796d0f61a05b | 95 | #ifdef __cplusplus |
HannesTschofenig | 0:796d0f61a05b | 96 | extern "C" { |
HannesTschofenig | 0:796d0f61a05b | 97 | #endif |
HannesTschofenig | 0:796d0f61a05b | 98 | |
HannesTschofenig | 0:796d0f61a05b | 99 | /** |
HannesTschofenig | 0:796d0f61a05b | 100 | * \brief Set the log mode for the debug functions globally |
HannesTschofenig | 0:796d0f61a05b | 101 | * (Default value: POLARSSL_DEBUG_DFL_MODE) |
HannesTschofenig | 0:796d0f61a05b | 102 | * |
HannesTschofenig | 0:796d0f61a05b | 103 | * \param log_mode The log mode to use (POLARSSL_DEBUG_LOG_FULL or |
HannesTschofenig | 0:796d0f61a05b | 104 | * POLARSSL_DEBUG_LOG_RAW) |
HannesTschofenig | 0:796d0f61a05b | 105 | */ |
HannesTschofenig | 0:796d0f61a05b | 106 | void debug_set_log_mode( int log_mode ); |
HannesTschofenig | 0:796d0f61a05b | 107 | |
HannesTschofenig | 0:796d0f61a05b | 108 | /** |
HannesTschofenig | 0:796d0f61a05b | 109 | * \brief Set the level threshold to handle globally. Messages that have a |
HannesTschofenig | 0:796d0f61a05b | 110 | * level over the threshold value are ignored. |
HannesTschofenig | 0:796d0f61a05b | 111 | * (Default value: 0 (No debug)) |
HannesTschofenig | 0:796d0f61a05b | 112 | * |
HannesTschofenig | 0:796d0f61a05b | 113 | * \param threshold maximum level of messages to pass on |
HannesTschofenig | 0:796d0f61a05b | 114 | */ |
HannesTschofenig | 0:796d0f61a05b | 115 | void debug_set_threshold( int threshold ); |
HannesTschofenig | 0:796d0f61a05b | 116 | |
HannesTschofenig | 0:796d0f61a05b | 117 | char *debug_fmt( const char *format, ... ); |
HannesTschofenig | 0:796d0f61a05b | 118 | |
HannesTschofenig | 0:796d0f61a05b | 119 | void debug_print_msg( const ssl_context *ssl, int level, |
HannesTschofenig | 0:796d0f61a05b | 120 | const char *file, int line, const char *text ); |
HannesTschofenig | 0:796d0f61a05b | 121 | |
HannesTschofenig | 0:796d0f61a05b | 122 | void debug_print_ret( const ssl_context *ssl, int level, |
HannesTschofenig | 0:796d0f61a05b | 123 | const char *file, int line, |
HannesTschofenig | 0:796d0f61a05b | 124 | const char *text, int ret ); |
HannesTschofenig | 0:796d0f61a05b | 125 | |
HannesTschofenig | 0:796d0f61a05b | 126 | void debug_print_buf( const ssl_context *ssl, int level, |
HannesTschofenig | 0:796d0f61a05b | 127 | const char *file, int line, const char *text, |
HannesTschofenig | 0:796d0f61a05b | 128 | unsigned char *buf, size_t len ); |
HannesTschofenig | 0:796d0f61a05b | 129 | |
HannesTschofenig | 0:796d0f61a05b | 130 | #if defined(POLARSSL_BIGNUM_C) |
HannesTschofenig | 0:796d0f61a05b | 131 | void debug_print_mpi( const ssl_context *ssl, int level, |
HannesTschofenig | 0:796d0f61a05b | 132 | const char *file, int line, |
HannesTschofenig | 0:796d0f61a05b | 133 | const char *text, const mpi *X ); |
HannesTschofenig | 0:796d0f61a05b | 134 | #endif |
HannesTschofenig | 0:796d0f61a05b | 135 | |
HannesTschofenig | 0:796d0f61a05b | 136 | #if defined(POLARSSL_ECP_C) |
HannesTschofenig | 0:796d0f61a05b | 137 | void debug_print_ecp( const ssl_context *ssl, int level, |
HannesTschofenig | 0:796d0f61a05b | 138 | const char *file, int line, |
HannesTschofenig | 0:796d0f61a05b | 139 | const char *text, const ecp_point *X ); |
HannesTschofenig | 0:796d0f61a05b | 140 | #endif |
HannesTschofenig | 0:796d0f61a05b | 141 | |
HannesTschofenig | 0:796d0f61a05b | 142 | #if defined(POLARSSL_X509_CRT_PARSE_C) |
HannesTschofenig | 0:796d0f61a05b | 143 | void debug_print_crt( const ssl_context *ssl, int level, |
HannesTschofenig | 0:796d0f61a05b | 144 | const char *file, int line, |
HannesTschofenig | 0:796d0f61a05b | 145 | const char *text, const x509_crt *crt ); |
HannesTschofenig | 0:796d0f61a05b | 146 | #endif |
HannesTschofenig | 0:796d0f61a05b | 147 | |
HannesTschofenig | 0:796d0f61a05b | 148 | #ifdef __cplusplus |
HannesTschofenig | 0:796d0f61a05b | 149 | } |
HannesTschofenig | 0:796d0f61a05b | 150 | #endif |
HannesTschofenig | 0:796d0f61a05b | 151 | |
HannesTschofenig | 0:796d0f61a05b | 152 | #endif /* debug.h */ |
HannesTschofenig | 0:796d0f61a05b | 153 | |
HannesTschofenig | 0:796d0f61a05b | 154 |