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.
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"
38 ssl_session_key_count(void)
40 return g_hash_table_size(ssl_session_hash
);
44 ssl_export_sessions_func(gpointer key
, gpointer value
, gpointer user_data
)
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
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');
71 ssl_export_sessions(void)
73 GString
* keylist
= g_string_new("");
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
);
96 * indent-tabs-mode: nil
99 * ex: set shiftwidth=4 tabstop=8 expandtab:
100 * :indentSize=4:tabSize=8:noTabs=true: