Corrected SRP-RSA ciphersuites when used under TLS 1.2.
[gnutls.git] / lib / debug.c
blobec4988af5ed35e78b6d5e35ac09dda46b4737580
1 /*
2 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
3 * Free Software Foundation, Inc.
5 * Author: Nikos Mavrogiannopoulos
7 * This file is part of GnuTLS.
9 * The GnuTLS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1 of
12 * the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 * USA
26 #include "gnutls_int.h"
27 #include "gnutls_errors.h"
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include "debug.h"
31 #include <gnutls_mpi.h>
33 void
34 _gnutls_dump_mpi (const char *prefix, bigint_t a)
36 char buf[400];
37 char buf_hex[2 * sizeof (buf)];
38 size_t n = sizeof buf;
40 if (_gnutls_mpi_print (a, buf, &n))
41 strcpy (buf, "[can't print value]"); /* Flawfinder: ignore */
42 _gnutls_debug_log ("MPI: length: %d\n\t%s%s\n", (int) n, prefix,
43 _gnutls_bin2hex (buf, n, buf_hex, sizeof (buf_hex),
44 NULL));
48 const char *
49 _gnutls_packet2str (content_type_t packet)
51 switch (packet)
53 case GNUTLS_CHANGE_CIPHER_SPEC:
54 return "Change Cipher Spec";
55 case GNUTLS_ALERT:
56 return "Alert";
57 case GNUTLS_HANDSHAKE:
58 return "Handshake";
59 case GNUTLS_APPLICATION_DATA:
60 return "Application Data";
61 case GNUTLS_INNER_APPLICATION:
62 return "Inner Application";
64 default:
65 return "Unknown Packet";
69 const char *
70 _gnutls_handshake2str (gnutls_handshake_description_t handshake)
73 switch (handshake)
75 case GNUTLS_HANDSHAKE_HELLO_REQUEST:
76 return "HELLO REQUEST";
77 break;
78 case GNUTLS_HANDSHAKE_CLIENT_HELLO:
79 return "CLIENT HELLO";
80 break;
81 case GNUTLS_HANDSHAKE_SERVER_HELLO:
82 return "SERVER HELLO";
83 break;
84 case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
85 return "CERTIFICATE";
86 break;
87 case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
88 return "SERVER KEY EXCHANGE";
89 break;
90 case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
91 return "CERTIFICATE REQUEST";
92 break;
93 case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
94 return "SERVER HELLO DONE";
95 break;
96 case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
97 return "CERTIFICATE VERIFY";
98 break;
99 case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
100 return "CLIENT KEY EXCHANGE";
101 break;
102 case GNUTLS_HANDSHAKE_FINISHED:
103 return "FINISHED";
104 break;
105 case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
106 return "SUPPLEMENTAL";
107 break;
108 case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET:
109 return "NEW SESSION TICKET";
110 break;
111 default:
112 return "Unknown Handshake packet";