updated makefiles
[gnutls.git] / lib / debug.c
blob1e5b0c6fb83b60ed6b2e4f5c2a965d7b77dc7fda
1 /*
2 * Copyright (C) 2001-2012 Free Software Foundation, Inc.
4 * Author: Nikos Mavrogiannopoulos
6 * This file is part of GnuTLS.
8 * The GnuTLS is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 3 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>
23 #include "gnutls_int.h"
24 #include "gnutls_errors.h"
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include "debug.h"
28 #include <gnutls_mpi.h>
30 #ifdef DEBUG
31 void
32 _gnutls_dump_mpi (const char *prefix, bigint_t a)
34 char buf[400];
35 char buf_hex[2 * sizeof (buf)];
36 size_t n = sizeof buf;
38 if (_gnutls_mpi_print (a, buf, &n))
39 strcpy (buf, "[can't print value]"); /* Flawfinder: ignore */
40 _gnutls_debug_log ("MPI: length: %d\n\t%s%s\n", (int) n, prefix,
41 _gnutls_bin2hex (buf, n, buf_hex, sizeof (buf_hex),
42 NULL));
44 #endif
46 const char *
47 _gnutls_packet2str (content_type_t packet)
49 switch (packet)
51 case GNUTLS_CHANGE_CIPHER_SPEC:
52 return "ChangeCipherSpec";
53 case GNUTLS_ALERT:
54 return "Alert";
55 case GNUTLS_HANDSHAKE:
56 return "Handshake";
57 case GNUTLS_APPLICATION_DATA:
58 return "Application Data";
59 default:
60 return "Unknown Packet";
64 const char *
65 _gnutls_handshake2str (gnutls_handshake_description_t handshake)
68 switch (handshake)
70 case GNUTLS_HANDSHAKE_HELLO_REQUEST:
71 return "HELLO REQUEST";
72 break;
73 case GNUTLS_HANDSHAKE_CLIENT_HELLO:
74 return "CLIENT HELLO";
75 break;
76 case GNUTLS_HANDSHAKE_CLIENT_HELLO_V2:
77 return "SSL2 CLIENT HELLO";
78 break;
79 case GNUTLS_HANDSHAKE_SERVER_HELLO:
80 return "SERVER HELLO";
81 break;
82 case GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST:
83 return "HELLO VERIFY REQUEST";
84 break;
85 case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
86 return "CERTIFICATE";
87 break;
88 case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
89 return "SERVER KEY EXCHANGE";
90 break;
91 case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
92 return "CERTIFICATE REQUEST";
93 break;
94 case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
95 return "SERVER HELLO DONE";
96 break;
97 case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
98 return "CERTIFICATE VERIFY";
99 break;
100 case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
101 return "CLIENT KEY EXCHANGE";
102 break;
103 case GNUTLS_HANDSHAKE_FINISHED:
104 return "FINISHED";
105 break;
106 case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
107 return "SUPPLEMENTAL";
108 break;
109 case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET:
110 return "NEW SESSION TICKET";
111 break;
112 case GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC:
113 return "CHANGE CIPHER SPEC";
114 break;
115 default:
116 return "Unknown Handshake packet";