blob: f0cc261770462a480e8ff1a0e592fa59be822b36 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file debug.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief Debug functions
5 *
Paul Bakkercce9d772011-11-18 14:26:47 +00006 * Copyright (C) 2006-2011, Brainspark B.V.
Paul Bakkerb96f1542010-07-18 20:36:00 +00007 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
Paul Bakker84f12b72010-07-18 10:13:04 +00009 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
Paul Bakkerb96f1542010-07-18 20:36:00 +000010 *
Paul Bakker77b385e2009-07-28 17:23:11 +000011 * All rights reserved.
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000012 *
Paul Bakkere0ccd0a2009-01-04 16:27:10 +000013 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Paul Bakker5121ce52009-01-03 21:22:43 +000026 */
Paul Bakkercce9d772011-11-18 14:26:47 +000027#ifndef POLARSSL_DEBUG_H
28#define POLARSSL_DEBUG_H
Paul Bakker5121ce52009-01-03 21:22:43 +000029
Paul Bakker314052f2011-08-15 09:07:52 +000030#include "config.h"
31#include "ssl.h"
Paul Bakker41c83d32013-03-20 14:39:14 +010032#if defined(POLARSSL_ECP_C)
33#include "ecp.h"
34#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000035
Paul Bakker1504af52012-02-11 16:17:43 +000036#if defined(POLARSSL_DEBUG_C)
Paul Bakker5121ce52009-01-03 21:22:43 +000037
38#define SSL_DEBUG_MSG( level, args ) \
39 debug_print_msg( ssl, level, __FILE__, __LINE__, debug_fmt args );
40
41#define SSL_DEBUG_RET( level, text, ret ) \
42 debug_print_ret( ssl, level, __FILE__, __LINE__, text, ret );
43
44#define SSL_DEBUG_BUF( level, text, buf, len ) \
45 debug_print_buf( ssl, level, __FILE__, __LINE__, text, buf, len );
46
47#define SSL_DEBUG_MPI( level, text, X ) \
48 debug_print_mpi( ssl, level, __FILE__, __LINE__, text, X );
49
Paul Bakker41c83d32013-03-20 14:39:14 +010050#define SSL_DEBUG_ECP( level, text, X ) \
51 debug_print_ecp( ssl, level, __FILE__, __LINE__, text, X );
52
Paul Bakker5121ce52009-01-03 21:22:43 +000053#define SSL_DEBUG_CRT( level, text, crt ) \
54 debug_print_crt( ssl, level, __FILE__, __LINE__, text, crt );
55
56#else
57
58#define SSL_DEBUG_MSG( level, args ) do { } while( 0 )
59#define SSL_DEBUG_RET( level, text, ret ) do { } while( 0 )
60#define SSL_DEBUG_BUF( level, text, buf, len ) do { } while( 0 )
61#define SSL_DEBUG_MPI( level, text, X ) do { } while( 0 )
Paul Bakker41c83d32013-03-20 14:39:14 +010062#define SSL_DEBUG_ECP( level, text, X ) do { } while( 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +000063#define SSL_DEBUG_CRT( level, text, crt ) do { } while( 0 )
64
65#endif
66
67#ifdef __cplusplus
68extern "C" {
69#endif
70
71char *debug_fmt( const char *format, ... );
72
Paul Bakkerff60ee62010-03-16 21:09:09 +000073void debug_print_msg( const ssl_context *ssl, int level,
74 const char *file, int line, const char *text );
Paul Bakker5121ce52009-01-03 21:22:43 +000075
Paul Bakkerff60ee62010-03-16 21:09:09 +000076void debug_print_ret( const ssl_context *ssl, int level,
77 const char *file, int line,
78 const char *text, int ret );
Paul Bakker5121ce52009-01-03 21:22:43 +000079
Paul Bakkerff60ee62010-03-16 21:09:09 +000080void debug_print_buf( const ssl_context *ssl, int level,
81 const char *file, int line, const char *text,
Paul Bakker23986e52011-04-24 08:57:21 +000082 unsigned char *buf, size_t len );
Paul Bakker5121ce52009-01-03 21:22:43 +000083
Paul Bakkerff60ee62010-03-16 21:09:09 +000084void debug_print_mpi( const ssl_context *ssl, int level,
85 const char *file, int line,
86 const char *text, const mpi *X );
Paul Bakker5121ce52009-01-03 21:22:43 +000087
Paul Bakker41c83d32013-03-20 14:39:14 +010088#if defined(POLARSSL_ECP_C)
89void debug_print_ecp( const ssl_context *ssl, int level,
90 const char *file, int line,
91 const char *text, const ecp_point *X );
92#endif
93
Paul Bakkerff60ee62010-03-16 21:09:09 +000094void debug_print_crt( const ssl_context *ssl, int level,
95 const char *file, int line,
96 const char *text, const x509_cert *crt );
Paul Bakker5121ce52009-01-03 21:22:43 +000097
98#ifdef __cplusplus
99}
100#endif
101
102#endif /* debug.h */