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 2.1 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"
28 #include <gnutls_mpi.h>
31 void _gnutls_dump_mpi(const char *prefix, bigint_t a)
34 char buf_hex[2 * sizeof(buf) + 1];
35 size_t n = sizeof buf;
37 if (_gnutls_mpi_print(a, buf, &n))
38 strcpy(buf, "[can't print value]"); /* Flawfinder: ignore */
39 _gnutls_debug_log("MPI: length: %d\n\t%s%s\n", (int) n, prefix,
40 _gnutls_bin2hex(buf, n, buf_hex, sizeof(buf_hex),
45 _gnutls_dump_vector(const char *prefix, const uint8_t * a, size_t a_size)
47 char buf_hex[2 * a_size + 1];
49 _gnutls_debug_log("Vector: length: %d\n\t%s%s\n", (int) a_size,
50 prefix, _gnutls_bin2hex(a, a_size, buf_hex,
51 sizeof(buf_hex), NULL));
55 const char *_gnutls_packet2str(content_type_t packet)
58 case GNUTLS_CHANGE_CIPHER_SPEC:
59 return "ChangeCipherSpec";
62 case GNUTLS_HANDSHAKE:
64 case GNUTLS_APPLICATION_DATA:
65 return "Application Data";
66 case GNUTLS_HEARTBEAT:
69 return "Unknown Packet";
74 * gnutls_handshake_description_get_name:
75 * @type: is a handshake message description
77 * Convert a #gnutls_handshake_description_t value to a string.
79 * Returns: a string that contains the name of the specified handshake
83 *gnutls_handshake_description_get_name(gnutls_handshake_description_t
87 case GNUTLS_HANDSHAKE_HELLO_REQUEST:
88 return "HELLO REQUEST";
90 case GNUTLS_HANDSHAKE_CLIENT_HELLO:
91 return "CLIENT HELLO";
93 case GNUTLS_HANDSHAKE_CLIENT_HELLO_V2:
94 return "SSL2 CLIENT HELLO";
96 case GNUTLS_HANDSHAKE_SERVER_HELLO:
97 return "SERVER HELLO";
99 case GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST:
100 return "HELLO VERIFY REQUEST";
102 case GNUTLS_HANDSHAKE_CERTIFICATE_PKT:
103 return "CERTIFICATE";
105 case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE:
106 return "SERVER KEY EXCHANGE";
108 case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST:
109 return "CERTIFICATE REQUEST";
111 case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE:
112 return "SERVER HELLO DONE";
114 case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY:
115 return "CERTIFICATE VERIFY";
117 case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE:
118 return "CLIENT KEY EXCHANGE";
120 case GNUTLS_HANDSHAKE_FINISHED:
123 case GNUTLS_HANDSHAKE_SUPPLEMENTAL:
124 return "SUPPLEMENTAL";
126 case GNUTLS_HANDSHAKE_CERTIFICATE_STATUS:
127 return "CERTIFICATE STATUS";
129 case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET:
130 return "NEW SESSION TICKET";
132 case GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC:
133 return "CHANGE CIPHER SPEC";
136 return "Unknown Handshake packet";