add parameter dcerpc_info to PIDL_dissect_ipv?address()
[wireshark-wip.git] / ui / ssl_key_export.c
blob7ab2d11a2677e635325ede794308e60032d3c205
1 /* export_sslkeys.c
3 * $Id$
5 * Export SSL Session Keys dialog
6 * by Sake Blok <sake@euronet.nl> (20110526)
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "config.h"
29 #include <glib.h>
31 #include <epan/address.h>
32 #include <epan/dissectors/packet-ssl.h>
33 #include <epan/dissectors/packet-ssl-utils.h>
35 #include "ui/ssl_key_export.h"
37 int
38 ssl_session_key_count(void)
40 return g_hash_table_size(ssl_session_hash);
43 static void
44 ssl_export_sessions_func(gpointer key, gpointer value, gpointer user_data)
46 guint i;
47 StringInfo* sslid = (StringInfo*)key;
48 StringInfo* mastersecret = (StringInfo*)value;
49 GString* keylist = (GString*)user_data;
52 * XXX - should this be a string that grows as necessary to hold
53 * everything in it?
55 g_string_append(keylist, "RSA Session-ID:");
57 for( i=0; i<sslid->data_len; i++) {
58 g_string_append_printf(keylist, "%.2x", sslid->data[i]&255);
61 g_string_append(keylist, " Master-Key:");
63 for( i=0; i<mastersecret->data_len; i++) {
64 g_string_append_printf(keylist, "%.2x", mastersecret->data[i]&255);
67 g_string_append_c(keylist, '\n');
70 gchar*
71 ssl_export_sessions(void)
73 GString* keylist = g_string_new("");
74 gchar *session_keys;
76 /* Output format is:
77 * "RSA Session-ID:xxxx Master-Key:yyyy\n"
78 * Where xxxx is the session ID in hex (max 64 chars)
79 * Where yyyy is the Master Key in hex (always 96 chars)
80 * So in total max 3+1+11+64+1+11+96+2 = 189 chars
83 g_hash_table_foreach(ssl_session_hash, ssl_export_sessions_func, (gpointer)keylist);
85 session_keys = keylist->str;
86 g_string_free(keylist, FALSE);
87 return session_keys;
91 * Editor modelines
93 * Local Variables:
94 * c-basic-offset: 4
95 * tab-width: 8
96 * indent-tabs-mode: nil
97 * End:
99 * ex: set shiftwidth=4 tabstop=8 expandtab:
100 * :indentSize=4:tabSize=8:noTabs=true: