diff options
author | Gerald Combs <gerald@wireshark.org> | 2012-10-16 18:14:16 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2012-10-16 18:14:16 +0000 |
commit | 403e6dc86a55a12f1cf586093d4b6a8fa62f91ba (patch) | |
tree | e5155f0cc0e573dda3d6055122dcd16b39440083 /ui/ssl_key_export.c | |
parent | 5bcb56b21c1c102001a2b50651ed3e6c9815dc64 (diff) | |
download | wireshark-403e6dc86a55a12f1cf586093d4b6a8fa62f91ba.tar.gz |
Move common SSL key export routines to ui/ssl_key_export.[ch]. Make the
exported keys a gchar *. Implement SSL key exports in the Qt UI. Remove
some no-longer-necessary packet-ssl*.h includes.
Change lastOpenDir().absolutePath() to .canonicalPath(). Get rid of the
"Export As PostScript" action.
svn path=/trunk/; revision=45589
Diffstat (limited to 'ui/ssl_key_export.c')
-rw-r--r-- | ui/ssl_key_export.c | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/ui/ssl_key_export.c b/ui/ssl_key_export.c new file mode 100644 index 0000000000..ab5773b6c4 --- /dev/null +++ b/ui/ssl_key_export.c @@ -0,0 +1,87 @@ +/* export_sslkeys.c + * + * $Id$ + * + * Export SSL Session Keys dialog + * by Sake Blok <sake@euronet.nl> (20110526) + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include <glib.h> + +#include <epan/address.h> +#include <epan/dissectors/packet-ssl.h> +#include <epan/dissectors/packet-ssl-utils.h> + + +int +ssl_session_key_count(void) +{ + return g_hash_table_size(ssl_session_hash); +} + +static void +ssl_export_sessions_func(gpointer key, gpointer value, gpointer user_data) +{ + guint i; + StringInfo* sslid = (StringInfo*)key; + StringInfo* mastersecret = (StringInfo*)value; + GString* keylist = (GString*)user_data; + + /* + * XXX - should this be a string that grows as necessary to hold + * everything in it? + */ + g_string_append(keylist, "RSA Session-ID:"); + + for( i=0; i<sslid->data_len; i++) { + g_string_append_printf(keylist, "%.2x", sslid->data[i]&255); + } + + g_string_append(keylist, " Master-Key:"); + + for( i=0; i<mastersecret->data_len; i++) { + g_string_append_printf(keylist, "%.2x", mastersecret->data[i]&255); + } + + g_string_append_c(keylist, '\n'); +} + +gchar* +ssl_export_sessions(void) +{ + GString* keylist = g_string_new(""); + gchar *session_keys; + + /* Output format is: + * "RSA Session-ID:xxxx Master-Key:yyyy\n" + * Where xxxx is the session ID in hex (max 64 chars) + * Where yyyy is the Master Key in hex (always 96 chars) + * So in total max 3+1+11+64+1+11+96+2 = 189 chars + */ + + g_hash_table_foreach(ssl_session_hash, ssl_export_sessions_func, (gpointer)keylist); + + session_keys = keylist->str; + g_string_free(keylist, FALSE); + return session_keys; +} |