Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2001-2012 Free Software Foundation, Inc. |
3 | | * |
4 | | * Author: Nikos Mavrogiannopoulos |
5 | | * |
6 | | * This file is part of GnuTLS. |
7 | | * |
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. |
12 | | * |
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. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/> |
20 | | * |
21 | | */ |
22 | | |
23 | | #include "gnutls_int.h" |
24 | | #include "errors.h" |
25 | | #include <stdio.h> |
26 | | #include <stdlib.h> |
27 | | #include "debug.h" |
28 | | #include <mpi.h> |
29 | | |
30 | | #ifdef DEBUG |
31 | | void _gnutls_dump_mpi(const char *prefix, bigint_t a) |
32 | | { |
33 | | char buf[400]; |
34 | | char buf_hex[2 * sizeof(buf) + 1]; |
35 | | size_t n = sizeof buf; |
36 | | |
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), |
41 | | NULL)); |
42 | | } |
43 | | |
44 | | void _gnutls_dump_vector(const char *prefix, const uint8_t * a, size_t a_size) |
45 | | { |
46 | | char buf_hex[2 * a_size + 1]; |
47 | | |
48 | | _gnutls_debug_log("Vector: length: %d\n\t%s%s\n", (int)a_size, |
49 | | prefix, _gnutls_bin2hex(a, a_size, buf_hex, |
50 | | sizeof(buf_hex), NULL)); |
51 | | } |
52 | | #endif |
53 | | |
54 | | const char *_gnutls_packet2str(content_type_t packet) |
55 | 0 | { |
56 | 0 | switch (packet) { |
57 | 0 | case GNUTLS_CHANGE_CIPHER_SPEC: |
58 | 0 | return "ChangeCipherSpec"; |
59 | 0 | case GNUTLS_ALERT: |
60 | 0 | return "Alert"; |
61 | 0 | case GNUTLS_HANDSHAKE: |
62 | 0 | return "Handshake"; |
63 | 0 | case GNUTLS_APPLICATION_DATA: |
64 | 0 | return "Application Data"; |
65 | 0 | case GNUTLS_HEARTBEAT: |
66 | 0 | return "HeartBeat"; |
67 | 0 | default: |
68 | 0 | return "Unknown Packet"; |
69 | 0 | } |
70 | 0 | } |
71 | | |
72 | | /** |
73 | | * gnutls_handshake_description_get_name: |
74 | | * @type: is a handshake message description |
75 | | * |
76 | | * Convert a #gnutls_handshake_description_t value to a string. |
77 | | * |
78 | | * Returns: a string that contains the name of the specified handshake |
79 | | * message or %NULL. |
80 | | **/ |
81 | | const char |
82 | | *gnutls_handshake_description_get_name(gnutls_handshake_description_t type) |
83 | 0 | { |
84 | 0 | switch (type) { |
85 | 0 | case GNUTLS_HANDSHAKE_END_OF_EARLY_DATA: |
86 | 0 | return "END OF EARLY DATA"; |
87 | 0 | case GNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST: |
88 | 0 | return "HELLO RETRY REQUEST"; |
89 | 0 | case GNUTLS_HANDSHAKE_HELLO_REQUEST: |
90 | 0 | return "HELLO REQUEST"; |
91 | 0 | case GNUTLS_HANDSHAKE_CLIENT_HELLO: |
92 | 0 | return "CLIENT HELLO"; |
93 | 0 | #ifdef ENABLE_SSL2 |
94 | 0 | case GNUTLS_HANDSHAKE_CLIENT_HELLO_V2: |
95 | 0 | return "SSL2 CLIENT HELLO"; |
96 | 0 | #endif |
97 | 0 | case GNUTLS_HANDSHAKE_SERVER_HELLO: |
98 | 0 | return "SERVER HELLO"; |
99 | 0 | case GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST: |
100 | 0 | return "HELLO VERIFY REQUEST"; |
101 | 0 | case GNUTLS_HANDSHAKE_CERTIFICATE_PKT: |
102 | 0 | return "CERTIFICATE"; |
103 | 0 | case GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS: |
104 | 0 | return "ENCRYPTED EXTENSIONS"; |
105 | 0 | case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: |
106 | 0 | return "SERVER KEY EXCHANGE"; |
107 | 0 | case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: |
108 | 0 | return "CERTIFICATE REQUEST"; |
109 | 0 | case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: |
110 | 0 | return "SERVER HELLO DONE"; |
111 | 0 | case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: |
112 | 0 | return "CERTIFICATE VERIFY"; |
113 | 0 | case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: |
114 | 0 | return "CLIENT KEY EXCHANGE"; |
115 | 0 | case GNUTLS_HANDSHAKE_FINISHED: |
116 | 0 | return "FINISHED"; |
117 | 0 | case GNUTLS_HANDSHAKE_KEY_UPDATE: |
118 | 0 | return "KEY_UPDATE"; |
119 | 0 | case GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT: |
120 | 0 | return "COMPRESSED CERTIFICATE"; |
121 | 0 | case GNUTLS_HANDSHAKE_SUPPLEMENTAL: |
122 | 0 | return "SUPPLEMENTAL"; |
123 | 0 | case GNUTLS_HANDSHAKE_CERTIFICATE_STATUS: |
124 | 0 | return "CERTIFICATE STATUS"; |
125 | 0 | case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: |
126 | 0 | return "NEW SESSION TICKET"; |
127 | 0 | case GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC: |
128 | 0 | return "CHANGE CIPHER SPEC"; |
129 | 0 | default: |
130 | 0 | return "Unknown Handshake packet"; |
131 | 0 | } |
132 | 0 | } |