2001-07-11 18:19:16 +00:00
|
|
|
/* packet-ssl.c
|
|
|
|
* Routines for ssl dissection
|
|
|
|
* Copyright (c) 2000-2001, Scott Renfro <scott@renfro.org>
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2001-07-11 18:19:16 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-07-11 18:19:16 +00:00
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
2003-07-19 07:06:01 +00:00
|
|
|
* See
|
|
|
|
*
|
|
|
|
* http://www.netscape.com/eng/security/SSL_2.html
|
|
|
|
*
|
|
|
|
* for SSL 2.0 specs.
|
2006-08-07 19:52:18 +00:00
|
|
|
*
|
2003-07-19 07:06:01 +00:00
|
|
|
* See
|
|
|
|
*
|
|
|
|
* http://www.netscape.com/eng/ssl3/
|
|
|
|
*
|
|
|
|
* for SSL 3.0 specs.
|
|
|
|
*
|
|
|
|
* See RFC 2246 for SSL 3.1/TLS 1.0 specs.
|
|
|
|
*
|
2004-06-01 01:03:49 +00:00
|
|
|
* See (among other places)
|
|
|
|
*
|
|
|
|
* http://www.graphcomp.com/info/specs/ms/pct.htm
|
|
|
|
*
|
|
|
|
* for PCT 1 draft specs.
|
|
|
|
*
|
2006-08-07 19:52:18 +00:00
|
|
|
* See
|
2004-07-17 10:56:34 +00:00
|
|
|
*
|
|
|
|
* http://research.sun.com/projects/crypto/draft-ietf-tls-ecc-05.txt
|
|
|
|
*
|
|
|
|
* for Elliptic Curve Cryptography cipher suites.
|
|
|
|
*
|
|
|
|
* See
|
|
|
|
*
|
|
|
|
* http://www.ietf.org/internet-drafts/draft-ietf-tls-camellia-04.txt
|
|
|
|
*
|
|
|
|
* for Camellia-based cipher suites.
|
|
|
|
*
|
2001-07-11 18:19:16 +00:00
|
|
|
* Notes:
|
|
|
|
*
|
2006-02-04 23:44:05 +00:00
|
|
|
* - Does not support dissection
|
2001-07-11 18:19:16 +00:00
|
|
|
* of frames that would require state maintained between frames
|
|
|
|
* (e.g., single ssl records spread across multiple tcp frames)
|
|
|
|
*
|
|
|
|
* - Identifies, but does not fully dissect the following messages:
|
|
|
|
*
|
|
|
|
* - SSLv3/TLS (These need more state from previous handshake msgs)
|
|
|
|
* - Server Key Exchange
|
|
|
|
* - Client Key Exchange
|
|
|
|
* - Certificate Verify
|
|
|
|
*
|
|
|
|
* - SSLv2 (These don't appear in the clear)
|
|
|
|
* - Error
|
|
|
|
* - Client Finished
|
|
|
|
* - Server Verify
|
|
|
|
* - Server Finished
|
|
|
|
* - Request Certificate
|
|
|
|
* - Client Certificate
|
|
|
|
*
|
2006-02-04 23:44:05 +00:00
|
|
|
* - Decryption is supported only for session that use RSA key exchange,
|
2006-08-07 19:52:18 +00:00
|
|
|
* if the host private key is provided via preference.
|
|
|
|
*
|
2006-02-04 23:44:05 +00:00
|
|
|
* - Decryption need to be performed 'sequentially', so it's done
|
|
|
|
* at packet reception time. This may cause a significative packet capture
|
|
|
|
* slow down. This also cause do dissect some ssl info that in previous
|
2006-08-07 19:52:18 +00:00
|
|
|
* dissector version were dissected only when a proto_tree context was
|
2006-02-04 23:44:05 +00:00
|
|
|
* available
|
|
|
|
*
|
2006-08-07 19:52:18 +00:00
|
|
|
* We are at Packet reception if time pinfo->fd->flags.visited == 0
|
2006-02-04 23:44:05 +00:00
|
|
|
*
|
2001-07-11 18:19:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2006-12-11 08:47:38 +00:00
|
|
|
#include <sys/stat.h>
|
2006-12-11 10:43:43 +00:00
|
|
|
#include <errno.h>
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-06-20 05:59:55 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#endif
|
2008-10-24 00:42:09 +00:00
|
|
|
#ifdef HAVE_WINSOCK2_H
|
|
|
|
#include <winsock2.h>
|
|
|
|
#endif
|
2006-06-20 05:59:55 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
2002-01-21 07:37:49 +00:00
|
|
|
#include <epan/conversation.h>
|
2007-04-10 15:12:48 +00:00
|
|
|
#include <epan/reassemble.h>
|
2004-09-27 22:55:15 +00:00
|
|
|
#include <epan/prefs.h>
|
2007-04-10 15:12:48 +00:00
|
|
|
#include <epan/emem.h>
|
|
|
|
#include <epan/dissectors/packet-tcp.h>
|
2007-05-13 20:58:29 +00:00
|
|
|
#include <epan/asn1.h>
|
2004-08-02 08:57:40 +00:00
|
|
|
#include <epan/dissectors/packet-x509af.h>
|
2006-02-04 23:44:05 +00:00
|
|
|
#include <epan/tap.h>
|
2006-12-11 08:47:38 +00:00
|
|
|
#include <epan/filesystem.h>
|
|
|
|
#include <epan/report_err.h>
|
2007-05-03 16:59:13 +00:00
|
|
|
#include <epan/expert.h>
|
2007-06-11 19:03:20 +00:00
|
|
|
#include "inet_v6defs.h"
|
2008-01-13 14:10:02 +00:00
|
|
|
#include "packet-x509if.h"
|
2006-08-25 08:07:26 +00:00
|
|
|
#include "packet-ssl.h"
|
2006-02-04 23:44:05 +00:00
|
|
|
#include "packet-ssl-utils.h"
|
2008-05-22 15:46:27 +00:00
|
|
|
#include <wsutil/file_util.h>
|
2006-02-04 23:44:05 +00:00
|
|
|
|
2002-01-04 07:01:54 +00:00
|
|
|
|
|
|
|
static gboolean ssl_desegment = TRUE;
|
2006-06-27 13:36:10 +00:00
|
|
|
static gboolean ssl_desegment_app_data = TRUE;
|
2002-01-04 07:01:54 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Protocol Constants, Variables, Data Structures
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
/* Initialize the protocol and registered fields */
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint ssl_tap = -1;
|
|
|
|
static gint proto_ssl = -1;
|
|
|
|
static gint hf_ssl_record = -1;
|
|
|
|
static gint hf_ssl_record_content_type = -1;
|
|
|
|
static gint hf_ssl_record_version = -1;
|
|
|
|
static gint hf_ssl_record_length = -1;
|
|
|
|
static gint hf_ssl_record_appdata = -1;
|
|
|
|
static gint hf_ssl2_record = -1;
|
|
|
|
static gint hf_ssl2_record_is_escape = -1;
|
|
|
|
static gint hf_ssl2_record_padding_length = -1;
|
|
|
|
static gint hf_ssl2_msg_type = -1;
|
|
|
|
static gint hf_pct_msg_type = -1;
|
|
|
|
static gint hf_ssl_change_cipher_spec = -1;
|
|
|
|
static gint hf_ssl_alert_message = -1;
|
|
|
|
static gint hf_ssl_alert_message_level = -1;
|
|
|
|
static gint hf_ssl_alert_message_description = -1;
|
|
|
|
static gint hf_ssl_handshake_protocol = -1;
|
|
|
|
static gint hf_ssl_handshake_type = -1;
|
|
|
|
static gint hf_ssl_handshake_length = -1;
|
|
|
|
static gint hf_ssl_handshake_client_version = -1;
|
|
|
|
static gint hf_ssl_handshake_server_version = -1;
|
|
|
|
static gint hf_ssl_handshake_random_time = -1;
|
|
|
|
static gint hf_ssl_handshake_random_bytes = -1;
|
|
|
|
static gint hf_ssl_handshake_cipher_suites_len = -1;
|
|
|
|
static gint hf_ssl_handshake_cipher_suites = -1;
|
|
|
|
static gint hf_ssl_handshake_cipher_suite = -1;
|
|
|
|
static gint hf_ssl_handshake_session_id = -1;
|
|
|
|
static gint hf_ssl_handshake_comp_methods_len = -1;
|
|
|
|
static gint hf_ssl_handshake_comp_methods = -1;
|
|
|
|
static gint hf_ssl_handshake_comp_method = -1;
|
|
|
|
static gint hf_ssl_handshake_extensions_len = -1;
|
|
|
|
static gint hf_ssl_handshake_extension_type = -1;
|
|
|
|
static gint hf_ssl_handshake_extension_len = -1;
|
|
|
|
static gint hf_ssl_handshake_extension_data = -1;
|
|
|
|
static gint hf_ssl_handshake_certificates_len = -1;
|
|
|
|
static gint hf_ssl_handshake_certificates = -1;
|
|
|
|
static gint hf_ssl_handshake_certificate = -1;
|
|
|
|
static gint hf_ssl_handshake_certificate_len = -1;
|
|
|
|
static gint hf_ssl_handshake_cert_types_count = -1;
|
|
|
|
static gint hf_ssl_handshake_cert_types = -1;
|
|
|
|
static gint hf_ssl_handshake_cert_type = -1;
|
|
|
|
static gint hf_ssl_handshake_finished = -1;
|
|
|
|
static gint hf_ssl_handshake_md5_hash = -1;
|
|
|
|
static gint hf_ssl_handshake_sha_hash = -1;
|
|
|
|
static gint hf_ssl_handshake_session_id_len = -1;
|
|
|
|
static gint hf_ssl_handshake_dnames_len = -1;
|
|
|
|
static gint hf_ssl_handshake_dnames = -1;
|
|
|
|
static gint hf_ssl_handshake_dname_len = -1;
|
|
|
|
static gint hf_ssl_handshake_dname = -1;
|
|
|
|
static gint hf_ssl2_handshake_cipher_spec_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_session_id_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_challenge_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_cipher_spec = -1;
|
|
|
|
static gint hf_ssl2_handshake_challenge = -1;
|
|
|
|
static gint hf_ssl2_handshake_clear_key_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_enc_key_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_key_arg_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_clear_key = -1;
|
|
|
|
static gint hf_ssl2_handshake_enc_key = -1;
|
|
|
|
static gint hf_ssl2_handshake_key_arg = -1;
|
|
|
|
static gint hf_ssl2_handshake_session_id_hit = -1;
|
|
|
|
static gint hf_ssl2_handshake_cert_type = -1;
|
|
|
|
static gint hf_ssl2_handshake_connection_id_len = -1;
|
|
|
|
static gint hf_ssl2_handshake_connection_id = -1;
|
2008-07-09 07:24:13 +00:00
|
|
|
static gint hf_pct_handshake_cipher_spec = -1;
|
|
|
|
static gint hf_pct_handshake_hash_spec = -1;
|
|
|
|
static gint hf_pct_handshake_cert_spec = -1;
|
|
|
|
static gint hf_pct_handshake_cert = -1;
|
|
|
|
static gint hf_pct_handshake_server_cert = -1;
|
|
|
|
static gint hf_pct_handshake_exch_spec = -1;
|
|
|
|
static gint hf_pct_handshake_hash = -1;
|
|
|
|
static gint hf_pct_handshake_cipher = -1;
|
|
|
|
static gint hf_pct_handshake_exch = -1;
|
|
|
|
static gint hf_pct_handshake_sig = -1;
|
|
|
|
static gint hf_pct_msg_error_type = -1;
|
|
|
|
static int hf_ssl_reassembled_in = -1;
|
|
|
|
static int hf_ssl_segments = -1;
|
|
|
|
static int hf_ssl_segment = -1;
|
|
|
|
static int hf_ssl_segment_overlap = -1;
|
|
|
|
static int hf_ssl_segment_overlap_conflict = -1;
|
|
|
|
static int hf_ssl_segment_multiple_tails = -1;
|
|
|
|
static int hf_ssl_segment_too_long_fragment = -1;
|
|
|
|
static int hf_ssl_segment_error = -1;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* Initialize the subtree pointers */
|
|
|
|
static gint ett_ssl = -1;
|
|
|
|
static gint ett_ssl_record = -1;
|
|
|
|
static gint ett_ssl_alert = -1;
|
|
|
|
static gint ett_ssl_handshake = -1;
|
|
|
|
static gint ett_ssl_cipher_suites = -1;
|
|
|
|
static gint ett_ssl_comp_methods = -1;
|
2004-12-26 00:28:47 +00:00
|
|
|
static gint ett_ssl_extension = -1;
|
2001-07-11 18:19:16 +00:00
|
|
|
static gint ett_ssl_certs = -1;
|
|
|
|
static gint ett_ssl_cert_types = -1;
|
|
|
|
static gint ett_ssl_dnames = -1;
|
2006-08-30 07:31:36 +00:00
|
|
|
static gint ett_ssl_random = -1;
|
2004-06-01 01:03:49 +00:00
|
|
|
static gint ett_pct_cipher_suites = -1;
|
2008-07-09 07:24:13 +00:00
|
|
|
static gint ett_pct_hash_suites = -1;
|
|
|
|
static gint ett_pct_cert_suites = -1;
|
|
|
|
static gint ett_pct_exch_suites = -1;
|
|
|
|
static gint ett_ssl_segments = -1;
|
|
|
|
static gint ett_ssl_segment = -1;
|
2007-04-10 15:12:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* not all of the hf_fields below make sense for SSL but we have to provide
|
|
|
|
them anyways to comply with the api (which was aimed for ip fragment
|
|
|
|
reassembly) */
|
|
|
|
static const fragment_items ssl_segment_items = {
|
|
|
|
&ett_ssl_segment,
|
|
|
|
&ett_ssl_segments,
|
|
|
|
&hf_ssl_segments,
|
|
|
|
&hf_ssl_segment,
|
|
|
|
&hf_ssl_segment_overlap,
|
|
|
|
&hf_ssl_segment_overlap_conflict,
|
|
|
|
&hf_ssl_segment_multiple_tails,
|
|
|
|
&hf_ssl_segment_too_long_fragment,
|
|
|
|
&hf_ssl_segment_error,
|
|
|
|
&hf_ssl_reassembled_in,
|
|
|
|
"Segments"
|
|
|
|
};
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
static GHashTable *ssl_session_hash = NULL;
|
|
|
|
static GHashTable *ssl_key_hash = NULL;
|
|
|
|
static GTree* ssl_associations = NULL;
|
|
|
|
static dissector_handle_t ssl_handle = NULL;
|
2007-04-10 15:12:48 +00:00
|
|
|
static StringInfo ssl_compressed_data = {NULL, 0};
|
2006-02-04 23:44:05 +00:00
|
|
|
static StringInfo ssl_decrypted_data = {NULL, 0};
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint ssl_decrypted_data_avail = 0;
|
2006-02-04 23:44:05 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gchar* ssl_keys_list = NULL;
|
2007-04-13 01:03:55 +00:00
|
|
|
|
|
|
|
#if defined(SSL_DECRYPT_DEBUG) || defined(HAVE_LIBGNUTLS)
|
2006-08-02 08:15:51 +00:00
|
|
|
static gchar* ssl_debug_file_name = NULL;
|
2007-04-13 01:03:55 +00:00
|
|
|
#endif
|
2006-05-03 05:29:04 +00:00
|
|
|
|
2007-03-24 01:38:58 +00:00
|
|
|
const gchar* ssl_version_short_names[] = {
|
|
|
|
"SSL",
|
|
|
|
"SSLv2",
|
|
|
|
"SSLv3",
|
|
|
|
"TLSv1",
|
|
|
|
"TLSv1.1",
|
|
|
|
"DTLSv1.0",
|
|
|
|
"PCT"
|
|
|
|
};
|
|
|
|
|
2006-08-25 08:07:26 +00:00
|
|
|
/* Forward declaration we need below */
|
|
|
|
void proto_reg_handoff_ssl(void);
|
|
|
|
|
2007-04-10 15:12:48 +00:00
|
|
|
/* Desegmentation of SSL streams */
|
|
|
|
/* table to hold defragmented SSL streams */
|
|
|
|
static GHashTable *ssl_fragment_table = NULL;
|
|
|
|
static void
|
|
|
|
ssl_fragment_init(void)
|
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
fragment_table_init(&ssl_fragment_table);
|
2007-04-10 15:12:48 +00:00
|
|
|
}
|
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* initialize/reset per capture state data (ssl sessions cache) */
|
2006-08-07 19:52:18 +00:00
|
|
|
static void
|
2006-02-11 13:41:17 +00:00
|
|
|
ssl_init(void)
|
2006-02-04 23:44:05 +00:00
|
|
|
{
|
2007-04-10 15:12:48 +00:00
|
|
|
ssl_common_init(&ssl_session_hash, &ssl_decrypted_data, &ssl_compressed_data);
|
|
|
|
ssl_fragment_init();
|
2008-01-14 09:34:26 +00:00
|
|
|
ssl_debug_flush();
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* parse ssl related preferences (private keys and ports association strings) */
|
2006-08-07 19:52:18 +00:00
|
|
|
static void
|
2006-02-11 13:41:17 +00:00
|
|
|
ssl_parse(void)
|
2006-02-04 23:44:05 +00:00
|
|
|
{
|
2006-09-24 20:29:47 +00:00
|
|
|
ep_stack_t tmp_stack;
|
|
|
|
SslAssociation *tmp_assoc;
|
2006-12-11 08:47:38 +00:00
|
|
|
FILE *ssl_keys_file;
|
2007-04-23 16:22:34 +00:00
|
|
|
struct stat statb;
|
|
|
|
size_t size;
|
|
|
|
gchar *tmp_buf;
|
|
|
|
size_t nbytes;
|
2007-05-02 19:46:05 +00:00
|
|
|
gboolean read_failed;
|
2006-08-25 08:07:26 +00:00
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
ssl_set_debug(ssl_debug_file_name);
|
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl_key_hash)
|
|
|
|
{
|
|
|
|
g_hash_table_foreach(ssl_key_hash, ssl_private_key_free, NULL);
|
|
|
|
g_hash_table_destroy(ssl_key_hash);
|
|
|
|
}
|
2006-08-25 08:07:26 +00:00
|
|
|
|
2006-09-24 20:29:47 +00:00
|
|
|
/* remove only associations created from key list */
|
|
|
|
tmp_stack = ep_stack_new();
|
2008-05-05 20:03:15 +00:00
|
|
|
g_tree_foreach(ssl_associations, ssl_assoc_from_key_list, tmp_stack);
|
2006-09-24 20:29:47 +00:00
|
|
|
while ((tmp_assoc = ep_stack_pop(tmp_stack)) != NULL) {
|
|
|
|
ssl_association_remove(ssl_associations, tmp_assoc);
|
|
|
|
}
|
2006-02-04 23:44:05 +00:00
|
|
|
|
|
|
|
/* parse private keys string, load available keys and put them in key hash*/
|
|
|
|
ssl_key_hash = g_hash_table_new(ssl_private_key_hash,ssl_private_key_equal);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
|
|
|
if (ssl_keys_list && (ssl_keys_list[0] != 0))
|
2006-02-04 23:44:05 +00:00
|
|
|
{
|
2007-04-23 16:22:34 +00:00
|
|
|
if (file_exists(ssl_keys_list)) {
|
2008-05-22 15:46:27 +00:00
|
|
|
if ((ssl_keys_file = ws_fopen(ssl_keys_list, "r"))) {
|
2007-05-02 19:46:05 +00:00
|
|
|
read_failed = FALSE;
|
2007-04-23 16:22:34 +00:00
|
|
|
fstat(fileno(ssl_keys_file), &statb);
|
2009-04-21 16:57:52 +00:00
|
|
|
size = (size_t)statb.st_size;
|
2007-04-23 16:22:34 +00:00
|
|
|
tmp_buf = ep_alloc0(size + 1);
|
2007-04-25 10:16:33 +00:00
|
|
|
nbytes = fread(tmp_buf, 1, size, ssl_keys_file);
|
2007-05-02 19:46:05 +00:00
|
|
|
if (ferror(ssl_keys_file)) {
|
|
|
|
report_read_failure(ssl_keys_list, errno);
|
|
|
|
read_failed = TRUE;
|
|
|
|
}
|
2007-04-23 16:22:34 +00:00
|
|
|
fclose(ssl_keys_file);
|
2007-04-25 10:16:33 +00:00
|
|
|
tmp_buf[nbytes] = '\0';
|
2007-05-02 19:46:05 +00:00
|
|
|
if (!read_failed)
|
|
|
|
ssl_parse_key_list(tmp_buf,ssl_key_hash,ssl_associations,ssl_handle,TRUE);
|
2007-04-23 16:22:34 +00:00
|
|
|
} else {
|
|
|
|
report_open_failure(ssl_keys_list, errno, FALSE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ssl_parse_key_list(ssl_keys_list,ssl_key_hash,ssl_associations,ssl_handle,TRUE);
|
|
|
|
}
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2008-01-14 09:34:26 +00:00
|
|
|
ssl_debug_flush();
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Forward Declarations
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SSL version 3 and TLS dissectors
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* record layer dissector */
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint dissect_ssl3_record(tvbuff_t *tvb, packet_info *pinfo,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree, guint32 offset,
|
2002-01-17 09:24:05 +00:00
|
|
|
guint *conv_version,
|
2006-02-04 23:44:05 +00:00
|
|
|
gboolean *need_desegmentation,
|
2006-12-30 01:06:46 +00:00
|
|
|
SslDecryptSession *conv_data,
|
|
|
|
gboolean first_record_in_frame);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* change cipher spec dissector */
|
2002-04-08 10:05:19 +00:00
|
|
|
static void dissect_ssl3_change_cipher_spec(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset,
|
2005-03-06 04:42:51 +00:00
|
|
|
guint *conv_version, guint8 content_type);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* alert message dissector */
|
|
|
|
static void dissect_ssl3_alert(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, guint32 offset,
|
|
|
|
guint *conv_version);
|
|
|
|
|
|
|
|
/* handshake protocol dissector */
|
|
|
|
static void dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, guint32 offset,
|
|
|
|
guint32 record_length,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint *conv_version,
|
|
|
|
SslDecryptSession *conv_data, guint8 content_type);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
|
2007-05-03 16:59:13 +00:00
|
|
|
static void dissect_ssl3_hnd_cli_hello(tvbuff_t *tvb, packet_info *pinfo,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree,
|
2006-08-07 19:52:18 +00:00
|
|
|
guint32 offset, guint32 length,
|
2006-02-04 23:44:05 +00:00
|
|
|
SslDecryptSession* ssl);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-08 10:05:19 +00:00
|
|
|
static void dissect_ssl3_hnd_srv_hello(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree,
|
2006-08-07 19:52:18 +00:00
|
|
|
guint32 offset, guint32 length,
|
2006-02-04 23:44:05 +00:00
|
|
|
SslDecryptSession* ssl);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-08 10:05:19 +00:00
|
|
|
static void dissect_ssl3_hnd_cert(tvbuff_t *tvb,
|
2004-08-02 08:57:40 +00:00
|
|
|
proto_tree *tree, guint32 offset, packet_info *pinfo);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-08 10:05:19 +00:00
|
|
|
static void dissect_ssl3_hnd_cert_req(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree,
|
2008-01-13 14:10:02 +00:00
|
|
|
guint32 offset, packet_info *pinfo);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-08 10:05:19 +00:00
|
|
|
static void dissect_ssl3_hnd_finished(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint* conv_version);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* SSL version 2 dissectors
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* record layer dissector */
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint dissect_ssl2_record(tvbuff_t *tvb, packet_info *pinfo,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree, guint32 offset,
|
2002-01-17 09:24:05 +00:00
|
|
|
guint *conv_version,
|
2006-02-04 23:44:05 +00:00
|
|
|
gboolean *need_desegmentation,
|
|
|
|
SslDecryptSession* ssl);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* client hello dissector */
|
2007-09-16 19:28:58 +00:00
|
|
|
static void dissect_ssl2_hnd_client_hello(tvbuff_t *tvb, packet_info *pinfo,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint32 offset,
|
|
|
|
SslDecryptSession* ssl);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
static void dissect_pct_msg_client_hello(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset);
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* client master key dissector */
|
|
|
|
static void dissect_ssl2_hnd_client_master_key(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset);
|
2004-06-01 01:03:49 +00:00
|
|
|
static void dissect_pct_msg_client_master_key(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* server hello dissector */
|
|
|
|
static void dissect_ssl2_hnd_server_hello(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
2004-08-02 08:57:40 +00:00
|
|
|
guint32 offset, packet_info *pinfo);
|
2004-06-01 01:03:49 +00:00
|
|
|
static void dissect_pct_msg_server_hello(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
2004-08-02 08:57:40 +00:00
|
|
|
guint32 offset, packet_info *pinfo);
|
2004-06-01 01:03:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void dissect_pct_msg_server_verify(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset);
|
|
|
|
|
|
|
|
static void dissect_pct_msg_error(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree,
|
|
|
|
guint32 offset);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Support Functions
|
|
|
|
*
|
|
|
|
*/
|
2006-02-04 23:44:05 +00:00
|
|
|
/*static void ssl_set_conv_version(packet_info *pinfo, guint version);*/
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint ssl_is_valid_handshake_type(guint8 type);
|
|
|
|
static gint ssl_is_valid_ssl_version(guint16 version);
|
|
|
|
static gint ssl_is_authoritative_version_message(guint8 content_type,
|
2001-07-11 18:19:16 +00:00
|
|
|
guint8 next_byte);
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint ssl_is_v2_client_hello(tvbuff_t *tvb, guint32 offset);
|
|
|
|
static gint ssl_looks_like_sslv2(tvbuff_t *tvb, guint32 offset);
|
|
|
|
static gint ssl_looks_like_sslv3(tvbuff_t *tvb, guint32 offset);
|
|
|
|
static gint ssl_looks_like_valid_v2_handshake(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
guint32 offset,
|
|
|
|
guint32 record_length);
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint ssl_looks_like_valid_pct_handshake(tvbuff_t *tvb,
|
2002-04-11 09:43:22 +00:00
|
|
|
guint32 offset,
|
|
|
|
guint32 record_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Main dissector
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
/*
|
|
|
|
* Code to actually dissect the packets
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
dissect_ssl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
|
|
|
|
conversation_t *conversation;
|
2001-09-03 10:33:12 +00:00
|
|
|
void *conv_data;
|
2006-08-02 08:15:51 +00:00
|
|
|
proto_item *ti;
|
|
|
|
proto_tree *ssl_tree;
|
|
|
|
guint32 offset;
|
|
|
|
gboolean first_record_in_frame;
|
2002-01-17 09:24:05 +00:00
|
|
|
gboolean need_desegmentation;
|
2006-08-02 08:15:51 +00:00
|
|
|
SslDecryptSession* ssl_session;
|
2006-02-04 23:44:05 +00:00
|
|
|
guint* conv_version;
|
2008-01-03 08:24:33 +00:00
|
|
|
Ssl_private_key_t * private_key;
|
2008-01-13 14:10:02 +00:00
|
|
|
guint32 port;
|
2008-01-03 08:24:33 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
ti = NULL;
|
|
|
|
ssl_tree = NULL;
|
|
|
|
offset = 0;
|
|
|
|
first_record_in_frame = TRUE;
|
|
|
|
ssl_session = NULL;
|
2008-01-13 14:10:02 +00:00
|
|
|
port = 0;
|
2008-01-03 08:24:33 +00:00
|
|
|
|
|
|
|
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("\ndissect_ssl enter frame #%u (%s)\n", pinfo->fd->num, (pinfo->fd->flags.visited)?"already visited":"first time");
|
2006-10-17 13:29:44 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* Track the version using conversations to reduce the
|
|
|
|
* chance that a packet that simply *looks* like a v2 or
|
|
|
|
* v3 packet is dissected improperly. This also allows
|
|
|
|
* us to more frequently set the protocol column properly
|
|
|
|
* for continuation data frames.
|
|
|
|
*
|
|
|
|
* Also: We use the copy in conv_version as our cached copy,
|
|
|
|
* so that we don't have to search the conversation
|
|
|
|
* table every time we want the version; when setting
|
|
|
|
* the conv_version, must set the copy in the conversation
|
|
|
|
* in addition to conv_version
|
|
|
|
*/
|
2005-02-02 20:07:03 +00:00
|
|
|
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
|
2001-07-11 18:19:16 +00:00
|
|
|
pinfo->srcport, pinfo->destport, 0);
|
2006-08-02 08:15:51 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
if (!conversation)
|
|
|
|
{
|
|
|
|
/* create a new conversation */
|
2005-02-02 20:07:03 +00:00
|
|
|
conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
|
2001-09-03 10:33:12 +00:00
|
|
|
pinfo->srcport, pinfo->destport, 0);
|
2008-02-11 17:04:51 +00:00
|
|
|
ssl_debug_printf(" new conversation = %p created\n", (void *)conversation);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2001-09-03 10:33:12 +00:00
|
|
|
conv_data = conversation_get_proto_data(conversation, proto_ssl);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* PAOLO: manage ssl decryption data */
|
2006-08-07 19:52:18 +00:00
|
|
|
/*get a valid ssl session pointer*/
|
2001-09-03 10:33:12 +00:00
|
|
|
if (conv_data != NULL)
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_session = conv_data;
|
|
|
|
else {
|
|
|
|
SslService dummy;
|
2008-01-03 08:24:33 +00:00
|
|
|
char ip_addr_any[] = {0,0,0,0};
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_session = se_alloc0(sizeof(SslDecryptSession));
|
|
|
|
ssl_session_init(ssl_session);
|
|
|
|
ssl_session->version = SSL_VER_UNKNOWN;
|
|
|
|
conversation_add_proto_data(conversation, proto_ssl, ssl_session);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* we need to know which side of the conversation is speaking */
|
2006-08-25 08:07:26 +00:00
|
|
|
if (ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP)) {
|
2006-02-17 11:56:52 +00:00
|
|
|
dummy.addr = pinfo->src;
|
2008-01-13 14:10:02 +00:00
|
|
|
dummy.port = port = pinfo->srcport;
|
2008-07-09 07:24:13 +00:00
|
|
|
} else {
|
2006-02-17 11:56:52 +00:00
|
|
|
dummy.addr = pinfo->dst;
|
2008-01-13 14:10:02 +00:00
|
|
|
dummy.port = port = pinfo->destport;
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2007-04-25 23:56:46 +00:00
|
|
|
ssl_debug_printf("dissect_ssl server %s:%u\n",
|
|
|
|
address_to_str(&dummy.addr),dummy.port);
|
2006-02-04 23:44:05 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* try to retrieve private key for this service. Do it now 'cause pinfo
|
2006-08-07 19:52:18 +00:00
|
|
|
* is not always available
|
2006-02-04 23:44:05 +00:00
|
|
|
* Note that with HAVE_LIBGNUTLS undefined private_key is allways 0
|
|
|
|
* and thus decryption never engaged*/
|
2008-05-22 15:46:27 +00:00
|
|
|
|
|
|
|
|
2008-01-03 08:24:33 +00:00
|
|
|
ssl_session->private_key = 0;
|
|
|
|
private_key = g_hash_table_lookup(ssl_key_hash, &dummy);
|
2008-01-13 14:10:02 +00:00
|
|
|
|
2008-01-03 08:24:33 +00:00
|
|
|
if (!private_key) {
|
2008-01-13 14:10:02 +00:00
|
|
|
ssl_debug_printf("dissect_ssl can't find private key for this server! Try it again with universal port 0\n");
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2008-01-13 14:10:02 +00:00
|
|
|
dummy.port = 0;
|
|
|
|
private_key = g_hash_table_lookup(ssl_key_hash, &dummy);
|
2008-07-09 07:24:13 +00:00
|
|
|
}
|
2008-01-13 14:10:02 +00:00
|
|
|
|
|
|
|
if (!private_key) {
|
|
|
|
ssl_debug_printf("dissect_ssl can't find private key for this server (universal port)! Try it again with universal address 0.0.0.0\n");
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2008-01-03 08:24:33 +00:00
|
|
|
dummy.addr.type = AT_IPv4;
|
|
|
|
dummy.addr.len = 4;
|
|
|
|
dummy.addr.data = ip_addr_any;
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
dummy.port = port;
|
2008-01-13 14:10:02 +00:00
|
|
|
private_key = g_hash_table_lookup(ssl_key_hash, &dummy);
|
2008-07-09 07:24:13 +00:00
|
|
|
}
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
if (!private_key) {
|
|
|
|
ssl_debug_printf("dissect_ssl can't find any private key!\n");
|
|
|
|
} else {
|
|
|
|
ssl_session->private_key = private_key->sexp_pkey;
|
|
|
|
}
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2008-07-09 07:24:13 +00:00
|
|
|
conv_version =& ssl_session->version;
|
2006-02-04 23:44:05 +00:00
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
/* try decryption only the first time we see this packet
|
2008-12-17 00:08:38 +00:00
|
|
|
* (to keep cipher synchronized) and only if we have
|
2006-02-04 23:44:05 +00:00
|
|
|
* the server private key*/
|
2007-01-04 09:20:18 +00:00
|
|
|
if (pinfo->fd->flags.visited)
|
2006-08-07 19:52:18 +00:00
|
|
|
ssl_session = NULL;
|
|
|
|
|
2008-02-11 17:04:51 +00:00
|
|
|
ssl_debug_printf(" conversation = %p, ssl_session = %p\n", (void *)conversation, (void *)ssl_session);
|
2007-11-21 14:10:55 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* Initialize the protocol column; we'll set it later when we
|
|
|
|
* figure out what flavor of SSL it is (assuming we don't
|
|
|
|
* throw an exception before we get the chance to do so). */
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSL");
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
/* clear the the info column */
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* TCP packets and SSL records are orthogonal.
|
|
|
|
* A tcp packet may contain multiple ssl records and an ssl
|
|
|
|
* record may be spread across multiple tcp packets.
|
|
|
|
*
|
|
|
|
* This loop accounts for multiple ssl records in a single
|
|
|
|
* frame, but not a single ssl record across multiple tcp
|
|
|
|
* packets.
|
|
|
|
*
|
|
|
|
* Handling the single ssl record across multiple packets
|
2007-01-26 01:34:29 +00:00
|
|
|
* may be possible using wireshark conversations, but
|
2001-07-11 18:19:16 +00:00
|
|
|
* probably not cleanly. May have to wait for tcp stream
|
|
|
|
* reassembly.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Create display subtree for SSL as a whole */
|
|
|
|
if (tree)
|
|
|
|
{
|
2002-01-24 09:20:54 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_ssl, tvb, 0, -1, FALSE);
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_tree = proto_item_add_subtree(ti, ett_ssl);
|
|
|
|
}
|
2002-03-28 09:15:28 +00:00
|
|
|
/* iterate through the records in this tvbuff */
|
|
|
|
while (tvb_reported_length_remaining(tvb, offset) != 0)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2008-03-19 08:26:45 +00:00
|
|
|
ssl_debug_printf(" record: offset = %d, reported_length_remaining = %d\n", offset, tvb_reported_length_remaining(tvb, offset));
|
2001-07-11 18:19:16 +00:00
|
|
|
/* on second and subsequent records per frame
|
|
|
|
* add a delimiter on info column
|
|
|
|
*/
|
|
|
|
if (!first_record_in_frame
|
2001-12-10 00:26:21 +00:00
|
|
|
&& check_col(pinfo->cinfo, COL_INFO))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/*
|
|
|
|
* Assume, for now, that this doesn't need desegmentation.
|
|
|
|
*/
|
|
|
|
need_desegmentation = FALSE;
|
2002-01-17 09:24:05 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* first try to dispatch off the cached version
|
|
|
|
* known to be associated with the conversation
|
|
|
|
*/
|
2006-02-04 23:44:05 +00:00
|
|
|
switch(*conv_version) {
|
2001-07-11 18:19:16 +00:00
|
|
|
case SSL_VER_SSLv2:
|
2002-04-11 09:43:22 +00:00
|
|
|
case SSL_VER_PCT:
|
2001-07-11 18:19:16 +00:00
|
|
|
offset = dissect_ssl2_record(tvb, pinfo, ssl_tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
offset, conv_version,
|
2006-08-07 19:52:18 +00:00
|
|
|
&need_desegmentation,
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_session);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_VER_SSLv3:
|
|
|
|
case SSL_VER_TLS:
|
|
|
|
/* the version tracking code works too well ;-)
|
|
|
|
* at times, we may visit a v2 client hello after
|
|
|
|
* we already know the version of the connection;
|
|
|
|
* work around that here by detecting and calling
|
|
|
|
* the v2 dissector instead
|
|
|
|
*/
|
|
|
|
if (ssl_is_v2_client_hello(tvb, offset))
|
|
|
|
{
|
|
|
|
offset = dissect_ssl2_record(tvb, pinfo, ssl_tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
offset, conv_version,
|
|
|
|
&need_desegmentation,
|
|
|
|
ssl_session);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
offset = dissect_ssl3_record(tvb, pinfo, ssl_tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
offset, conv_version,
|
|
|
|
&need_desegmentation,
|
2006-12-30 01:06:46 +00:00
|
|
|
ssl_session,
|
|
|
|
first_record_in_frame);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* that failed, so apply some heuristics based
|
|
|
|
* on this individual packet
|
|
|
|
*/
|
|
|
|
default:
|
|
|
|
if (ssl_looks_like_sslv2(tvb, offset))
|
|
|
|
{
|
2002-04-11 09:43:22 +00:00
|
|
|
/* looks like sslv2 or pct client hello */
|
2001-07-11 18:19:16 +00:00
|
|
|
offset = dissect_ssl2_record(tvb, pinfo, ssl_tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
offset, conv_version,
|
2006-08-07 19:52:18 +00:00
|
|
|
&need_desegmentation,
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_session);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
else if (ssl_looks_like_sslv3(tvb, offset))
|
|
|
|
{
|
|
|
|
/* looks like sslv3 or tls */
|
|
|
|
offset = dissect_ssl3_record(tvb, pinfo, ssl_tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
offset, conv_version,
|
|
|
|
&need_desegmentation,
|
2006-12-30 01:06:46 +00:00
|
|
|
ssl_session,
|
|
|
|
first_record_in_frame);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* looks like something unknown, so lump into
|
|
|
|
* continuation data
|
|
|
|
*/
|
|
|
|
offset = tvb_length(tvb);
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO,
|
2001-07-11 18:19:16 +00:00
|
|
|
"Continuation Data");
|
|
|
|
|
|
|
|
/* Set the protocol column */
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL,
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_version_short_names[*conv_version]);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-01-04 07:01:54 +00:00
|
|
|
/* Desegmentation return check */
|
2008-03-19 08:26:45 +00:00
|
|
|
if (need_desegmentation) {
|
|
|
|
ssl_debug_printf(" need_desegmentation: offset = %d, reported_length_remaining = %d\n", offset, tvb_reported_length_remaining(tvb, offset));
|
2002-01-04 07:01:54 +00:00
|
|
|
return;
|
2008-03-19 08:26:45 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
/* set up for next record in frame, if any */
|
|
|
|
first_record_in_frame = FALSE;
|
|
|
|
}
|
2008-07-09 07:24:13 +00:00
|
|
|
|
2007-04-18 04:13:50 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2008-07-09 07:24:13 +00:00
|
|
|
col_set_fence(pinfo->cinfo, COL_INFO);
|
2007-11-30 11:12:55 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
ssl_debug_flush();
|
2007-04-18 04:13:50 +00:00
|
|
|
|
2007-07-12 15:34:21 +00:00
|
|
|
tap_queue_packet(ssl_tap, pinfo, GINT_TO_POINTER(proto_ssl));
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2006-08-07 19:52:18 +00:00
|
|
|
decrypt_ssl3_record(tvbuff_t *tvb, packet_info *pinfo, guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint32 record_length, guint8 content_type, SslDecryptSession* ssl,
|
|
|
|
gboolean save_plaintext)
|
|
|
|
{
|
2006-08-02 08:15:51 +00:00
|
|
|
gint ret;
|
|
|
|
gint direction;
|
2007-01-04 09:20:18 +00:00
|
|
|
StringInfo* data_for_iv;
|
|
|
|
gint data_for_iv_len;
|
2006-02-04 23:44:05 +00:00
|
|
|
SslDecoder* decoder;
|
2006-08-02 08:15:51 +00:00
|
|
|
ret = 0;
|
2008-07-09 07:24:13 +00:00
|
|
|
/* if we can decrypt and decryption was a success
|
|
|
|
* add decrypted data to this packet info */
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("decrypt_ssl3_record: app_data len %d ssl, state 0x%02X\n",
|
2006-02-04 23:44:05 +00:00
|
|
|
record_length, ssl->state);
|
2007-01-04 09:20:18 +00:00
|
|
|
direction = ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* retrieve decoder for this packet direction */
|
2007-01-04 09:20:18 +00:00
|
|
|
if (direction != 0) {
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_debug_printf("decrypt_ssl3_record: using server decoder\n");
|
2007-04-10 15:12:48 +00:00
|
|
|
decoder = ssl->server;
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
else {
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_debug_printf("decrypt_ssl3_record: using client decoder\n");
|
2007-04-10 15:12:48 +00:00
|
|
|
decoder = ssl->client;
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2007-11-01 10:50:01 +00:00
|
|
|
/* save data to update IV if decoder is available or updated later */
|
|
|
|
data_for_iv = (direction != 0) ? &ssl->server_data_for_iv : &ssl->client_data_for_iv;
|
|
|
|
data_for_iv_len = (record_length < 24) ? record_length : 24;
|
|
|
|
ssl_data_set(data_for_iv, (guchar*)tvb_get_ptr(tvb, offset + record_length - data_for_iv_len, data_for_iv_len), data_for_iv_len);
|
|
|
|
|
2007-04-10 15:12:48 +00:00
|
|
|
if (!decoder) {
|
|
|
|
ssl_debug_printf("decrypt_ssl3_record: no decoder available\n");
|
|
|
|
return ret;
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
|
|
|
/* run decryption and add decrypted payload to protocol data, if decryption
|
2008-07-09 07:24:13 +00:00
|
|
|
* is successful*/
|
2006-08-07 19:52:18 +00:00
|
|
|
ssl_decrypted_data_avail = ssl_decrypted_data.data_len;
|
|
|
|
if (ssl_decrypt_record(ssl, decoder,
|
2006-05-03 05:29:04 +00:00
|
|
|
content_type, tvb_get_ptr(tvb, offset, record_length),
|
2007-04-10 15:12:48 +00:00
|
|
|
record_length, &ssl_compressed_data, &ssl_decrypted_data, &ssl_decrypted_data_avail) == 0)
|
2006-05-03 05:29:04 +00:00
|
|
|
ret = 1;
|
2007-01-04 09:20:18 +00:00
|
|
|
/* */
|
|
|
|
if (!ret) {
|
|
|
|
/* save data to update IV if valid session key is obtained later */
|
|
|
|
data_for_iv = (direction != 0) ? &ssl->server_data_for_iv : &ssl->client_data_for_iv;
|
|
|
|
data_for_iv_len = (record_length < 24) ? record_length : 24;
|
|
|
|
ssl_data_set(data_for_iv, (guchar*)tvb_get_ptr(tvb, offset + record_length - data_for_iv_len, data_for_iv_len), data_for_iv_len);
|
|
|
|
}
|
2007-01-12 10:25:03 +00:00
|
|
|
if (ret && save_plaintext) {
|
2007-04-10 15:12:48 +00:00
|
|
|
ssl_add_data_info(proto_ssl, pinfo, ssl_decrypted_data.data, ssl_decrypted_data_avail, TVB_RAW_OFFSET(tvb)+offset, decoder->flow);
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2006-05-03 05:29:04 +00:00
|
|
|
return ret;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 15:12:48 +00:00
|
|
|
static void
|
|
|
|
process_ssl_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo,
|
2007-04-20 14:19:20 +00:00
|
|
|
proto_tree *tree, SslAssociation* association);
|
2007-04-10 15:12:48 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
desegment_ssl(tvbuff_t *tvb, packet_info *pinfo, int offset,
|
|
|
|
guint32 seq, guint32 nxtseq,
|
|
|
|
SslAssociation* association,
|
|
|
|
proto_tree *root_tree, proto_tree *tree,
|
|
|
|
SslFlow *flow)
|
|
|
|
{
|
|
|
|
fragment_data *ipfd_head;
|
|
|
|
gboolean must_desegment;
|
|
|
|
gboolean called_dissector;
|
|
|
|
int another_pdu_follows;
|
|
|
|
int deseg_offset;
|
|
|
|
guint32 deseg_seq;
|
|
|
|
gint nbytes;
|
|
|
|
proto_item *item;
|
|
|
|
proto_item *frag_tree_item;
|
|
|
|
proto_item *ssl_tree_item;
|
|
|
|
struct tcp_multisegment_pdu *msp;
|
|
|
|
|
|
|
|
again:
|
|
|
|
ipfd_head=NULL;
|
|
|
|
must_desegment = FALSE;
|
|
|
|
called_dissector = FALSE;
|
|
|
|
another_pdu_follows = 0;
|
|
|
|
msp=NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize these to assume no desegmentation.
|
|
|
|
* If that's not the case, these will be set appropriately
|
|
|
|
* by the subdissector.
|
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = 0;
|
|
|
|
pinfo->desegment_len = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize this to assume that this segment will just be
|
|
|
|
* added to the middle of a desegmented chunk of data, so
|
|
|
|
* that we should show it all as data.
|
|
|
|
* If that's not the case, it will be set appropriately.
|
|
|
|
*/
|
|
|
|
deseg_offset = offset;
|
|
|
|
|
|
|
|
/* find the most previous PDU starting before this sequence number */
|
|
|
|
msp=se_tree_lookup32_le(flow->multisegment_pdus, seq-1);
|
|
|
|
if(msp && msp->seq<=seq && msp->nxtpdu>seq){
|
|
|
|
int len;
|
|
|
|
|
|
|
|
if(!pinfo->fd->flags.visited){
|
|
|
|
msp->last_frame=pinfo->fd->num;
|
|
|
|
msp->last_frame_time=pinfo->fd->abs_ts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* OK, this PDU was found, which means the segment continues
|
|
|
|
a higher-level PDU and that we must desegment it.
|
|
|
|
*/
|
|
|
|
if(msp->flags&MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT){
|
|
|
|
/* The dissector asked for the entire segment */
|
|
|
|
len=tvb_length_remaining(tvb, offset);
|
|
|
|
} else {
|
|
|
|
len=MIN(nxtseq, msp->nxtpdu) - seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipfd_head = fragment_add(tvb, offset, pinfo, msp->first_frame,
|
|
|
|
ssl_fragment_table,
|
|
|
|
seq - msp->seq,
|
|
|
|
len,
|
|
|
|
(LT_SEQ (nxtseq,msp->nxtpdu)) );
|
|
|
|
|
|
|
|
if(msp->flags&MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT){
|
|
|
|
msp->flags&=(~MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT);
|
|
|
|
|
|
|
|
/* If we consumed the entire segment there is no
|
|
|
|
* other pdu starting anywhere inside this segment.
|
|
|
|
* So update nxtpdu to point at least to the start
|
|
|
|
* of the next segment.
|
|
|
|
* (If the subdissector asks for even more data we
|
|
|
|
* will advance nxtpdu even furhter later down in
|
|
|
|
* the code.)
|
|
|
|
*/
|
|
|
|
msp->nxtpdu=nxtseq;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (msp->nxtpdu<nxtseq)
|
|
|
|
&& (msp->nxtpdu>=seq)
|
|
|
|
&& (len>0) ){
|
|
|
|
another_pdu_follows=msp->nxtpdu-seq;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* This segment was not found in our table, so it doesn't
|
|
|
|
contain a continuation of a higher-level PDU.
|
|
|
|
Call the normal subdissector.
|
|
|
|
*/
|
2007-04-20 14:19:20 +00:00
|
|
|
process_ssl_payload(tvb, offset, pinfo, tree, association);
|
2007-04-10 15:12:48 +00:00
|
|
|
called_dissector = TRUE;
|
|
|
|
|
|
|
|
/* Did the subdissector ask us to desegment some more data
|
|
|
|
before it could handle the packet?
|
|
|
|
If so we have to create some structures in our table but
|
|
|
|
this is something we only do the first time we see this
|
|
|
|
packet.
|
|
|
|
*/
|
|
|
|
if(pinfo->desegment_len) {
|
|
|
|
if (!pinfo->fd->flags.visited)
|
|
|
|
must_desegment = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set "deseg_offset" to the offset in "tvb"
|
|
|
|
* of the first byte of data that the
|
|
|
|
* subdissector didn't process.
|
|
|
|
*/
|
|
|
|
deseg_offset = offset + pinfo->desegment_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Either no desegmentation is necessary, or this is
|
|
|
|
segment contains the beginning but not the end of
|
|
|
|
a higher-level PDU and thus isn't completely
|
|
|
|
desegmented.
|
|
|
|
*/
|
|
|
|
ipfd_head = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* is it completely desegmented? */
|
|
|
|
if(ipfd_head){
|
|
|
|
/*
|
|
|
|
* Yes, we think it is.
|
|
|
|
* We only call subdissector for the last segment.
|
|
|
|
* Note that the last segment may include more than what
|
|
|
|
* we needed.
|
|
|
|
*/
|
|
|
|
if(ipfd_head->reassembled_in==pinfo->fd->num){
|
|
|
|
/*
|
|
|
|
* OK, this is the last segment.
|
|
|
|
* Let's call the subdissector with the desegmented
|
|
|
|
* data.
|
|
|
|
*/
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
int old_len;
|
|
|
|
|
|
|
|
/* create a new TVB structure for desegmented data */
|
2009-05-13 19:46:11 +00:00
|
|
|
next_tvb = tvb_new_child_real_data(tvb, ipfd_head->data,
|
2007-04-10 15:12:48 +00:00
|
|
|
ipfd_head->datalen, ipfd_head->datalen);
|
|
|
|
|
|
|
|
/* add desegmented data to the data source list */
|
|
|
|
add_new_data_source(pinfo, next_tvb, "Reassembled SSL");
|
|
|
|
|
|
|
|
/* call subdissector */
|
2007-04-20 14:19:20 +00:00
|
|
|
process_ssl_payload(next_tvb, 0, pinfo, tree, association);
|
2007-04-10 15:12:48 +00:00
|
|
|
called_dissector = TRUE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OK, did the subdissector think it was completely
|
|
|
|
* desegmented, or does it think we need even more
|
|
|
|
* data?
|
|
|
|
*/
|
|
|
|
old_len=(int)(tvb_reported_length(next_tvb)-tvb_reported_length_remaining(tvb, offset));
|
|
|
|
if(pinfo->desegment_len &&
|
|
|
|
pinfo->desegment_offset<=old_len){
|
|
|
|
/*
|
|
|
|
* "desegment_len" isn't 0, so it needs more
|
|
|
|
* data for something - and "desegment_offset"
|
|
|
|
* is before "old_len", so it needs more data
|
|
|
|
* to dissect the stuff we thought was
|
|
|
|
* completely desegmented (as opposed to the
|
|
|
|
* stuff at the beginning being completely
|
|
|
|
* desegmented, but the stuff at the end
|
|
|
|
* being a new higher-level PDU that also
|
|
|
|
* needs desegmentation).
|
|
|
|
*/
|
|
|
|
fragment_set_partial_reassembly(pinfo,msp->first_frame,ssl_fragment_table);
|
|
|
|
/* Update msp->nxtpdu to point to the new next
|
|
|
|
* pdu boundary.
|
|
|
|
*/
|
|
|
|
if(pinfo->desegment_len==DESEGMENT_ONE_MORE_SEGMENT){
|
|
|
|
/* We want reassembly of at least one
|
2007-04-18 04:13:50 +00:00
|
|
|
* more segment so set the nxtpdu
|
|
|
|
* boundary to one byte into the next
|
2007-04-10 15:12:48 +00:00
|
|
|
* segment.
|
2007-04-18 04:13:50 +00:00
|
|
|
* This means that the next segment
|
2007-04-10 15:12:48 +00:00
|
|
|
* will complete reassembly even if it
|
|
|
|
* is only one single byte in length.
|
|
|
|
*/
|
|
|
|
msp->nxtpdu=seq+tvb_reported_length_remaining(tvb, offset) + 1;
|
|
|
|
msp->flags|=MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT;
|
|
|
|
} else {
|
|
|
|
msp->nxtpdu=seq+tvb_reported_length_remaining(tvb, offset) + pinfo->desegment_len;
|
|
|
|
}
|
|
|
|
/* Since we need at least some more data
|
|
|
|
* there can be no pdu following in the
|
|
|
|
* tail of this segment.
|
|
|
|
*/
|
|
|
|
another_pdu_follows=0;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Show the stuff in this TCP segment as
|
|
|
|
* just raw TCP segment data.
|
|
|
|
*/
|
|
|
|
nbytes =
|
|
|
|
tvb_reported_length_remaining(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, -1,
|
|
|
|
"SSL segment data (%u byte%s)", nbytes,
|
|
|
|
plurality(nbytes, "", "s"));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The subdissector thought it was completely
|
|
|
|
* desegmented (although the stuff at the
|
|
|
|
* end may, in turn, require desegmentation),
|
|
|
|
* so we show a tree with all segments.
|
|
|
|
*/
|
|
|
|
show_fragment_tree(ipfd_head, &ssl_segment_items,
|
|
|
|
root_tree, pinfo, next_tvb, &frag_tree_item);
|
|
|
|
/*
|
|
|
|
* The toplevel fragment subtree is now
|
|
|
|
* behind all desegmented data; move it
|
|
|
|
* right behind the TCP tree.
|
|
|
|
*/
|
|
|
|
ssl_tree_item = proto_tree_get_parent(tree);
|
|
|
|
if(frag_tree_item && ssl_tree_item) {
|
|
|
|
proto_tree_move_item(root_tree, ssl_tree_item, frag_tree_item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Did the subdissector ask us to desegment
|
|
|
|
some more data? This means that the data
|
|
|
|
at the beginning of this segment completed
|
|
|
|
a higher-level PDU, but the data at the
|
|
|
|
end of this segment started a higher-level
|
|
|
|
PDU but didn't complete it.
|
|
|
|
|
|
|
|
If so, we have to create some structures
|
|
|
|
in our table, but this is something we
|
|
|
|
only do the first time we see this packet.
|
|
|
|
*/
|
|
|
|
if(pinfo->desegment_len) {
|
|
|
|
if (!pinfo->fd->flags.visited)
|
|
|
|
must_desegment = TRUE;
|
|
|
|
|
|
|
|
/* The stuff we couldn't dissect
|
|
|
|
must have come from this segment,
|
|
|
|
so it's all in "tvb".
|
|
|
|
|
|
|
|
"pinfo->desegment_offset" is
|
|
|
|
relative to the beginning of
|
|
|
|
"next_tvb"; we want an offset
|
|
|
|
relative to the beginning of "tvb".
|
|
|
|
|
|
|
|
First, compute the offset relative
|
|
|
|
to the *end* of "next_tvb" - i.e.,
|
|
|
|
the number of bytes before the end
|
|
|
|
of "next_tvb" at which the
|
|
|
|
subdissector stopped. That's the
|
|
|
|
length of "next_tvb" minus the
|
|
|
|
offset, relative to the beginning
|
|
|
|
of "next_tvb, at which the
|
|
|
|
subdissector stopped.
|
|
|
|
*/
|
|
|
|
deseg_offset =
|
|
|
|
ipfd_head->datalen - pinfo->desegment_offset;
|
|
|
|
|
|
|
|
/* "tvb" and "next_tvb" end at the
|
|
|
|
same byte of data, so the offset
|
|
|
|
relative to the end of "next_tvb"
|
|
|
|
of the byte at which we stopped
|
|
|
|
is also the offset relative to
|
|
|
|
the end of "tvb" of the byte at
|
|
|
|
which we stopped.
|
|
|
|
|
|
|
|
Convert that back into an offset
|
|
|
|
relative to the beginninng of
|
|
|
|
"tvb", by taking the length of
|
|
|
|
"tvb" and subtracting the offset
|
|
|
|
relative to the end.
|
|
|
|
*/
|
|
|
|
deseg_offset=tvb_reported_length(tvb) - deseg_offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (must_desegment) {
|
|
|
|
/* If the dissector requested "reassemble until FIN"
|
|
|
|
* just set this flag for the flow and let reassembly
|
|
|
|
* proceed at normal. We will check/pick up these
|
|
|
|
* reassembled PDUs later down in dissect_tcp() when checking
|
|
|
|
* for the FIN flag.
|
|
|
|
*/
|
|
|
|
if(pinfo->desegment_len==DESEGMENT_UNTIL_FIN){
|
|
|
|
flow->flags|=TCP_FLOW_REASSEMBLE_UNTIL_FIN;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* The sequence number at which the stuff to be desegmented
|
|
|
|
* starts is the sequence number of the byte at an offset
|
|
|
|
* of "deseg_offset" into "tvb".
|
|
|
|
*
|
|
|
|
* The sequence number of the byte at an offset of "offset"
|
|
|
|
* is "seq", i.e. the starting sequence number of this
|
|
|
|
* segment, so the sequence number of the byte at
|
|
|
|
* "deseg_offset" is "seq + (deseg_offset - offset)".
|
|
|
|
*/
|
|
|
|
deseg_seq = seq + (deseg_offset - offset);
|
|
|
|
|
|
|
|
if( ((nxtseq - deseg_seq) <= 1024*1024)
|
|
|
|
&& (!pinfo->fd->flags.visited) ){
|
|
|
|
if(pinfo->desegment_len==DESEGMENT_ONE_MORE_SEGMENT){
|
|
|
|
/* The subdissector asked to reassemble using the
|
|
|
|
* entire next segment.
|
|
|
|
* Just ask reassembly for one more byte
|
|
|
|
* but set this msp flag so we can pick it up
|
|
|
|
* above.
|
|
|
|
*/
|
2007-04-18 04:13:50 +00:00
|
|
|
msp = pdu_store_sequencenumber_of_next_pdu(pinfo,
|
2007-04-10 15:12:48 +00:00
|
|
|
deseg_seq, nxtseq+1, flow->multisegment_pdus);
|
|
|
|
msp->flags|=MSP_FLAGS_REASSEMBLE_ENTIRE_SEGMENT;
|
|
|
|
} else {
|
2007-04-18 04:13:50 +00:00
|
|
|
msp = pdu_store_sequencenumber_of_next_pdu(pinfo,
|
2007-04-10 15:12:48 +00:00
|
|
|
deseg_seq, nxtseq+pinfo->desegment_len, flow->multisegment_pdus);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add this segment as the first one for this new pdu */
|
|
|
|
fragment_add(tvb, deseg_offset, pinfo, msp->first_frame,
|
|
|
|
ssl_fragment_table,
|
|
|
|
0,
|
|
|
|
nxtseq - deseg_seq,
|
|
|
|
LT_SEQ(nxtseq, msp->nxtpdu));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!called_dissector || pinfo->desegment_len != 0) {
|
|
|
|
if (ipfd_head != NULL && ipfd_head->reassembled_in != 0 &&
|
|
|
|
!(ipfd_head->flags & FD_PARTIAL_REASSEMBLY)) {
|
|
|
|
/*
|
|
|
|
* We know what frame this PDU is reassembled in;
|
|
|
|
* let the user know.
|
|
|
|
*/
|
|
|
|
item=proto_tree_add_uint(tree, *ssl_segment_items.hf_reassembled_in,
|
|
|
|
tvb, 0, 0, ipfd_head->reassembled_in);
|
|
|
|
PROTO_ITEM_SET_GENERATED(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Either we didn't call the subdissector at all (i.e.,
|
|
|
|
* this is a segment that contains the middle of a
|
|
|
|
* higher-level PDU, but contains neither the beginning
|
|
|
|
* nor the end), or the subdissector couldn't dissect it
|
|
|
|
* all, as some data was missing (i.e., it set
|
|
|
|
* "pinfo->desegment_len" to the amount of additional
|
|
|
|
* data it needs).
|
|
|
|
*/
|
|
|
|
if (pinfo->desegment_offset == 0) {
|
|
|
|
/*
|
|
|
|
* It couldn't, in fact, dissect any of it (the
|
|
|
|
* first byte it couldn't dissect is at an offset
|
|
|
|
* of "pinfo->desegment_offset" from the beginning
|
|
|
|
* of the payload, and that's 0).
|
|
|
|
* Just mark this as SSL.
|
|
|
|
*/
|
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL)){
|
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "SSL");
|
|
|
|
}
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO)){
|
|
|
|
col_set_str(pinfo->cinfo, COL_INFO, "[SSL segment of a reassembled PDU]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show what's left in the packet as just raw TCP segment
|
|
|
|
* data.
|
|
|
|
* XXX - remember what protocol the last subdissector
|
|
|
|
* was, and report it as a continuation of that, instead?
|
|
|
|
*/
|
|
|
|
nbytes = tvb_reported_length_remaining(tvb, deseg_offset);
|
|
|
|
proto_tree_add_text(tree, tvb, deseg_offset, -1,
|
|
|
|
"SSL segment data (%u byte%s)", nbytes,
|
|
|
|
plurality(nbytes, "", "s"));
|
|
|
|
}
|
|
|
|
pinfo->can_desegment=0;
|
|
|
|
pinfo->desegment_offset = 0;
|
|
|
|
pinfo->desegment_len = 0;
|
|
|
|
|
|
|
|
if(another_pdu_follows){
|
|
|
|
/* there was another pdu following this one. */
|
|
|
|
pinfo->can_desegment=2;
|
2007-04-18 04:13:50 +00:00
|
|
|
/* we also have to prevent the dissector from changing the
|
|
|
|
* PROTOCOL and INFO colums since what follows may be an
|
2007-04-10 15:12:48 +00:00
|
|
|
* incomplete PDU and we dont want it be changed back from
|
|
|
|
* <Protocol> to <TCP>
|
|
|
|
* XXX There is no good way to block the PROTOCOL column
|
|
|
|
* from being changed yet so we set the entire row unwritable.
|
|
|
|
*/
|
|
|
|
col_set_fence(pinfo->cinfo, COL_INFO);
|
|
|
|
col_set_writable(pinfo->cinfo, FALSE);
|
|
|
|
offset += another_pdu_follows;
|
|
|
|
seq += another_pdu_follows;
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
process_ssl_payload(tvbuff_t *tvb, volatile int offset, packet_info *pinfo,
|
2007-04-20 14:19:20 +00:00
|
|
|
proto_tree *tree, SslAssociation* association)
|
2007-04-10 15:12:48 +00:00
|
|
|
{
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
|
|
|
next_tvb = tvb_new_subset(tvb, offset, -1, -1);
|
|
|
|
|
|
|
|
if (association && association->handle) {
|
2008-02-11 17:04:51 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_record found association %p\n", (void *)association);
|
2007-04-10 15:12:48 +00:00
|
|
|
call_dissector(association->handle, next_tvb, pinfo, proto_tree_get_root(tree));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-12 10:25:03 +00:00
|
|
|
void
|
|
|
|
dissect_ssl_payload(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *tree, SslAssociation* association)
|
|
|
|
{
|
|
|
|
gboolean save_fragmented;
|
2007-12-28 01:23:01 +00:00
|
|
|
guint16 save_can_desegment;
|
2007-01-12 10:25:03 +00:00
|
|
|
SslDataInfo *appl_data;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2007-12-28 01:23:01 +00:00
|
|
|
/* Preserve current desegmentation ability to prevent the subdissector
|
|
|
|
* from messing up the ssl desegmentation */
|
|
|
|
save_can_desegment = pinfo->can_desegment;
|
|
|
|
|
2007-01-12 10:25:03 +00:00
|
|
|
/* show decrypted data info, if available */
|
|
|
|
appl_data = ssl_get_data_info(proto_ssl, pinfo, TVB_RAW_OFFSET(tvb)+offset);
|
|
|
|
if (!appl_data || !appl_data->plain_data.data_len) return;
|
|
|
|
|
|
|
|
/* try to dissect decrypted data*/
|
|
|
|
ssl_debug_printf("dissect_ssl3_record decrypted len %d\n", appl_data->plain_data.data_len);
|
2007-04-10 15:12:48 +00:00
|
|
|
ssl_print_text_data("decrypted app data fragment", appl_data->plain_data.data, appl_data->plain_data.data_len);
|
2007-01-12 10:25:03 +00:00
|
|
|
|
|
|
|
/* create a new TVB structure for desegmented data */
|
2009-05-13 19:46:11 +00:00
|
|
|
next_tvb = tvb_new_child_real_data(tvb, appl_data->plain_data.data, appl_data->plain_data.data_len, appl_data->plain_data.data_len);
|
2007-01-12 10:25:03 +00:00
|
|
|
|
|
|
|
/* add desegmented data to the data source list */
|
|
|
|
add_new_data_source(pinfo, next_tvb, "Decrypted SSL data");
|
|
|
|
|
|
|
|
/* Can we desegment this segment? */
|
2007-04-10 15:12:48 +00:00
|
|
|
if (ssl_desegment_app_data) {
|
2007-01-12 10:25:03 +00:00
|
|
|
/* Yes. */
|
2007-04-10 15:12:48 +00:00
|
|
|
pinfo->can_desegment = 2;
|
|
|
|
desegment_ssl(next_tvb, pinfo, 0, appl_data->seq, appl_data->nxtseq, association, proto_tree_get_root(tree), tree, appl_data->flow);
|
2007-01-12 10:25:03 +00:00
|
|
|
} else if (association && association->handle) {
|
|
|
|
/* No - just call the subdissector.
|
|
|
|
Mark this as fragmented, so if somebody throws an exception,
|
|
|
|
we don't report it as a malformed frame. */
|
2007-04-10 15:12:48 +00:00
|
|
|
pinfo->can_desegment = 0;
|
2007-01-12 10:25:03 +00:00
|
|
|
save_fragmented = pinfo->fragmented;
|
|
|
|
pinfo->fragmented = TRUE;
|
2007-04-20 14:19:20 +00:00
|
|
|
|
|
|
|
process_ssl_payload(next_tvb, 0, pinfo, tree, association);
|
2007-01-12 10:25:03 +00:00
|
|
|
pinfo->fragmented = save_fragmented;
|
|
|
|
}
|
2008-05-22 15:46:27 +00:00
|
|
|
|
2007-12-28 01:23:01 +00:00
|
|
|
/* restore desegmentation ability */
|
|
|
|
pinfo->can_desegment = save_can_desegment;
|
2007-01-12 10:25:03 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* SSL version 3 and TLS Dissection Routines
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
dissect_ssl3_record(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint *conv_version, gboolean *need_desegmentation,
|
2007-03-21 14:00:23 +00:00
|
|
|
SslDecryptSession* ssl, gboolean first_record_in_frame _U_)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* struct {
|
|
|
|
* uint8 major, minor;
|
|
|
|
* } ProtocolVersion;
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* enum {
|
|
|
|
* change_cipher_spec(20), alert(21), handshake(22),
|
|
|
|
* application_data(23), (255)
|
|
|
|
* } ContentType;
|
|
|
|
*
|
|
|
|
* struct {
|
|
|
|
* ContentType type;
|
|
|
|
* ProtocolVersion version;
|
|
|
|
* uint16 length;
|
|
|
|
* opaque fragment[TLSPlaintext.length];
|
|
|
|
* } TLSPlaintext;
|
|
|
|
*/
|
|
|
|
guint32 record_length;
|
|
|
|
guint16 version;
|
|
|
|
guint8 content_type;
|
|
|
|
guint8 next_byte;
|
2006-08-02 08:15:51 +00:00
|
|
|
proto_tree *ti;
|
|
|
|
proto_tree *ssl_record_tree;
|
2006-02-04 23:44:05 +00:00
|
|
|
SslAssociation* association;
|
2007-01-12 10:25:03 +00:00
|
|
|
guint32 available_bytes;
|
2006-08-02 08:15:51 +00:00
|
|
|
ti = NULL;
|
|
|
|
ssl_record_tree = NULL;
|
|
|
|
available_bytes = 0;
|
2006-07-01 05:41:30 +00:00
|
|
|
|
2002-03-28 09:15:28 +00:00
|
|
|
available_bytes = tvb_length_remaining(tvb, offset);
|
|
|
|
|
2007-01-26 12:08:45 +00:00
|
|
|
/* TLS 1.0/1.1 just ignores unknown records - RFC 2246 chapter 6. The TLS Record Protocol */
|
2009-02-11 07:03:51 +00:00
|
|
|
if ((*conv_version==SSL_VER_TLS || *conv_version==SSL_VER_TLSv1DOT1 || *conv_version==SSL_VER_TLSv1DOT2) &&
|
2007-01-26 12:08:45 +00:00
|
|
|
(available_bytes >=1 ) && !ssl_is_valid_content_type(tvb_get_guint8(tvb, offset))) {
|
|
|
|
proto_tree_add_text(tree, tvb, offset, available_bytes, "Ignored Unknown Record");
|
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Ignored Unknown Record");
|
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
2008-07-09 07:24:13 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, ssl_version_short_names[*conv_version]);
|
2007-01-26 12:08:45 +00:00
|
|
|
return offset + available_bytes;
|
|
|
|
}
|
|
|
|
|
2006-06-27 13:36:10 +00:00
|
|
|
/*
|
2002-03-28 09:15:28 +00:00
|
|
|
* Can we do reassembly?
|
|
|
|
*/
|
|
|
|
if (ssl_desegment && pinfo->can_desegment) {
|
|
|
|
/*
|
|
|
|
* Yes - is the record header split across segment boundaries?
|
|
|
|
*/
|
|
|
|
if (available_bytes < 5) {
|
|
|
|
/*
|
|
|
|
* Yes. Tell the TCP dissector where the data for this
|
|
|
|
* message starts in the data it handed us, and how many
|
|
|
|
* more bytes we need, and return.
|
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = offset;
|
|
|
|
pinfo->desegment_len = 5 - available_bytes;
|
|
|
|
*need_desegmentation = TRUE;
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/*
|
|
|
|
* Get the record layer fields of interest
|
|
|
|
*/
|
|
|
|
content_type = tvb_get_guint8(tvb, offset);
|
|
|
|
version = tvb_get_ntohs(tvb, offset + 1);
|
|
|
|
record_length = tvb_get_ntohs(tvb, offset + 3);
|
|
|
|
|
2002-01-04 07:01:54 +00:00
|
|
|
if (ssl_is_valid_content_type(content_type)) {
|
|
|
|
|
|
|
|
/*
|
2002-03-28 09:15:28 +00:00
|
|
|
* Can we do reassembly?
|
2002-01-04 07:01:54 +00:00
|
|
|
*/
|
2002-03-28 09:15:28 +00:00
|
|
|
if (ssl_desegment && pinfo->can_desegment) {
|
|
|
|
/*
|
|
|
|
* Yes - is the record split across segment boundaries?
|
|
|
|
*/
|
|
|
|
if (available_bytes < record_length + 5) {
|
|
|
|
/*
|
|
|
|
* Yes. Tell the TCP dissector where the data for this
|
|
|
|
* message starts in the data it handed us, and how many
|
|
|
|
* more bytes we need, and return.
|
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = offset;
|
2009-04-19 20:28:18 +00:00
|
|
|
|
|
|
|
/* Don't use:
|
|
|
|
* pinfo->desegment_len = (record_length + 5) - available_bytes;
|
|
|
|
* as it will display two SSL subtrees when a frame contains
|
|
|
|
* the continuation of a previous PDU together with a full new
|
|
|
|
* PDU (and the info column would not show the message type
|
|
|
|
* of the second PDU)
|
|
|
|
*/
|
|
|
|
pinfo->desegment_len = DESEGMENT_ONE_MORE_SEGMENT;
|
2002-03-28 09:15:28 +00:00
|
|
|
*need_desegmentation = TRUE;
|
|
|
|
return offset;
|
|
|
|
}
|
2002-01-04 07:01:54 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-01-04 07:01:54 +00:00
|
|
|
} else {
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2008-09-07 03:13:10 +00:00
|
|
|
/* if we don't have a valid content_type, there's no sense
|
|
|
|
* continuing any further
|
|
|
|
*/
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Continuation Data");
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* Set the protocol column */
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL,
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_version_short_names[*conv_version]);
|
|
|
|
}
|
|
|
|
return offset + 5 + record_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-09-07 03:13:10 +00:00
|
|
|
* If building a protocol tree, fill in record layer part of tree
|
2001-07-11 18:19:16 +00:00
|
|
|
*/
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* add the record layer subtree header */
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, 5 + record_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
ti = proto_tree_add_item(tree, hf_ssl_record, tvb,
|
|
|
|
offset, 5 + record_length, 0);
|
|
|
|
ssl_record_tree = proto_item_add_subtree(ti, ett_ssl_record);
|
|
|
|
|
|
|
|
/* show the one-byte content type */
|
|
|
|
proto_tree_add_item(ssl_record_tree, hf_ssl_record_content_type,
|
|
|
|
tvb, offset, 1, 0);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* add the version */
|
|
|
|
proto_tree_add_item(ssl_record_tree, hf_ssl_record_version, tvb,
|
|
|
|
offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* add the length */
|
|
|
|
proto_tree_add_uint(ssl_record_tree, hf_ssl_record_length, tvb,
|
|
|
|
offset, 2, record_length);
|
|
|
|
offset += 2; /* move past length field itself */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-09-07 03:13:10 +00:00
|
|
|
/* if no protocol tree, then just skip over those fields */
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if we don't already have a version set for this conversation,
|
|
|
|
* but this message's version is authoritative (i.e., it's
|
|
|
|
* not client_hello, then save the version to to conversation
|
|
|
|
* structure and print the column version
|
|
|
|
*/
|
|
|
|
next_byte = tvb_get_guint8(tvb, offset);
|
|
|
|
if (*conv_version == SSL_VER_UNKNOWN
|
|
|
|
&& ssl_is_authoritative_version_message(content_type, next_byte))
|
|
|
|
{
|
2006-06-27 13:36:10 +00:00
|
|
|
if (version == SSLV3_VERSION)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
*conv_version = SSL_VER_SSLv3;
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl) {
|
|
|
|
ssl->version_netorder = version;
|
|
|
|
ssl->state |= SSL_VERSION;
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_record found version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
|
|
|
/*ssl_set_conv_version(pinfo, ssl->version);*/
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2006-06-27 13:36:10 +00:00
|
|
|
else if (version == TLSV1_VERSION)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
*conv_version = SSL_VER_TLS;
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl) {
|
|
|
|
ssl->version_netorder = version;
|
|
|
|
ssl->state |= SSL_VERSION;
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_record found version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
|
|
|
/*ssl_set_conv_version(pinfo, ssl->version);*/
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2006-06-27 13:36:10 +00:00
|
|
|
else if (version == TLSV1DOT1_VERSION)
|
|
|
|
{
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-06-27 13:36:10 +00:00
|
|
|
*conv_version = SSL_VER_TLSv1DOT1;
|
|
|
|
if (ssl) {
|
|
|
|
ssl->version_netorder = version;
|
|
|
|
ssl->state |= SSL_VERSION;
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_record found version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
2006-06-27 13:36:10 +00:00
|
|
|
}
|
|
|
|
/*ssl_set_conv_version(pinfo, ssl->version);*/
|
|
|
|
}
|
2009-02-11 07:03:51 +00:00
|
|
|
else if (version == TLSV1DOT2_VERSION)
|
|
|
|
{
|
|
|
|
|
|
|
|
*conv_version = SSL_VER_TLSv1DOT2;
|
|
|
|
if (ssl) {
|
|
|
|
ssl->version_netorder = version;
|
|
|
|
ssl->state |= SSL_VERSION;
|
|
|
|
ssl_debug_printf("dissect_ssl3_record found version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
|
|
|
}
|
|
|
|
/*ssl_set_conv_version(pinfo, ssl->version);*/
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL,
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_version_short_names[*conv_version]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* now dissect the next layer
|
|
|
|
*/
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_record: content_type %d\n",content_type);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
|
|
|
/* PAOLO try to decrypt each record (we must keep ciphers "in sync")
|
2006-02-04 23:44:05 +00:00
|
|
|
* store plain text only for app data */
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
switch (content_type) {
|
|
|
|
case SSL_ID_CHG_CIPHER_SPEC:
|
2007-04-10 15:12:48 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_change_cipher_spec\n");
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Change Cipher Spec");
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl3_change_cipher_spec(tvb, ssl_record_tree,
|
2005-03-06 04:42:51 +00:00
|
|
|
offset, conv_version, content_type);
|
2007-04-10 15:12:48 +00:00
|
|
|
if (ssl) ssl_change_cipher(ssl, ssl_packet_from_server(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP));
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
case SSL_ID_ALERT:
|
2008-07-09 07:24:13 +00:00
|
|
|
{
|
|
|
|
tvbuff_t* decrypted;
|
|
|
|
|
|
|
|
if (ssl&&decrypt_ssl3_record(tvb, pinfo, offset,
|
2006-06-27 13:36:10 +00:00
|
|
|
record_length, content_type, ssl, FALSE))
|
2008-07-09 07:24:13 +00:00
|
|
|
ssl_add_record_info(proto_ssl, pinfo, ssl_decrypted_data.data,
|
|
|
|
ssl_decrypted_data_avail, offset);
|
2006-06-27 13:36:10 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* try to retrieve and use decrypted alert record, if any. */
|
2006-08-02 08:15:51 +00:00
|
|
|
decrypted = ssl_get_record_info(proto_ssl, pinfo, offset);
|
2006-06-27 13:36:10 +00:00
|
|
|
if (decrypted)
|
2008-07-09 07:24:13 +00:00
|
|
|
dissect_ssl3_alert(decrypted, pinfo, ssl_record_tree, 0, conv_version);
|
|
|
|
else
|
|
|
|
dissect_ssl3_alert(tvb, pinfo, ssl_record_tree, offset, conv_version);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
2008-07-09 07:24:13 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
case SSL_ID_HANDSHAKE:
|
2006-05-03 05:29:04 +00:00
|
|
|
{
|
2006-08-02 08:15:51 +00:00
|
|
|
tvbuff_t* decrypted;
|
2008-07-09 07:24:13 +00:00
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
/* try to decrypt handshake record, if possible. Store decrypted
|
2008-07-09 07:24:13 +00:00
|
|
|
* record for later usage. The offset is used as 'key' to identify
|
|
|
|
* this record in the packet (we can have multiple handshake records
|
2006-05-03 05:29:04 +00:00
|
|
|
* in the same frame) */
|
2006-08-07 19:52:18 +00:00
|
|
|
if (ssl && decrypt_ssl3_record(tvb, pinfo, offset,
|
|
|
|
record_length, content_type, ssl, FALSE))
|
|
|
|
ssl_add_record_info(proto_ssl, pinfo, ssl_decrypted_data.data,
|
2006-05-03 05:29:04 +00:00
|
|
|
ssl_decrypted_data_avail, offset);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* try to retrieve and use decrypted handshake record, if any. */
|
2006-08-02 08:15:51 +00:00
|
|
|
decrypted = ssl_get_record_info(proto_ssl, pinfo, offset);
|
2006-08-28 07:05:02 +00:00
|
|
|
if (decrypted) {
|
2008-07-09 07:24:13 +00:00
|
|
|
/* add desegmented data to the data source list */
|
|
|
|
add_new_data_source(pinfo, decrypted, "Decrypted SSL record");
|
2006-05-03 05:29:04 +00:00
|
|
|
dissect_ssl3_handshake(decrypted, pinfo, ssl_record_tree, 0,
|
|
|
|
decrypted->length, conv_version, ssl, content_type);
|
2008-07-09 07:24:13 +00:00
|
|
|
} else {
|
2006-05-03 05:29:04 +00:00
|
|
|
dissect_ssl3_handshake(tvb, pinfo, ssl_record_tree, offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
record_length, conv_version, ssl, content_type);
|
2008-07-09 07:24:13 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
2006-05-03 05:29:04 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
case SSL_ID_APP_DATA:
|
2006-07-01 05:41:30 +00:00
|
|
|
if (ssl){
|
2008-07-09 07:24:13 +00:00
|
|
|
decrypt_ssl3_record(tvb, pinfo, offset,
|
|
|
|
record_length, content_type, ssl, TRUE);
|
|
|
|
/* if application data desegmentation is allowed and needed */
|
|
|
|
/* if (ssl_desegment_app_data && *need_desegmentation)
|
|
|
|
ssl_desegment_ssl_app_data(ssl,pinfo);
|
|
|
|
*/
|
2006-07-01 05:41:30 +00:00
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* show on info colum what we are decoding */
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Application Data");
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* we need dissector information when the selected packet is shown.
|
|
|
|
* ssl session pointer is NULL at that time, so we can't access
|
2006-08-07 19:52:18 +00:00
|
|
|
* info cached there*/
|
2006-08-25 08:07:26 +00:00
|
|
|
association = ssl_association_find(ssl_associations, pinfo->srcport, pinfo->ptype == PT_TCP);
|
|
|
|
association = association ? association: ssl_association_find(ssl_associations, pinfo->destport, pinfo->ptype == PT_TCP);
|
2006-02-04 23:44:05 +00:00
|
|
|
|
|
|
|
proto_item_set_text(ssl_record_tree,
|
2007-01-12 10:25:03 +00:00
|
|
|
"%s Record Layer: %s Protocol: %s",
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_version_short_names[*conv_version],
|
|
|
|
val_to_str(content_type, ssl_31_content_type, "unknown"),
|
|
|
|
association?association->info:"Application Data");
|
2006-07-01 05:41:30 +00:00
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
proto_tree_add_item(ssl_record_tree, hf_ssl_record_appdata, tvb,
|
2006-07-01 05:41:30 +00:00
|
|
|
offset, record_length, 0);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
dissect_ssl_payload(tvb, pinfo, offset, tree, association);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* shouldn't get here since we check above for valid types */
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Bad SSLv3 Content Type");
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
offset += record_length; /* skip to end of record */
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dissects the change cipher spec procotol, filling in the tree */
|
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl3_change_cipher_spec(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree, guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint* conv_version, guint8 content_type)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* struct {
|
|
|
|
* enum { change_cipher_spec(1), (255) } type;
|
|
|
|
* } ChangeCipherSpec;
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_item_set_text(tree,
|
2005-03-06 04:42:51 +00:00
|
|
|
"%s Record Layer: %s Protocol: Change Cipher Spec",
|
|
|
|
ssl_version_short_names[*conv_version],
|
2005-06-26 19:56:52 +00:00
|
|
|
val_to_str(content_type, ssl_31_content_type, "unknown"));
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl_change_cipher_spec, tvb,
|
|
|
|
offset++, 1, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dissects the alert message, filling in the tree */
|
|
|
|
static void
|
|
|
|
dissect_ssl3_alert(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint* conv_version)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* AlertLevel level;
|
|
|
|
* AlertDescription description;
|
|
|
|
* } Alert;
|
|
|
|
*/
|
|
|
|
proto_tree *ti;
|
2006-08-02 08:15:51 +00:00
|
|
|
proto_tree *ssl_alert_tree;
|
2005-06-26 19:56:52 +00:00
|
|
|
const gchar *level;
|
|
|
|
const gchar *desc;
|
2001-07-11 18:19:16 +00:00
|
|
|
guint8 byte;
|
2006-08-02 08:15:51 +00:00
|
|
|
ssl_alert_tree = NULL;
|
2001-07-11 18:19:16 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
ti = proto_tree_add_item(tree, hf_ssl_alert_message, tvb,
|
|
|
|
offset, 2, 0);
|
|
|
|
ssl_alert_tree = proto_item_add_subtree(ti, ett_ssl_alert);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set the record layer label
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* first lookup the names for the alert level and description */
|
|
|
|
byte = tvb_get_guint8(tvb, offset); /* grab the level byte */
|
|
|
|
level = match_strval(byte, ssl_31_alert_level);
|
|
|
|
|
|
|
|
byte = tvb_get_guint8(tvb, offset+1); /* grab the desc byte */
|
|
|
|
desc = match_strval(byte, ssl_31_alert_description);
|
|
|
|
|
|
|
|
/* now set the text in the record layer line */
|
|
|
|
if (level && desc)
|
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO,
|
2001-07-11 18:19:16 +00:00
|
|
|
"Alert (Level: %s, Description: %s)",
|
|
|
|
level, desc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Encrypted Alert");
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
if (level && desc)
|
|
|
|
{
|
|
|
|
proto_item_set_text(tree, "%s Record Layer: Alert "
|
|
|
|
"(Level: %s, Description: %s)",
|
|
|
|
ssl_version_short_names[*conv_version],
|
|
|
|
level, desc);
|
|
|
|
proto_tree_add_item(ssl_alert_tree, hf_ssl_alert_message_level,
|
|
|
|
tvb, offset++, 1, FALSE);
|
|
|
|
|
|
|
|
proto_tree_add_item(ssl_alert_tree, hf_ssl_alert_message_description,
|
|
|
|
tvb, offset++, 1, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proto_item_set_text(tree,
|
|
|
|
"%s Record Layer: Encrypted Alert",
|
|
|
|
ssl_version_short_names[*conv_version]);
|
|
|
|
proto_item_set_text(ssl_alert_tree,
|
|
|
|
"Alert Message: Encrypted Alert");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* dissects the handshake protocol, filling the tree */
|
|
|
|
static void
|
|
|
|
dissect_ssl3_handshake(tvbuff_t *tvb, packet_info *pinfo,
|
|
|
|
proto_tree *tree, guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint32 record_length, guint *conv_version,
|
|
|
|
SslDecryptSession* ssl, guint8 content_type)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* HandshakeType msg_type;
|
|
|
|
* uint24 length;
|
|
|
|
* select (HandshakeType) {
|
|
|
|
* case hello_request: HelloRequest;
|
|
|
|
* case client_hello: ClientHello;
|
|
|
|
* case server_hello: ServerHello;
|
|
|
|
* case certificate: Certificate;
|
|
|
|
* case server_key_exchange: ServerKeyExchange;
|
|
|
|
* case certificate_request: CertificateRequest;
|
|
|
|
* case server_hello_done: ServerHelloDone;
|
|
|
|
* case certificate_verify: CertificateVerify;
|
|
|
|
* case client_key_exchange: ClientKeyExchange;
|
|
|
|
* case finished: Finished;
|
|
|
|
* } body;
|
|
|
|
* } Handshake;
|
|
|
|
*/
|
2006-08-02 08:15:51 +00:00
|
|
|
proto_tree *ti;
|
|
|
|
proto_tree *ssl_hand_tree;
|
|
|
|
const gchar *msg_type_str;
|
2001-07-11 18:19:16 +00:00
|
|
|
guint8 msg_type;
|
|
|
|
guint32 length;
|
2006-08-02 08:15:51 +00:00
|
|
|
gboolean first_iteration;
|
|
|
|
ti = NULL;
|
|
|
|
ssl_hand_tree = NULL;
|
|
|
|
msg_type_str = NULL;
|
|
|
|
first_iteration = TRUE;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* just as there can be multiple records per packet, there
|
|
|
|
* can be multiple messages per record as long as they have
|
|
|
|
* the same content type
|
|
|
|
*
|
|
|
|
* we really only care about this for handshake messages
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* set record_length to the max offset */
|
|
|
|
record_length += offset;
|
|
|
|
while (offset < record_length)
|
|
|
|
{
|
|
|
|
msg_type = tvb_get_guint8(tvb, offset);
|
|
|
|
length = tvb_get_ntoh24(tvb, offset + 1);
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* Check the length in the handshake message. Assume it's an
|
|
|
|
* encrypted handshake message if the message would pass
|
|
|
|
* the record_length boundary. This is a workaround for the
|
|
|
|
* situation where the first octet of the encrypted handshake
|
|
|
|
* message is actually a known handshake message type.
|
|
|
|
*/
|
|
|
|
if (offset + length <= record_length)
|
|
|
|
msg_type_str = match_strval(msg_type, ssl_31_handshake_type);
|
|
|
|
else
|
|
|
|
msg_type_str = NULL;
|
2007-04-14 19:04:19 +00:00
|
|
|
|
2006-10-08 07:54:06 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_handshake iteration %d type %d offset %d length %d "
|
|
|
|
"bytes, remaining %d \n", first_iteration, msg_type, offset, length, record_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
if (!msg_type_str && !first_iteration)
|
|
|
|
{
|
|
|
|
/* only dissect / report messages if they're
|
|
|
|
* either the first message in this record
|
|
|
|
* or they're a valid message type
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* on second and later iterations, add comma to info col */
|
|
|
|
if (!first_iteration)
|
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2007-10-23 05:50:00 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, ", ");
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update our info string
|
|
|
|
*/
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
2007-10-23 05:50:00 +00:00
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, (msg_type_str != NULL)
|
2001-07-11 18:19:16 +00:00
|
|
|
? msg_type_str : "Encrypted Handshake Message");
|
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
/* set the label text on the record layer expanding node */
|
|
|
|
if (first_iteration)
|
|
|
|
{
|
2005-03-06 04:42:51 +00:00
|
|
|
proto_item_set_text(tree, "%s Record Layer: %s Protocol: %s",
|
2006-08-07 19:52:18 +00:00
|
|
|
ssl_version_short_names[*conv_version],
|
2005-06-26 19:56:52 +00:00
|
|
|
val_to_str(content_type, ssl_31_content_type, "unknown"),
|
|
|
|
(msg_type_str!=NULL) ? msg_type_str :
|
|
|
|
"Encrypted Handshake Message");
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-03-06 04:42:51 +00:00
|
|
|
proto_item_set_text(tree, "%s Record Layer: %s Protocol: %s",
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_version_short_names[*conv_version],
|
2005-06-26 19:56:52 +00:00
|
|
|
val_to_str(content_type, ssl_31_content_type, "unknown"),
|
2001-07-11 18:19:16 +00:00
|
|
|
"Multiple Handshake Messages");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add a subtree for the handshake protocol */
|
|
|
|
ti = proto_tree_add_item(tree, hf_ssl_handshake_protocol, tvb,
|
|
|
|
offset, length + 4, 0);
|
|
|
|
ssl_hand_tree = proto_item_add_subtree(ti, ett_ssl_handshake);
|
|
|
|
|
|
|
|
if (ssl_hand_tree)
|
|
|
|
{
|
|
|
|
/* set the text label on the subtree node */
|
|
|
|
proto_item_set_text(ssl_hand_tree, "Handshake Protocol: %s",
|
|
|
|
(msg_type_str != NULL) ? msg_type_str :
|
|
|
|
"Encrypted Handshake Message");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we don't have a valid handshake type, just quit dissecting */
|
|
|
|
if (!msg_type_str)
|
|
|
|
return;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* PAOLO: if we are doing ssl decryption we must dissect some requests type */
|
|
|
|
if (ssl_hand_tree || ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* add nodes for the message type and message length */
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl_hand_tree)
|
|
|
|
proto_tree_add_item(ssl_hand_tree, hf_ssl_handshake_type,
|
|
|
|
tvb, offset, 1, msg_type);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset++;
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl_hand_tree)
|
|
|
|
proto_tree_add_uint(ssl_hand_tree, hf_ssl_handshake_length,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, 3, length);
|
|
|
|
offset += 3;
|
|
|
|
|
|
|
|
/* now dissect the handshake message, if necessary */
|
|
|
|
switch (msg_type) {
|
|
|
|
case SSL_HND_HELLO_REQUEST:
|
|
|
|
/* hello_request has no fields, so nothing to do! */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_HND_CLIENT_HELLO:
|
2007-05-03 16:59:13 +00:00
|
|
|
dissect_ssl3_hnd_cli_hello(tvb, pinfo, ssl_hand_tree, offset, length, ssl);
|
2008-07-09 07:24:13 +00:00
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
case SSL_HND_SERVER_HELLO:
|
2006-02-04 23:44:05 +00:00
|
|
|
dissect_ssl3_hnd_srv_hello(tvb, ssl_hand_tree, offset, length, ssl);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_HND_CERTIFICATE:
|
2004-08-02 08:57:40 +00:00
|
|
|
dissect_ssl3_hnd_cert(tvb, ssl_hand_tree, offset, pinfo);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
2003-07-19 07:06:01 +00:00
|
|
|
case SSL_HND_SERVER_KEY_EXCHG:
|
|
|
|
/* unimplemented */
|
|
|
|
break;
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
case SSL_HND_CERT_REQUEST:
|
2008-01-13 14:10:02 +00:00
|
|
|
dissect_ssl3_hnd_cert_req(tvb, ssl_hand_tree, offset, pinfo);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_HND_SVR_HELLO_DONE:
|
|
|
|
/* server_hello_done has no fields, so nothing to do! */
|
|
|
|
break;
|
|
|
|
|
2003-07-19 07:06:01 +00:00
|
|
|
case SSL_HND_CERT_VERIFY:
|
|
|
|
/* unimplemented */
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
case SSL_HND_CLIENT_KEY_EXCHG:
|
2006-02-04 23:44:05 +00:00
|
|
|
{
|
|
|
|
/* PAOLO: here we can have all the data to build session key*/
|
|
|
|
StringInfo encrypted_pre_master;
|
2006-08-02 08:15:51 +00:00
|
|
|
gint ret;
|
|
|
|
guint encrlen, skip;
|
2008-07-09 07:24:13 +00:00
|
|
|
encrlen = length;
|
|
|
|
skip = 0;
|
2006-08-02 08:15:51 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (!ssl)
|
|
|
|
break;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-04-26 15:10:23 +00:00
|
|
|
/* get encrypted data, on tls1 we have to skip two bytes
|
2006-08-07 19:52:18 +00:00
|
|
|
* (it's the encrypted len and should be equal to record len - 2)
|
2006-02-10 13:20:11 +00:00
|
|
|
*/
|
2009-02-11 07:03:51 +00:00
|
|
|
if (ssl->version == SSL_VER_TLS||ssl->version == SSL_VER_TLSv1DOT1||ssl->version == SSL_VER_TLSv1DOT2)
|
2006-02-10 13:20:11 +00:00
|
|
|
{
|
|
|
|
encrlen = tvb_get_ntohs(tvb, offset);
|
|
|
|
skip = 2;
|
|
|
|
if (encrlen > length - 2)
|
|
|
|
{
|
|
|
|
ssl_debug_printf("dissect_ssl3_handshake wrong encrypted length (%d max %d)\n",
|
|
|
|
encrlen, length);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
encrypted_pre_master.data = se_alloc(encrlen);
|
|
|
|
encrypted_pre_master.data_len = encrlen;
|
|
|
|
tvb_memcpy(tvb, encrypted_pre_master.data, offset+skip, encrlen);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (!ssl->private_key) {
|
|
|
|
ssl_debug_printf("dissect_ssl3_handshake can't find private key\n");
|
|
|
|
break;
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
|
|
|
/* go with ssl key processessing; encrypted_pre_master
|
2006-02-04 23:44:05 +00:00
|
|
|
* will be used for master secret store*/
|
|
|
|
ret = ssl_decrypt_pre_master_secret(ssl, &encrypted_pre_master, ssl->private_key);
|
|
|
|
if (ret < 0) {
|
|
|
|
ssl_debug_printf("dissect_ssl3_handshake can't decrypt pre master secret\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ssl_generate_keyring_material(ssl)<0) {
|
|
|
|
ssl_debug_printf("dissect_ssl3_handshake can't generate keyring material\n");
|
|
|
|
break;
|
|
|
|
}
|
2008-07-09 07:24:13 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
ssl_save_session(ssl, ssl_session_hash);
|
2008-12-20 00:09:02 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_handshake session keys successfully generated\n");
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
2003-07-19 07:06:01 +00:00
|
|
|
|
|
|
|
case SSL_HND_FINISHED:
|
|
|
|
dissect_ssl3_hnd_finished(tvb, ssl_hand_tree,
|
|
|
|
offset, conv_version);
|
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
2006-02-04 23:44:05 +00:00
|
|
|
offset += 4; /* skip the handshake header when handshake is not processed*/
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += length;
|
|
|
|
first_iteration = FALSE; /* set up for next pass, if any */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
dissect_ssl3_hnd_hello_common(tvbuff_t *tvb, proto_tree *tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint32 offset, SslDecryptSession* ssl, gint from_server)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* show the client's random challenge */
|
2001-09-14 07:10:13 +00:00
|
|
|
nstime_t gmt_unix_time;
|
2006-08-02 08:15:51 +00:00
|
|
|
guint8 session_id_length;
|
2008-07-09 07:24:13 +00:00
|
|
|
proto_item *ti_rnd;
|
|
|
|
proto_tree *ssl_rnd_tree;
|
2006-08-30 07:31:36 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
session_id_length = 0;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
if (ssl)
|
2006-02-04 23:44:05 +00:00
|
|
|
{
|
|
|
|
/* PAOLO: get proper peer information*/
|
|
|
|
StringInfo* rnd;
|
2006-08-07 19:52:18 +00:00
|
|
|
if (from_server)
|
2006-02-04 23:44:05 +00:00
|
|
|
rnd = &ssl->server_random;
|
2006-08-07 19:52:18 +00:00
|
|
|
else
|
2006-02-04 23:44:05 +00:00
|
|
|
rnd = &ssl->client_random;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* get provided random for keyring generation*/
|
|
|
|
tvb_memcpy(tvb, rnd->data, offset, 32);
|
|
|
|
rnd->data_len = 32;
|
|
|
|
if (from_server)
|
|
|
|
ssl->state |= SSL_SERVER_RANDOM;
|
|
|
|
else
|
|
|
|
ssl->state |= SSL_CLIENT_RANDOM;
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_hnd_hello_common found %s RANDOM -> state 0x%02X\n",
|
|
|
|
(from_server)?"SERVER":"CLIENT", ssl->state);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
session_id_length = tvb_get_guint8(tvb, offset + 32);
|
|
|
|
/* check stored session id info */
|
|
|
|
if (from_server && (session_id_length == ssl->session_id.data_len) &&
|
|
|
|
(tvb_memeql(tvb, offset+33, ssl->session_id.data, session_id_length) == 0))
|
2006-08-07 19:52:18 +00:00
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
/* client/server id match: try to restore a previous cached session*/
|
2006-08-07 19:52:18 +00:00
|
|
|
ssl_restore_session(ssl, ssl_session_hash);
|
2008-07-09 07:24:13 +00:00
|
|
|
} else {
|
2006-02-04 23:44:05 +00:00
|
|
|
tvb_memcpy(tvb,ssl->session_id.data, offset+33, session_id_length);
|
|
|
|
ssl->session_id.data_len = session_id_length;
|
2006-08-07 19:52:18 +00:00
|
|
|
}
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
ti_rnd = proto_tree_add_text(tree, tvb, offset, 32, "Random");
|
|
|
|
ssl_rnd_tree = proto_item_add_subtree(ti_rnd, ett_ssl_random);
|
2006-08-30 07:31:36 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* show the time */
|
2001-09-14 07:10:13 +00:00
|
|
|
gmt_unix_time.secs = tvb_get_ntohl(tvb, offset);
|
|
|
|
gmt_unix_time.nsecs = 0;
|
2006-08-30 07:31:36 +00:00
|
|
|
proto_tree_add_time(ssl_rnd_tree, hf_ssl_handshake_random_time,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, 4, &gmt_unix_time);
|
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
/* show the random bytes */
|
2006-08-30 07:31:36 +00:00
|
|
|
proto_tree_add_item(ssl_rnd_tree, hf_ssl_handshake_random_bytes,
|
|
|
|
tvb, offset, 28, FALSE);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 28;
|
|
|
|
|
|
|
|
/* show the session id */
|
|
|
|
session_id_length = tvb_get_guint8(tvb, offset);
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_session_id_len,
|
|
|
|
tvb, offset++, 1, 0);
|
|
|
|
if (session_id_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, session_id_length);
|
2006-12-25 04:01:22 +00:00
|
|
|
proto_tree_add_bytes(tree, hf_ssl_handshake_session_id,
|
2001-07-16 01:38:34 +00:00
|
|
|
tvb, offset, session_id_length,
|
2006-12-25 04:01:22 +00:00
|
|
|
tvb_get_ptr(tvb, offset, session_id_length));
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += session_id_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-06 01:01:09 +00:00
|
|
|
/* XXXX */
|
2006-02-04 23:44:05 +00:00
|
|
|
return session_id_length+33;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2004-12-26 00:28:47 +00:00
|
|
|
dissect_ssl3_hnd_hello_ext(tvbuff_t *tvb,
|
2004-12-26 22:52:16 +00:00
|
|
|
proto_tree *tree, guint32 offset, guint32 left)
|
2004-12-26 00:28:47 +00:00
|
|
|
{
|
|
|
|
guint16 extension_length;
|
|
|
|
guint16 ext_type;
|
|
|
|
guint16 ext_len;
|
|
|
|
proto_item *pi;
|
|
|
|
proto_tree *ext_tree;
|
|
|
|
|
2004-12-26 22:52:16 +00:00
|
|
|
if (left < 2)
|
2008-07-09 07:24:13 +00:00
|
|
|
return offset;
|
2004-12-26 00:28:47 +00:00
|
|
|
|
|
|
|
extension_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_extensions_len,
|
2008-07-09 07:24:13 +00:00
|
|
|
tvb, offset, 2, extension_length);
|
2004-12-26 00:28:47 +00:00
|
|
|
offset += 2;
|
2004-12-26 22:52:16 +00:00
|
|
|
left -= 2;
|
2004-12-26 00:28:47 +00:00
|
|
|
|
2004-12-26 22:52:16 +00:00
|
|
|
while (left >= 4)
|
2004-12-26 00:28:47 +00:00
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
ext_type = tvb_get_ntohs(tvb, offset);
|
|
|
|
ext_len = tvb_get_ntohs(tvb, offset + 2);
|
|
|
|
|
|
|
|
pi = proto_tree_add_text(tree, tvb, offset, 4 + ext_len,
|
|
|
|
"Extension: %s",
|
|
|
|
val_to_str(ext_type,
|
|
|
|
tls_hello_extension_types,
|
|
|
|
"Unknown %u"));
|
|
|
|
ext_tree = proto_item_add_subtree(pi, ett_ssl_extension);
|
|
|
|
if (!ext_tree)
|
|
|
|
ext_tree = tree;
|
|
|
|
|
|
|
|
proto_tree_add_uint(ext_tree, hf_ssl_handshake_extension_type,
|
|
|
|
tvb, offset, 2, ext_type);
|
|
|
|
offset += 2;
|
2004-12-26 00:28:47 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
proto_tree_add_uint(ext_tree, hf_ssl_handshake_extension_len,
|
|
|
|
tvb, offset, 2, ext_len);
|
|
|
|
offset += 2;
|
2004-12-26 00:28:47 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
proto_tree_add_bytes_format(ext_tree, hf_ssl_handshake_extension_data,
|
|
|
|
tvb, offset, ext_len,
|
2008-12-19 17:39:52 +00:00
|
|
|
tvb_get_ptr(tvb, offset, ext_len),
|
2008-07-09 07:24:13 +00:00
|
|
|
"Data (%u byte%s)",
|
|
|
|
ext_len, plurality(ext_len, "", "s"));
|
|
|
|
offset += ext_len;
|
|
|
|
left -= 2 + 2 + ext_len;
|
2004-12-26 00:28:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
static void
|
2007-05-03 16:59:13 +00:00
|
|
|
dissect_ssl3_hnd_cli_hello(tvbuff_t *tvb, packet_info *pinfo,
|
2006-02-04 23:44:05 +00:00
|
|
|
proto_tree *tree, guint32 offset, guint32 length,
|
|
|
|
SslDecryptSession*ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* ProtocolVersion client_version;
|
|
|
|
* Random random;
|
|
|
|
* SessionID session_id;
|
|
|
|
* CipherSuite cipher_suites<2..2^16-1>;
|
|
|
|
* CompressionMethod compression_methods<1..2^8-1>;
|
2004-12-26 00:28:47 +00:00
|
|
|
* Extension client_hello_extension_list<0..2^16-1>;
|
2001-07-11 18:19:16 +00:00
|
|
|
* } ClientHello;
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
proto_tree *ti;
|
|
|
|
proto_tree *cs_tree;
|
2007-05-03 16:59:13 +00:00
|
|
|
gint cipher_suite_length;
|
2006-08-02 08:15:51 +00:00
|
|
|
guint8 compression_methods_length;
|
2003-01-27 19:50:05 +00:00
|
|
|
guint8 compression_method;
|
2006-08-02 08:15:51 +00:00
|
|
|
guint16 start_offset;
|
2007-05-03 16:59:13 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
cipher_suite_length = 0;
|
|
|
|
compression_methods_length = 0;
|
|
|
|
start_offset = offset;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree || ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* show the client version */
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_client_version, tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* show the fields in common with server hello */
|
2006-02-04 23:44:05 +00:00
|
|
|
offset += dissect_ssl3_hnd_hello_common(tvb, tree, offset, ssl, 0);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* tell the user how many cipher suites there are */
|
|
|
|
cipher_suite_length = tvb_get_ntohs(tvb, offset);
|
2006-02-04 23:44:05 +00:00
|
|
|
if (!tree)
|
|
|
|
return;
|
2001-07-16 01:38:34 +00:00
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_cipher_suites_len,
|
2006-02-04 23:44:05 +00:00
|
|
|
tvb, offset, 2, cipher_suite_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 2; /* skip opaque length */
|
|
|
|
|
|
|
|
if (cipher_suite_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, cipher_suite_length);
|
2001-07-16 04:02:22 +00:00
|
|
|
ti = proto_tree_add_none_format(tree,
|
|
|
|
hf_ssl_handshake_cipher_suites,
|
|
|
|
tvb, offset, cipher_suite_length,
|
2007-05-03 16:59:13 +00:00
|
|
|
"Cipher Suites (%d suite%s)",
|
2001-07-16 04:02:22 +00:00
|
|
|
cipher_suite_length / 2,
|
|
|
|
plurality(cipher_suite_length/2, "", "s"));
|
2007-05-03 16:59:13 +00:00
|
|
|
if (cipher_suite_length % 2) {
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2,
|
|
|
|
"Invalid cipher suite length: %d", cipher_suite_length);
|
|
|
|
expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR,
|
|
|
|
"Cipher suite length (%d) must be a multiple of 2",
|
|
|
|
cipher_suite_length);
|
|
|
|
return;
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* make this a subtree */
|
|
|
|
cs_tree = proto_item_add_subtree(ti, ett_ssl_cipher_suites);
|
|
|
|
if (!cs_tree)
|
|
|
|
{
|
|
|
|
cs_tree = tree; /* failsafe */
|
|
|
|
}
|
|
|
|
|
|
|
|
while (cipher_suite_length > 0)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(cs_tree, hf_ssl_handshake_cipher_suite,
|
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
cipher_suite_length -= 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* tell the user how many compression methods there are */
|
2001-07-16 01:38:34 +00:00
|
|
|
compression_methods_length = tvb_get_guint8(tvb, offset);
|
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_comp_methods_len,
|
|
|
|
tvb, offset, 1, compression_methods_length);
|
|
|
|
offset++;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
if (compression_methods_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, compression_methods_length);
|
2001-07-16 04:02:22 +00:00
|
|
|
ti = proto_tree_add_none_format(tree,
|
|
|
|
hf_ssl_handshake_comp_methods,
|
|
|
|
tvb, offset, compression_methods_length,
|
|
|
|
"Compression Methods (%u method%s)",
|
|
|
|
compression_methods_length,
|
|
|
|
plurality(compression_methods_length,
|
|
|
|
"", "s"));
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* make this a subtree */
|
|
|
|
cs_tree = proto_item_add_subtree(ti, ett_ssl_comp_methods);
|
|
|
|
if (!cs_tree)
|
|
|
|
{
|
|
|
|
cs_tree = tree; /* failsafe */
|
|
|
|
}
|
|
|
|
|
|
|
|
while (compression_methods_length > 0)
|
|
|
|
{
|
2003-01-27 19:50:05 +00:00
|
|
|
compression_method = tvb_get_guint8(tvb, offset);
|
|
|
|
if (compression_method < 64)
|
|
|
|
proto_tree_add_uint(cs_tree, hf_ssl_handshake_comp_method,
|
|
|
|
tvb, offset, 1, compression_method);
|
|
|
|
else if (compression_method > 63 && compression_method < 193)
|
|
|
|
proto_tree_add_text(cs_tree, tvb, offset, 1,
|
|
|
|
"Compression Method: Reserved - to be assigned by IANA (%u)",
|
|
|
|
compression_method);
|
|
|
|
else
|
|
|
|
proto_tree_add_text(cs_tree, tvb, offset, 1,
|
|
|
|
"Compression Method: Private use range (%u)",
|
|
|
|
compression_method);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset++;
|
|
|
|
compression_methods_length--;
|
|
|
|
}
|
|
|
|
}
|
2004-12-26 00:28:47 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
if (length > offset - start_offset)
|
|
|
|
{
|
|
|
|
offset = dissect_ssl3_hnd_hello_ext(tvb, tree, offset,
|
|
|
|
length -
|
|
|
|
(offset - start_offset));
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl3_hnd_srv_hello(tvbuff_t *tvb,
|
2006-02-04 23:44:05 +00:00
|
|
|
proto_tree *tree, guint32 offset, guint32 length, SslDecryptSession* ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* ProtocolVersion server_version;
|
|
|
|
* Random random;
|
|
|
|
* SessionID session_id;
|
|
|
|
* CipherSuite cipher_suite;
|
|
|
|
* CompressionMethod compression_method;
|
2004-12-26 00:28:47 +00:00
|
|
|
* Extension server_hello_extension_list<0..2^16-1>;
|
2001-07-11 18:19:16 +00:00
|
|
|
* } ServerHello;
|
|
|
|
*/
|
2006-08-02 08:15:51 +00:00
|
|
|
guint16 start_offset;
|
|
|
|
start_offset = offset;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree || ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* show the server version */
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_server_version, tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* first display the elements conveniently in
|
|
|
|
* common with client hello
|
|
|
|
*/
|
2006-02-04 23:44:05 +00:00
|
|
|
offset += dissect_ssl3_hnd_hello_common(tvb, tree, offset, ssl, 1);
|
|
|
|
|
|
|
|
/* PAOLO: handle session cipher suite */
|
|
|
|
if (ssl) {
|
|
|
|
/* store selected cipher suite for decryption */
|
|
|
|
ssl->cipher = tvb_get_ntohs(tvb, offset);
|
|
|
|
if (ssl_find_cipher(ssl->cipher,&ssl->cipher_suite) < 0) {
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_hnd_srv_hello can't find cipher suite 0x%X\n", ssl->cipher);
|
2006-02-04 23:44:05 +00:00
|
|
|
goto no_cipher;
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl->state |= SSL_CIPHER;
|
2006-12-28 12:30:53 +00:00
|
|
|
ssl_debug_printf("dissect_ssl3_hnd_srv_hello found CIPHER 0x%04X -> state 0x%02X\n",
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl->cipher, ssl->state);
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* if we have restored a session now we can have enough material
|
2006-02-04 23:44:05 +00:00
|
|
|
* to build session key, check it out*/
|
|
|
|
ssl_debug_printf("dissect_ssl3_hnd_srv_hello trying to generate keys\n");
|
|
|
|
if (ssl_generate_keyring_material(ssl)<0) {
|
|
|
|
ssl_debug_printf("dissect_ssl3_hnd_srv_hello can't generate keyring material\n");
|
|
|
|
goto no_cipher;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
no_cipher:
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* now the server-selected cipher suite */
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_cipher_suite,
|
2006-02-04 23:44:05 +00:00
|
|
|
tvb, offset, 2, FALSE);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 2;
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
if (ssl) {
|
|
|
|
/* store selected compression method for decryption */
|
|
|
|
ssl->compression = tvb_get_guint8(tvb, offset);
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
/* and the server-selected compression method */
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_comp_method,
|
|
|
|
tvb, offset, 1, FALSE);
|
2008-07-09 07:24:13 +00:00
|
|
|
offset++;
|
2004-12-26 00:28:47 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
if (length > offset - start_offset)
|
|
|
|
{
|
|
|
|
offset = dissect_ssl3_hnd_hello_ext(tvb, tree, offset,
|
|
|
|
length -
|
|
|
|
(offset - start_offset));
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl3_hnd_cert(tvbuff_t *tvb,
|
2004-08-02 08:57:40 +00:00
|
|
|
proto_tree *tree, guint32 offset, packet_info *pinfo)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
/* opaque ASN.1Cert<2^24-1>;
|
|
|
|
*
|
|
|
|
* struct {
|
|
|
|
* ASN.1Cert certificate_list<1..2^24-1>;
|
|
|
|
* } Certificate;
|
|
|
|
*/
|
|
|
|
guint32 certificate_list_length;
|
|
|
|
proto_tree *ti;
|
|
|
|
proto_tree *subtree;
|
2008-07-09 07:24:13 +00:00
|
|
|
asn1_ctx_t asn1_ctx;
|
|
|
|
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
certificate_list_length = tvb_get_ntoh24(tvb, offset);
|
2001-07-16 01:38:34 +00:00
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_certificates_len,
|
|
|
|
tvb, offset, 3, certificate_list_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 3; /* 24-bit length value */
|
|
|
|
|
|
|
|
if (certificate_list_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, certificate_list_length);
|
2001-07-16 04:02:22 +00:00
|
|
|
ti = proto_tree_add_none_format(tree,
|
|
|
|
hf_ssl_handshake_certificates,
|
|
|
|
tvb, offset, certificate_list_length,
|
|
|
|
"Certificates (%u byte%s)",
|
|
|
|
certificate_list_length,
|
|
|
|
plurality(certificate_list_length,
|
|
|
|
"", "s"));
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* make it a subtree */
|
|
|
|
subtree = proto_item_add_subtree(ti, ett_ssl_certs);
|
|
|
|
if (!subtree)
|
|
|
|
{
|
|
|
|
subtree = tree; /* failsafe */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate through each certificate */
|
|
|
|
while (certificate_list_length > 0)
|
|
|
|
{
|
|
|
|
/* get the length of the current certificate */
|
2006-08-02 08:15:51 +00:00
|
|
|
guint32 cert_length;
|
2008-07-09 07:24:13 +00:00
|
|
|
cert_length = tvb_get_ntoh24(tvb, offset);
|
2001-07-11 18:19:16 +00:00
|
|
|
certificate_list_length -= 3 + cert_length;
|
|
|
|
|
|
|
|
proto_tree_add_item(subtree, hf_ssl_handshake_certificate_len,
|
|
|
|
tvb, offset, 3, FALSE);
|
|
|
|
offset += 3;
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
(void)dissect_x509af_Certificate(FALSE, tvb, offset, &asn1_ctx, subtree, hf_ssl_handshake_certificate);
|
|
|
|
offset += cert_length;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl3_hnd_cert_req(tvbuff_t *tvb,
|
2008-01-13 14:10:02 +00:00
|
|
|
proto_tree *tree, guint32 offset, packet_info *pinfo)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* enum {
|
|
|
|
* rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),
|
|
|
|
* (255)
|
|
|
|
* } ClientCertificateType;
|
|
|
|
*
|
|
|
|
* opaque DistinguishedName<1..2^16-1>;
|
|
|
|
*
|
|
|
|
* struct {
|
|
|
|
* ClientCertificateType certificate_types<1..2^8-1>;
|
|
|
|
* DistinguishedName certificate_authorities<3..2^16-1>;
|
|
|
|
* } CertificateRequest;
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
proto_tree *ti;
|
|
|
|
proto_tree *subtree;
|
2006-08-02 08:15:51 +00:00
|
|
|
guint8 cert_types_count;
|
2008-01-13 14:10:02 +00:00
|
|
|
gint dnames_length;
|
|
|
|
asn1_ctx_t asn1_ctx;
|
2006-08-02 08:15:51 +00:00
|
|
|
cert_types_count = 0;
|
|
|
|
dnames_length = 0;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2008-01-13 14:10:02 +00:00
|
|
|
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
cert_types_count = tvb_get_guint8(tvb, offset);
|
2001-07-16 01:38:34 +00:00
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_cert_types_count,
|
|
|
|
tvb, offset, 1, cert_types_count);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset++;
|
|
|
|
|
|
|
|
if (cert_types_count > 0)
|
|
|
|
{
|
2001-07-16 04:02:22 +00:00
|
|
|
ti = proto_tree_add_none_format(tree,
|
|
|
|
hf_ssl_handshake_cert_types,
|
|
|
|
tvb, offset, cert_types_count,
|
|
|
|
"Certificate types (%u type%s)",
|
|
|
|
cert_types_count,
|
|
|
|
plurality(cert_types_count, "", "s"));
|
2001-07-11 18:19:16 +00:00
|
|
|
subtree = proto_item_add_subtree(ti, ett_ssl_cert_types);
|
|
|
|
if (!subtree)
|
|
|
|
{
|
|
|
|
subtree = tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (cert_types_count > 0)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(subtree, hf_ssl_handshake_cert_type,
|
|
|
|
tvb, offset, 1, FALSE);
|
|
|
|
offset++;
|
|
|
|
cert_types_count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dnames_length = tvb_get_ntohs(tvb, offset);
|
2001-07-16 01:38:34 +00:00
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_dnames_len,
|
|
|
|
tvb, offset, 2, dnames_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if (dnames_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, dnames_length);
|
2001-07-16 04:02:22 +00:00
|
|
|
ti = proto_tree_add_none_format(tree,
|
|
|
|
hf_ssl_handshake_dnames,
|
|
|
|
tvb, offset, dnames_length,
|
|
|
|
"Distinguished Names (%d byte%s)",
|
|
|
|
dnames_length,
|
|
|
|
plurality(dnames_length, "", "s"));
|
2001-07-11 18:19:16 +00:00
|
|
|
subtree = proto_item_add_subtree(ti, ett_ssl_dnames);
|
|
|
|
if (!subtree)
|
|
|
|
{
|
|
|
|
subtree = tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (dnames_length > 0)
|
|
|
|
{
|
|
|
|
/* get the length of the current certificate */
|
2006-08-02 08:15:51 +00:00
|
|
|
guint16 name_length;
|
2008-07-09 07:24:13 +00:00
|
|
|
name_length = tvb_get_ntohs(tvb, offset);
|
2001-07-11 18:19:16 +00:00
|
|
|
dnames_length -= 2 + name_length;
|
|
|
|
|
|
|
|
proto_tree_add_item(subtree, hf_ssl_handshake_dname_len,
|
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, name_length);
|
2008-01-13 14:10:02 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
(void)dissect_x509if_DistinguishedName(FALSE, tvb, offset, &asn1_ctx, subtree, hf_ssl_handshake_dname);
|
2008-01-13 14:10:02 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += name_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl3_hnd_finished(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree, guint32 offset,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint* conv_version)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* For TLS:
|
|
|
|
* struct {
|
|
|
|
* opaque verify_data[12];
|
|
|
|
* } Finished;
|
|
|
|
*
|
|
|
|
* For SSLv3:
|
|
|
|
* struct {
|
|
|
|
* opaque md5_hash[16];
|
|
|
|
* opaque sha_hash[20];
|
|
|
|
* } Finished;
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* this all needs a tree, so bail if we don't have one */
|
|
|
|
if (!tree)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(*conv_version) {
|
|
|
|
case SSL_VER_TLS:
|
2006-06-27 13:36:10 +00:00
|
|
|
case SSL_VER_TLSv1DOT1:
|
2009-02-11 07:03:51 +00:00
|
|
|
case SSL_VER_TLSv1DOT2:
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_finished,
|
|
|
|
tvb, offset, 12, FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_VER_SSLv3:
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_md5_hash,
|
|
|
|
tvb, offset, 16, FALSE);
|
|
|
|
offset += 16;
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_sha_hash,
|
|
|
|
tvb, offset, 20, FALSE);
|
|
|
|
offset += 20;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* SSL version 2 Dissectors
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/* record layer dissector */
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2002-03-28 09:15:28 +00:00
|
|
|
dissect_ssl2_record(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
|
2006-02-04 23:44:05 +00:00
|
|
|
guint32 offset, guint* conv_version,
|
|
|
|
gboolean *need_desegmentation,
|
|
|
|
SslDecryptSession* ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2006-08-02 08:15:51 +00:00
|
|
|
guint32 initial_offset;
|
|
|
|
guint8 byte;
|
|
|
|
guint8 record_length_length;
|
|
|
|
guint32 record_length;
|
|
|
|
gint is_escape;
|
|
|
|
gint16 padding_length;
|
|
|
|
guint8 msg_type;
|
|
|
|
const gchar *msg_type_str;
|
|
|
|
guint32 available_bytes;
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *ti;
|
2006-08-02 08:15:51 +00:00
|
|
|
proto_tree *ssl_record_tree;
|
|
|
|
|
|
|
|
initial_offset = offset;
|
|
|
|
byte = 0;
|
|
|
|
record_length_length = 0;
|
|
|
|
record_length = 0;
|
|
|
|
is_escape = -1;
|
|
|
|
padding_length = -1;
|
|
|
|
msg_type = 0;
|
|
|
|
msg_type_str = NULL;
|
|
|
|
available_bytes = 0;
|
|
|
|
ssl_record_tree = NULL;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2007-04-10 18:40:05 +00:00
|
|
|
/* pull first byte; if high bit is unset, then record
|
2001-07-11 18:19:16 +00:00
|
|
|
* length is three bytes due to padding; otherwise
|
|
|
|
* record length is two bytes
|
|
|
|
*/
|
2002-04-11 09:43:22 +00:00
|
|
|
byte = tvb_get_guint8(tvb, offset);
|
2001-07-11 18:19:16 +00:00
|
|
|
record_length_length = (byte & 0x80) ? 2 : 3;
|
|
|
|
|
2002-03-28 09:15:28 +00:00
|
|
|
/*
|
|
|
|
* Can we do reassembly?
|
|
|
|
*/
|
|
|
|
available_bytes = tvb_length_remaining(tvb, offset);
|
|
|
|
|
|
|
|
if (ssl_desegment && pinfo->can_desegment) {
|
|
|
|
/*
|
|
|
|
* Yes - is the record header split across segment boundaries?
|
|
|
|
*/
|
|
|
|
if (available_bytes < record_length_length) {
|
|
|
|
/*
|
|
|
|
* Yes. Tell the TCP dissector where the data for this
|
|
|
|
* message starts in the data it handed us, and how many
|
|
|
|
* more bytes we need, and return.
|
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = offset;
|
|
|
|
pinfo->desegment_len = record_length_length - available_bytes;
|
|
|
|
*need_desegmentation = TRUE;
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* parse out the record length */
|
|
|
|
switch(record_length_length) {
|
|
|
|
case 2: /* two-byte record length */
|
|
|
|
record_length = (byte & 0x7f) << 8;
|
2002-04-11 09:43:22 +00:00
|
|
|
byte = tvb_get_guint8(tvb, offset + 1);
|
2001-07-11 18:19:16 +00:00
|
|
|
record_length += byte;
|
|
|
|
break;
|
|
|
|
case 3: /* three-byte record length */
|
|
|
|
is_escape = (byte & 0x40) ? TRUE : FALSE;
|
|
|
|
record_length = (byte & 0x3f) << 8;
|
2002-04-11 09:43:22 +00:00
|
|
|
byte = tvb_get_guint8(tvb, offset + 1);
|
2001-07-11 18:19:16 +00:00
|
|
|
record_length += byte;
|
2002-04-11 09:43:22 +00:00
|
|
|
byte = tvb_get_guint8(tvb, offset + 2);
|
2001-07-11 18:19:16 +00:00
|
|
|
padding_length = byte;
|
|
|
|
}
|
|
|
|
|
2002-01-04 07:01:54 +00:00
|
|
|
/*
|
2002-03-28 09:15:28 +00:00
|
|
|
* Can we do reassembly?
|
2002-01-04 07:01:54 +00:00
|
|
|
*/
|
2002-03-28 09:15:28 +00:00
|
|
|
if (ssl_desegment && pinfo->can_desegment) {
|
|
|
|
/*
|
|
|
|
* Yes - is the record split across segment boundaries?
|
|
|
|
*/
|
2002-04-11 09:43:22 +00:00
|
|
|
if (available_bytes < (record_length_length + record_length)) {
|
2002-03-28 09:15:28 +00:00
|
|
|
/*
|
|
|
|
* Yes. Tell the TCP dissector where the data for this
|
|
|
|
* message starts in the data it handed us, and how many
|
|
|
|
* more bytes we need, and return.
|
|
|
|
*/
|
|
|
|
pinfo->desegment_offset = offset;
|
2002-04-11 09:43:22 +00:00
|
|
|
pinfo->desegment_len = (record_length_length + record_length)
|
2008-07-09 07:24:13 +00:00
|
|
|
- available_bytes;
|
2002-03-28 09:15:28 +00:00
|
|
|
*need_desegmentation = TRUE;
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
}
|
2002-04-11 09:43:22 +00:00
|
|
|
offset += record_length_length;
|
2002-01-04 07:01:54 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* add the record layer subtree header */
|
|
|
|
ti = proto_tree_add_item(tree, hf_ssl2_record, tvb, initial_offset,
|
|
|
|
record_length_length + record_length, 0);
|
|
|
|
ssl_record_tree = proto_item_add_subtree(ti, ett_ssl_record);
|
|
|
|
|
|
|
|
/* pull the msg_type so we can bail if it's unknown */
|
|
|
|
msg_type = tvb_get_guint8(tvb, initial_offset + record_length_length);
|
|
|
|
|
|
|
|
/* if we get a server_hello or later handshake in v2, then set
|
|
|
|
* this to sslv2
|
|
|
|
*/
|
2002-04-11 09:43:22 +00:00
|
|
|
if (*conv_version == SSL_VER_UNKNOWN)
|
|
|
|
{
|
|
|
|
if (ssl_looks_like_valid_pct_handshake(tvb,
|
|
|
|
(initial_offset +
|
|
|
|
record_length_length),
|
|
|
|
record_length)) {
|
2006-08-07 19:52:18 +00:00
|
|
|
*conv_version = SSL_VER_PCT;
|
2006-02-04 23:44:05 +00:00
|
|
|
/*ssl_set_conv_version(pinfo, ssl->version);*/
|
2002-04-11 09:43:22 +00:00
|
|
|
}
|
|
|
|
else if (msg_type >= 2 && msg_type <= 8)
|
|
|
|
{
|
|
|
|
*conv_version = SSL_VER_SSLv2;
|
2006-02-04 23:44:05 +00:00
|
|
|
/*ssl_set_conv_version(pinfo, ssl->version);*/
|
2002-04-11 09:43:22 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
/* if we get here, but don't have a version set for the
|
|
|
|
* conversation, then set a version for just this frame
|
|
|
|
* (e.g., on a client hello)
|
|
|
|
*/
|
|
|
|
if (check_col(pinfo->cinfo, COL_PROTOCOL))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2002-04-11 09:43:22 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL,
|
|
|
|
(*conv_version == SSL_VER_PCT) ? "PCT" : "SSLv2");
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* see if the msg_type is valid; if not the payload is
|
|
|
|
* probably encrypted, so note that fact and bail
|
|
|
|
*/
|
2002-04-11 09:43:22 +00:00
|
|
|
msg_type_str = match_strval(msg_type,
|
|
|
|
(*conv_version == SSL_VER_PCT)
|
2008-07-09 07:24:13 +00:00
|
|
|
? pct_msg_types : ssl_20_msg_types);
|
2001-07-11 18:19:16 +00:00
|
|
|
if (!msg_type_str
|
2002-04-11 09:43:22 +00:00
|
|
|
|| ((*conv_version != SSL_VER_PCT) &&
|
2008-07-09 07:24:13 +00:00
|
|
|
!ssl_looks_like_valid_v2_handshake(tvb, initial_offset
|
|
|
|
+ record_length_length,
|
|
|
|
record_length))
|
|
|
|
|| ((*conv_version == SSL_VER_PCT) &&
|
|
|
|
!ssl_looks_like_valid_pct_handshake(tvb, initial_offset
|
|
|
|
+ record_length_length,
|
|
|
|
record_length)))
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
if (ssl_record_tree)
|
|
|
|
{
|
2002-04-11 09:43:22 +00:00
|
|
|
proto_item_set_text(ssl_record_tree, "%s Record Layer: %s",
|
|
|
|
(*conv_version == SSL_VER_PCT)
|
|
|
|
? "PCT" : "SSLv2",
|
2001-07-11 18:19:16 +00:00
|
|
|
"Encrypted Data");
|
2007-04-10 18:40:05 +00:00
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* Unlike SSLv3, the SSLv2 record layer does not have a
|
|
|
|
* version field. To make it possible to filter on record
|
|
|
|
* layer version we create a generated field with ssl
|
|
|
|
* record layer version 0x0002
|
|
|
|
*/
|
|
|
|
ti = proto_tree_add_uint(ssl_record_tree,
|
|
|
|
hf_ssl_record_version, tvb,
|
|
|
|
initial_offset, 0, 0x0002);
|
|
|
|
PROTO_ITEM_SET_GENERATED(ti);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2007-04-10 18:40:05 +00:00
|
|
|
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, "Encrypted Data");
|
2001-07-11 18:19:16 +00:00
|
|
|
return initial_offset + record_length_length + record_length;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-12-10 00:26:21 +00:00
|
|
|
if (check_col(pinfo->cinfo, COL_INFO))
|
|
|
|
col_append_str(pinfo->cinfo, COL_INFO, msg_type_str);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
if (ssl_record_tree)
|
|
|
|
{
|
2002-04-11 09:43:22 +00:00
|
|
|
proto_item_set_text(ssl_record_tree, "%s Record Layer: %s",
|
|
|
|
(*conv_version == SSL_VER_PCT)
|
|
|
|
? "PCT" : "SSLv2",
|
2001-07-11 18:19:16 +00:00
|
|
|
msg_type_str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a valid message type, so move foward, filling in the
|
|
|
|
* tree by adding the length, is_escape boolean and padding_length,
|
|
|
|
* if present in the original packet
|
|
|
|
*/
|
2002-01-04 07:01:54 +00:00
|
|
|
if (ssl_record_tree)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
/* Unlike SSLv3, the SSLv2 record layer does not have a
|
|
|
|
* version field. To make it possible to filter on record
|
|
|
|
* layer version we create a generated field with ssl
|
|
|
|
* record layer version 0x0002
|
|
|
|
*/
|
|
|
|
ti = proto_tree_add_uint(ssl_record_tree,
|
|
|
|
hf_ssl_record_version, tvb,
|
|
|
|
initial_offset, 0, 0x0002);
|
|
|
|
PROTO_ITEM_SET_GENERATED(ti);
|
2007-04-10 18:40:05 +00:00
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/* add the record length */
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, record_length_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
ti = proto_tree_add_uint (ssl_record_tree,
|
|
|
|
hf_ssl_record_length, tvb,
|
|
|
|
initial_offset, record_length_length,
|
|
|
|
record_length);
|
|
|
|
}
|
|
|
|
if (ssl_record_tree && is_escape != -1)
|
|
|
|
{
|
|
|
|
proto_tree_add_boolean(ssl_record_tree,
|
|
|
|
hf_ssl2_record_is_escape, tvb,
|
|
|
|
initial_offset, 1, is_escape);
|
2008-07-09 07:24:13 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
if (ssl_record_tree && padding_length != -1)
|
|
|
|
{
|
|
|
|
proto_tree_add_uint(ssl_record_tree,
|
|
|
|
hf_ssl2_record_padding_length, tvb,
|
|
|
|
initial_offset + 2, 1, padding_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dissect the record data
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* jump forward to the start of the record data */
|
|
|
|
offset = initial_offset + record_length_length;
|
|
|
|
|
|
|
|
/* add the message type */
|
|
|
|
if (ssl_record_tree)
|
|
|
|
{
|
2002-04-11 09:43:22 +00:00
|
|
|
proto_tree_add_item(ssl_record_tree,
|
|
|
|
(*conv_version == SSL_VER_PCT)
|
|
|
|
? hf_pct_msg_type : hf_ssl2_msg_type,
|
|
|
|
tvb, offset, 1, 0);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
offset++; /* move past msg_type byte */
|
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
if (*conv_version != SSL_VER_PCT)
|
|
|
|
{
|
|
|
|
/* dissect the message (only handle client hello right now) */
|
|
|
|
switch (msg_type) {
|
|
|
|
case SSL2_HND_CLIENT_HELLO:
|
2007-09-16 19:28:58 +00:00
|
|
|
dissect_ssl2_hnd_client_hello(tvb, pinfo, ssl_record_tree, offset, ssl);
|
2002-04-11 09:43:22 +00:00
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
case SSL2_HND_CLIENT_MASTER_KEY:
|
|
|
|
dissect_ssl2_hnd_client_master_key(tvb, ssl_record_tree, offset);
|
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
case SSL2_HND_SERVER_HELLO:
|
2004-08-02 08:57:40 +00:00
|
|
|
dissect_ssl2_hnd_server_hello(tvb, ssl_record_tree, offset, pinfo);
|
2002-04-11 09:43:22 +00:00
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
case SSL2_HND_ERROR:
|
|
|
|
case SSL2_HND_CLIENT_FINISHED:
|
|
|
|
case SSL2_HND_SERVER_VERIFY:
|
|
|
|
case SSL2_HND_SERVER_FINISHED:
|
|
|
|
case SSL2_HND_REQUEST_CERTIFICATE:
|
|
|
|
case SSL2_HND_CLIENT_CERTIFICATE:
|
|
|
|
/* unimplemented */
|
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
default: /* unknown */
|
|
|
|
break;
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2002-04-11 09:43:22 +00:00
|
|
|
else
|
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
/* dissect the message */
|
2002-04-11 09:43:22 +00:00
|
|
|
switch (msg_type) {
|
|
|
|
case PCT_MSG_CLIENT_HELLO:
|
2008-07-09 07:24:13 +00:00
|
|
|
dissect_pct_msg_client_hello(tvb, ssl_record_tree, offset);
|
|
|
|
break;
|
2002-04-11 09:43:22 +00:00
|
|
|
case PCT_MSG_SERVER_HELLO:
|
2008-07-09 07:24:13 +00:00
|
|
|
dissect_pct_msg_server_hello(tvb, ssl_record_tree, offset, pinfo);
|
|
|
|
break;
|
2002-04-11 09:43:22 +00:00
|
|
|
case PCT_MSG_CLIENT_MASTER_KEY:
|
2008-07-09 07:24:13 +00:00
|
|
|
dissect_pct_msg_client_master_key(tvb, ssl_record_tree, offset);
|
|
|
|
break;
|
2002-04-11 09:43:22 +00:00
|
|
|
case PCT_MSG_SERVER_VERIFY:
|
2008-07-09 07:24:13 +00:00
|
|
|
dissect_pct_msg_server_verify(tvb, ssl_record_tree, offset);
|
|
|
|
break;
|
|
|
|
case PCT_MSG_ERROR:
|
|
|
|
dissect_pct_msg_error(tvb, ssl_record_tree, offset);
|
2002-04-11 09:43:22 +00:00
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
default: /* unknown */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
return (initial_offset + record_length_length + record_length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2007-09-16 19:28:58 +00:00
|
|
|
dissect_ssl2_hnd_client_hello(tvbuff_t *tvb, packet_info *pinfo,
|
2006-02-04 23:44:05 +00:00
|
|
|
proto_tree *tree, guint32 offset,
|
|
|
|
SslDecryptSession* ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* uint8 msg_type;
|
|
|
|
* Version version;
|
|
|
|
* uint16 cipher_spec_length;
|
|
|
|
* uint16 session_id_length;
|
|
|
|
* uint16 challenge_length;
|
|
|
|
* V2CipherSpec cipher_specs[V2ClientHello.cipher_spec_length];
|
|
|
|
* opaque session_id[V2ClientHello.session_id_length];
|
|
|
|
* Random challenge;
|
|
|
|
* } V2ClientHello;
|
|
|
|
*
|
|
|
|
* Note: when we get here, offset's already pointing at Version
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
guint16 version;
|
|
|
|
guint16 cipher_spec_length;
|
|
|
|
guint16 session_id_length;
|
|
|
|
guint16 challenge_length;
|
|
|
|
|
|
|
|
proto_tree *ti;
|
2006-08-02 08:15:51 +00:00
|
|
|
proto_tree *cs_tree;
|
|
|
|
cs_tree=0;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
version = tvb_get_ntohs(tvb, offset);
|
|
|
|
if (!ssl_is_valid_ssl_version(version))
|
|
|
|
{
|
|
|
|
/* invalid version; probably encrypted data */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree || ssl)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* show the version */
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
2007-04-10 18:40:05 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_client_version, tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
cipher_spec_length = tvb_get_ntohs(tvb, offset);
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_cipher_spec_len,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
session_id_length = tvb_get_ntohs(tvb, offset);
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_session_id_len,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, 2, FALSE);
|
2007-09-16 19:28:58 +00:00
|
|
|
if (session_id_length > SSLV2_MAX_SESSION_ID_LENGTH_IN_BYTES) {
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2,
|
|
|
|
"Invalid session ID length: %d", session_id_length);
|
|
|
|
expert_add_info_format(pinfo, NULL, PI_MALFORMED, PI_ERROR,
|
|
|
|
"Session ID length (%u) must be less than %u.",
|
|
|
|
session_id_length, SSLV2_MAX_SESSION_ID_LENGTH_IN_BYTES);
|
|
|
|
offset = tvb_length(tvb);
|
|
|
|
return;
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
challenge_length = tvb_get_ntohs(tvb, offset);
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_challenge_len,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
/* tell the user how many cipher specs they've won */
|
|
|
|
tvb_ensure_bytes_exist(tvb, offset, cipher_spec_length);
|
|
|
|
ti = proto_tree_add_none_format(tree, hf_ssl_handshake_cipher_suites,
|
2001-07-16 04:02:22 +00:00
|
|
|
tvb, offset, cipher_spec_length,
|
|
|
|
"Cipher Specs (%u specs)",
|
|
|
|
cipher_spec_length/3);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
/* make this a subtree and expand the actual specs below */
|
|
|
|
cs_tree = proto_item_add_subtree(ti, ett_ssl_cipher_suites);
|
|
|
|
if (!cs_tree)
|
|
|
|
{
|
|
|
|
cs_tree = tree; /* failsafe */
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate through the cipher specs, showing them */
|
|
|
|
while (cipher_spec_length > 0)
|
|
|
|
{
|
2006-02-04 23:44:05 +00:00
|
|
|
if (cs_tree)
|
|
|
|
proto_tree_add_item(cs_tree, hf_ssl2_handshake_cipher_spec,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, 3, FALSE);
|
|
|
|
offset += 3; /* length of one cipher spec */
|
|
|
|
cipher_spec_length -= 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if there's a session id, show it */
|
|
|
|
if (session_id_length > 0)
|
|
|
|
{
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
tvb_ensure_bytes_exist(tvb, offset, session_id_length);
|
|
|
|
proto_tree_add_bytes_format(tree,
|
|
|
|
hf_ssl_handshake_session_id,
|
|
|
|
tvb, offset, session_id_length,
|
2008-12-19 17:39:52 +00:00
|
|
|
tvb_get_ptr(tvb, offset, session_id_length),
|
2006-02-04 23:44:05 +00:00
|
|
|
"Session ID (%u byte%s)",
|
|
|
|
session_id_length,
|
|
|
|
plurality(session_id_length, "", "s"));
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-06 01:01:09 +00:00
|
|
|
/* PAOLO: get session id and reset session state for key [re]negotiation */
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl)
|
|
|
|
{
|
|
|
|
tvb_memcpy(tvb,ssl->session_id.data, offset, session_id_length);
|
|
|
|
ssl->session_id.data_len = session_id_length;
|
2008-07-09 07:24:13 +00:00
|
|
|
ssl->state &= ~(SSL_HAVE_SESSION_KEY|SSL_MASTER_SECRET|SSL_PRE_MASTER_SECRET|
|
2006-08-07 19:52:18 +00:00
|
|
|
SSL_CIPHER|SSL_SERVER_RANDOM);
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += session_id_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if there's a challenge, show it */
|
|
|
|
if (challenge_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, challenge_length);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
if (tree)
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_challenge,
|
2001-07-11 18:19:16 +00:00
|
|
|
tvb, offset, challenge_length, 0);
|
2006-02-04 23:44:05 +00:00
|
|
|
if (ssl)
|
|
|
|
{
|
2006-08-07 19:52:18 +00:00
|
|
|
/* PAOLO: get client random data; we get at most 32 bytes from
|
2006-02-06 01:01:09 +00:00
|
|
|
challenge */
|
2006-08-02 08:15:51 +00:00
|
|
|
gint max;
|
|
|
|
max = challenge_length > 32? 32: challenge_length;
|
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_debug_printf("client random len: %d padded to 32\n",
|
|
|
|
challenge_length);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-06 01:01:09 +00:00
|
|
|
/* client random is padded with zero and 'right' aligned */
|
2006-02-04 23:44:05 +00:00
|
|
|
memset(ssl->client_random.data, 0, 32 - max);
|
|
|
|
tvb_memcpy(tvb, &ssl->client_random.data[32 - max], offset, max);
|
|
|
|
ssl->client_random.data_len = 32;
|
|
|
|
ssl->state |= SSL_CLIENT_RANDOM;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
offset += challenge_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
static void
|
|
|
|
dissect_pct_msg_client_hello(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree, guint32 offset)
|
|
|
|
{
|
2006-08-07 19:52:18 +00:00
|
|
|
guint16 CH_CLIENT_VERSION, CH_OFFSET, CH_CIPHER_SPECS_LENGTH, CH_HASH_SPECS_LENGTH, CH_CERT_SPECS_LENGTH, CH_EXCH_SPECS_LENGTH, CH_KEY_ARG_LENGTH;
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_item *CH_CIPHER_SPECS_ti, *CH_HASH_SPECS_ti, *CH_CERT_SPECS_ti, *CH_EXCH_SPECS_ti;
|
|
|
|
proto_tree *CH_CIPHER_SPECS_tree, *CH_HASH_SPECS_tree, *CH_CERT_SPECS_tree, *CH_EXCH_SPECS_tree;
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
CH_CLIENT_VERSION = tvb_get_ntohs(tvb, offset);
|
|
|
|
if(CH_CLIENT_VERSION != PCT_VERSION_1)
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Client Version, should be %x in PCT version 1", PCT_VERSION_1);
|
|
|
|
else
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Client Version (%x)", PCT_VERSION_1);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "PAD");
|
|
|
|
offset += 1;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, 32, "Client Session ID Data (32 bytes)");
|
|
|
|
offset += 32;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2008-12-17 00:08:38 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, 32, "Challenge Data(32 bytes)");
|
2004-06-01 01:03:49 +00:00
|
|
|
offset += 32;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_OFFSET = tvb_get_ntohs(tvb, offset);
|
|
|
|
if(CH_OFFSET != PCT_CH_OFFSET_V1)
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "CH_OFFSET: %d, should be %d in PCT version 1", CH_OFFSET, PCT_CH_OFFSET_V1);
|
|
|
|
else
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "CH_OFFSET: %d", CH_OFFSET);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_CIPHER_SPECS_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "CIPHER_SPECS Length: %d", CH_CIPHER_SPECS_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_HASH_SPECS_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "HASH_SPECS Length: %d", CH_HASH_SPECS_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_CERT_SPECS_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "CERT_SPECS Length: %d", CH_CERT_SPECS_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_EXCH_SPECS_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "EXCH_SPECS Length: %d", CH_EXCH_SPECS_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_KEY_ARG_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "IV Length: %d", CH_KEY_ARG_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
if(CH_CIPHER_SPECS_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CH_CIPHER_SPECS_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_CIPHER_SPECS_ti = proto_tree_add_item(tree, hf_pct_handshake_cipher_spec, tvb, offset, CH_CIPHER_SPECS_LENGTH, FALSE);
|
|
|
|
CH_CIPHER_SPECS_tree = proto_item_add_subtree(CH_CIPHER_SPECS_ti, ett_pct_cipher_suites);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
for(i=0; i<(CH_CIPHER_SPECS_LENGTH/4); i++) {
|
|
|
|
proto_tree_add_item(CH_CIPHER_SPECS_tree, hf_pct_handshake_cipher, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
proto_tree_add_text(CH_CIPHER_SPECS_tree, tvb, offset, 1, "Encryption key length: %d", tvb_get_guint8(tvb, offset));
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(CH_CIPHER_SPECS_tree, tvb, offset, 1, "MAC key length in bits: %d", tvb_get_guint8(tvb, offset) + 64);
|
|
|
|
offset += 1;
|
|
|
|
}
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
if(CH_HASH_SPECS_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CH_HASH_SPECS_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_HASH_SPECS_ti = proto_tree_add_item(tree, hf_pct_handshake_hash_spec, tvb, offset, CH_HASH_SPECS_LENGTH, FALSE);
|
|
|
|
CH_HASH_SPECS_tree = proto_item_add_subtree(CH_HASH_SPECS_ti, ett_pct_hash_suites);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
for(i=0; i<(CH_HASH_SPECS_LENGTH/2); i++) {
|
|
|
|
proto_tree_add_item(CH_HASH_SPECS_tree, hf_pct_handshake_hash, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
if(CH_CERT_SPECS_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CH_CERT_SPECS_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_CERT_SPECS_ti = proto_tree_add_item(tree, hf_pct_handshake_cert_spec, tvb, offset, CH_CERT_SPECS_LENGTH, FALSE);
|
|
|
|
CH_CERT_SPECS_tree = proto_item_add_subtree(CH_CERT_SPECS_ti, ett_pct_cert_suites);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
for(i=0; i< (CH_CERT_SPECS_LENGTH/2); i++) {
|
|
|
|
proto_tree_add_item(CH_CERT_SPECS_tree, hf_pct_handshake_cert, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
if(CH_EXCH_SPECS_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CH_EXCH_SPECS_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
CH_EXCH_SPECS_ti = proto_tree_add_item(tree, hf_pct_handshake_exch_spec, tvb, offset, CH_EXCH_SPECS_LENGTH, FALSE);
|
|
|
|
CH_EXCH_SPECS_tree = proto_item_add_subtree(CH_EXCH_SPECS_ti, ett_pct_exch_suites);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
for(i=0; i<(CH_EXCH_SPECS_LENGTH/2); i++) {
|
|
|
|
proto_tree_add_item(CH_EXCH_SPECS_tree, hf_pct_handshake_exch, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
}
|
|
|
|
}
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
if(CH_KEY_ARG_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CH_KEY_ARG_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CH_KEY_ARG_LENGTH, "IV data (%d bytes)", CH_KEY_ARG_LENGTH);
|
|
|
|
offset += CH_KEY_ARG_LENGTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-08-02 08:57:40 +00:00
|
|
|
dissect_pct_msg_server_hello(tvbuff_t *tvb, proto_tree *tree, guint32 offset, packet_info *pinfo)
|
2004-06-01 01:03:49 +00:00
|
|
|
{
|
2006-08-07 19:52:18 +00:00
|
|
|
/* structure:
|
2004-06-01 01:03:49 +00:00
|
|
|
char SH_MSG_SERVER_HELLO
|
|
|
|
char SH_PAD
|
|
|
|
char SH_SERVER_VERSION_MSB
|
|
|
|
char SH_SERVER_VERSION_LSB
|
|
|
|
char SH_RESTART_SESSION_OK
|
|
|
|
char SH_CLIENT_AUTH_REQ
|
|
|
|
char SH_CIPHER_SPECS_DATA[4]
|
|
|
|
char SH_HASH_SPECS_DATA[2]
|
|
|
|
char SH_CERT_SPECS_DATA[2]
|
|
|
|
char SH_EXCH_SPECS_DATA[2]
|
|
|
|
char SH_CONNECTION_ID_DATA[32]
|
|
|
|
char SH_CERTIFICATE_LENGTH_MSB
|
|
|
|
char SH_CERTIFICATE_LENGTH_LSB
|
|
|
|
char SH_CLIENT_CERT_SPECS_LENGTH_MSB
|
|
|
|
char SH_CLIENT_CERT_SPECS_LENGTH_LSB
|
|
|
|
char SH_CLIENT_SIG_SPECS_LENGTH_MSB
|
|
|
|
char SH_CLIENT_SIG_SPECS_LENGTH_LSB
|
|
|
|
char SH_RESPONSE_LENGTH_MSB
|
|
|
|
char SH_RESPONSE_LENGTH_LSB
|
|
|
|
char SH_CERTIFICATE_DATA[MSB<<8|LSB]
|
|
|
|
char SH_CLIENT_CERT_SPECS_DATA[MSB<<8|LSB]
|
|
|
|
char SH_CLIENT_SIG_SPECS_DATA[MSB<<8|LSB]
|
|
|
|
char SH_RESPONSE_DATA[MSB<<8|LSB]
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-08-07 19:52:18 +00:00
|
|
|
guint16 SH_SERVER_VERSION, SH_CERT_LENGTH, SH_CERT_SPECS_LENGTH, SH_CLIENT_SIG_LENGTH, SH_RESPONSE_LENGTH;
|
2007-05-13 20:58:29 +00:00
|
|
|
asn1_ctx_t asn1_ctx;
|
|
|
|
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
|
2004-06-01 01:03:49 +00:00
|
|
|
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "PAD");
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
SH_SERVER_VERSION = tvb_get_ntohs(tvb, offset);
|
|
|
|
if(SH_SERVER_VERSION != PCT_VERSION_1)
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Server Version, should be %x in PCT version 1", PCT_VERSION_1);
|
|
|
|
else
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Server Version (%x)", PCT_VERSION_1);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SH_RESTART_SESSION_OK flag");
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SH_CLIENT_AUTH_REQ flag");
|
|
|
|
offset += 1;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_item(tree, hf_pct_handshake_cipher, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "Encryption key length: %d", tvb_get_guint8(tvb, offset));
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "MAC key length in bits: %d", tvb_get_guint8(tvb, offset) + 64);
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_pct_handshake_hash, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_pct_handshake_cert, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_pct_handshake_exch, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 32, "Connection ID Data (32 bytes)");
|
|
|
|
offset += 32;
|
|
|
|
|
|
|
|
SH_CERT_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Server Certificate Length: %d", SH_CERT_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
SH_CERT_SPECS_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Client CERT_SPECS Length: %d", SH_CERT_SPECS_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
SH_CLIENT_SIG_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Client SIG_SPECS Length: %d", SH_CLIENT_SIG_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
SH_RESPONSE_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Response Length: %d", SH_RESPONSE_LENGTH);
|
|
|
|
offset += 2;
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2004-06-01 01:03:49 +00:00
|
|
|
if(SH_CERT_LENGTH) {
|
2007-05-13 20:58:29 +00:00
|
|
|
dissect_x509af_Certificate(FALSE, tvb, offset, &asn1_ctx, tree, hf_pct_handshake_server_cert);
|
2004-06-01 01:03:49 +00:00
|
|
|
offset += SH_CERT_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SH_CERT_SPECS_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, SH_CERT_SPECS_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, SH_CERT_SPECS_LENGTH, "Client CERT_SPECS (%d bytes)", SH_CERT_SPECS_LENGTH);
|
|
|
|
offset += SH_CERT_SPECS_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SH_CLIENT_SIG_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, SH_CLIENT_SIG_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, SH_CLIENT_SIG_LENGTH, "Client Signature (%d bytes)", SH_CLIENT_SIG_LENGTH);
|
|
|
|
offset += SH_CLIENT_SIG_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SH_RESPONSE_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, SH_RESPONSE_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, SH_RESPONSE_LENGTH, "Server Response (%d bytes)", SH_RESPONSE_LENGTH);
|
|
|
|
offset += SH_RESPONSE_LENGTH;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_pct_msg_client_master_key(tvbuff_t *tvb, proto_tree *tree, guint32 offset)
|
|
|
|
{
|
|
|
|
guint16 CMK_CLEAR_KEY_LENGTH, CMK_ENCRYPTED_KEY_LENGTH, CMK_KEY_ARG_LENGTH, CMK_VERIFY_PRELUDE, CMK_CLIENT_CERT_LENGTH, CMK_RESPONSE_LENGTH;
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "PAD");
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_pct_handshake_cert, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
proto_tree_add_item(tree, hf_pct_handshake_sig, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
CMK_CLEAR_KEY_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Clear Key Length: %d",CMK_CLEAR_KEY_LENGTH);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
CMK_ENCRYPTED_KEY_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Encrypted Key Length: %d",CMK_ENCRYPTED_KEY_LENGTH);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
CMK_KEY_ARG_LENGTH= tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "IV Length: %d",CMK_KEY_ARG_LENGTH);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
CMK_VERIFY_PRELUDE = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Verify Prelude Length: %d",CMK_VERIFY_PRELUDE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
CMK_CLIENT_CERT_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Client Cert Length: %d",CMK_CLIENT_CERT_LENGTH);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
CMK_RESPONSE_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Response Length: %d",CMK_RESPONSE_LENGTH);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if(CMK_CLEAR_KEY_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CMK_CLEAR_KEY_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CMK_CLEAR_KEY_LENGTH, "Clear Key data (%d bytes)", CMK_CLEAR_KEY_LENGTH);
|
|
|
|
offset += CMK_CLEAR_KEY_LENGTH;
|
|
|
|
}
|
|
|
|
if(CMK_ENCRYPTED_KEY_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CMK_ENCRYPTED_KEY_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CMK_ENCRYPTED_KEY_LENGTH, "Encrypted Key data (%d bytes)", CMK_ENCRYPTED_KEY_LENGTH);
|
|
|
|
offset += CMK_ENCRYPTED_KEY_LENGTH;
|
|
|
|
}
|
|
|
|
if(CMK_KEY_ARG_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CMK_KEY_ARG_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CMK_KEY_ARG_LENGTH, "IV data (%d bytes)", CMK_KEY_ARG_LENGTH);
|
|
|
|
offset += CMK_KEY_ARG_LENGTH;
|
|
|
|
}
|
|
|
|
if(CMK_VERIFY_PRELUDE) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CMK_VERIFY_PRELUDE);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CMK_VERIFY_PRELUDE, "Verify Prelude data (%d bytes)", CMK_VERIFY_PRELUDE);
|
|
|
|
offset += CMK_VERIFY_PRELUDE;
|
|
|
|
}
|
|
|
|
if(CMK_CLIENT_CERT_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CMK_CLIENT_CERT_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CMK_CLIENT_CERT_LENGTH, "Client Certificate data (%d bytes)", CMK_CLIENT_CERT_LENGTH);
|
|
|
|
offset += CMK_CLIENT_CERT_LENGTH;
|
|
|
|
}
|
|
|
|
if(CMK_RESPONSE_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, CMK_RESPONSE_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, CMK_RESPONSE_LENGTH, "Response data (%d bytes)", CMK_RESPONSE_LENGTH);
|
|
|
|
offset += CMK_RESPONSE_LENGTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_pct_msg_server_verify(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree, guint32 offset)
|
|
|
|
{
|
|
|
|
guint16 SV_RESPONSE_LENGTH;
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "PAD");
|
|
|
|
offset += 1;
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 32, "Server Session ID data (32 bytes)");
|
|
|
|
offset += 32;
|
|
|
|
|
|
|
|
SV_RESPONSE_LENGTH = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Server Response Length: %d", SV_RESPONSE_LENGTH);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
if(SV_RESPONSE_LENGTH) {
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, SV_RESPONSE_LENGTH);
|
2004-06-01 01:03:49 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, SV_RESPONSE_LENGTH, "Server Response (%d bytes)", SV_RESPONSE_LENGTH);
|
|
|
|
offset += SV_RESPONSE_LENGTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_pct_msg_error(tvbuff_t *tvb,
|
|
|
|
proto_tree *tree, guint32 offset)
|
|
|
|
{
|
|
|
|
guint16 ERROR_CODE, INFO_LEN;
|
|
|
|
|
|
|
|
ERROR_CODE = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_item(tree, hf_pct_msg_error_type, tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
INFO_LEN = tvb_get_ntohs(tvb, offset);
|
2008-07-09 07:24:13 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, 2, "Error Information Length: %d", INFO_LEN);
|
2004-06-01 01:03:49 +00:00
|
|
|
offset += 2;
|
|
|
|
if (ERROR_CODE == PCT_ERR_SPECS_MISMATCH && INFO_LEN == 6)
|
|
|
|
{
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SPECS_MISMATCH_CIPHER");
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SPECS_MISMATCH_HASH");
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SPECS_MISMATCH_CERT");
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SPECS_MISMATCH_EXCH");
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SPECS_MISMATCH_CLIENT_CERT");
|
|
|
|
offset += 1;
|
|
|
|
proto_tree_add_text(tree, tvb, offset, 1, "SPECS_MISMATCH_CLIENT_SIG");
|
|
|
|
offset += 1;
|
|
|
|
}
|
|
|
|
else if(INFO_LEN) {
|
2008-07-09 07:24:13 +00:00
|
|
|
proto_tree_add_text(tree, tvb, offset, INFO_LEN, "Error Information data (%d bytes)", INFO_LEN);
|
2004-06-01 01:03:49 +00:00
|
|
|
offset += INFO_LEN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl2_hnd_client_master_key(tvbuff_t *tvb,
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree *tree, guint32 offset)
|
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* uint8 msg_type;
|
|
|
|
* V2Cipherspec cipher;
|
|
|
|
* uint16 clear_key_length;
|
|
|
|
* uint16 encrypted_key_length;
|
|
|
|
* uint16 key_arg_length;
|
|
|
|
* opaque clear_key_data[V2ClientMasterKey.clear_key_length];
|
|
|
|
* opaque encrypted_key_data[V2ClientMasterKey.encrypted_key_length];
|
|
|
|
* opaque key_arg_data[V2ClientMasterKey.key_arg_length];
|
|
|
|
* } V2ClientMasterKey;
|
|
|
|
*
|
|
|
|
* Note: when we get here, offset's already pointing at cipher
|
|
|
|
*/
|
|
|
|
guint16 clear_key_length;
|
|
|
|
guint16 encrypted_key_length;
|
|
|
|
guint16 key_arg_length;
|
|
|
|
|
|
|
|
/* at this point, everything we do involves the tree,
|
|
|
|
* so quit now if we don't have one ;-)
|
|
|
|
*/
|
|
|
|
if (!tree)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* show the selected cipher */
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_cipher_spec,
|
|
|
|
tvb, offset, 3, FALSE);
|
|
|
|
offset += 3;
|
|
|
|
|
|
|
|
/* get the fixed fields */
|
|
|
|
clear_key_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_clear_key_len,
|
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
encrypted_key_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_enc_key_len,
|
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
key_arg_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_key_arg_len,
|
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* show the variable length fields */
|
|
|
|
if (clear_key_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, clear_key_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_clear_key,
|
|
|
|
tvb, offset, clear_key_length, FALSE);
|
|
|
|
offset += clear_key_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (encrypted_key_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, encrypted_key_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_enc_key,
|
|
|
|
tvb, offset, encrypted_key_length, FALSE);
|
|
|
|
offset += encrypted_key_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_arg_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, key_arg_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_key_arg,
|
|
|
|
tvb, offset, key_arg_length, FALSE);
|
|
|
|
offset += key_arg_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-08 10:05:19 +00:00
|
|
|
dissect_ssl2_hnd_server_hello(tvbuff_t *tvb,
|
2004-08-02 08:57:40 +00:00
|
|
|
proto_tree *tree, guint32 offset, packet_info *pinfo)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
|
|
|
/* struct {
|
|
|
|
* uint8 msg_type;
|
|
|
|
* uint8 session_id_hit;
|
|
|
|
* uint8 certificate_type;
|
|
|
|
* uint16 server_version;
|
|
|
|
* uint16 certificate_length;
|
|
|
|
* uint16 cipher_specs_length;
|
|
|
|
* uint16 connection_id_length;
|
|
|
|
* opaque certificate_data[V2ServerHello.certificate_length];
|
|
|
|
* opaque cipher_specs_data[V2ServerHello.cipher_specs_length];
|
|
|
|
* opaque connection_id_data[V2ServerHello.connection_id_length];
|
|
|
|
* } V2ServerHello;
|
|
|
|
*
|
|
|
|
* Note: when we get here, offset's already pointing at session_id_hit
|
|
|
|
*/
|
|
|
|
guint16 certificate_length;
|
|
|
|
guint16 cipher_spec_length;
|
|
|
|
guint16 connection_id_length;
|
|
|
|
guint16 version;
|
|
|
|
proto_tree *ti;
|
|
|
|
proto_tree *subtree;
|
2008-07-09 07:24:13 +00:00
|
|
|
asn1_ctx_t asn1_ctx;
|
|
|
|
asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* everything we do only makes sense with a tree, so
|
|
|
|
* quit now if we don't have one
|
|
|
|
*/
|
|
|
|
if (!tree)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
version = tvb_get_ntohs(tvb, offset + 2);
|
|
|
|
if (!ssl_is_valid_ssl_version(version))
|
|
|
|
{
|
|
|
|
/* invalid version; probably encrypted data */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* is there a hit? */
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_session_id_hit,
|
|
|
|
tvb, offset, 1, FALSE);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* what type of certificate is this? */
|
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_cert_type,
|
|
|
|
tvb, offset, 1, FALSE);
|
|
|
|
offset++;
|
|
|
|
|
|
|
|
/* now the server version */
|
|
|
|
proto_tree_add_item(tree, hf_ssl_handshake_server_version,
|
|
|
|
tvb, offset, 2, FALSE);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* get the fixed fields */
|
|
|
|
certificate_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_uint(tree, hf_ssl_handshake_certificate_len,
|
|
|
|
tvb, offset, 2, certificate_length);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
cipher_spec_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_uint(tree, hf_ssl2_handshake_cipher_spec_len,
|
|
|
|
tvb, offset, 2, cipher_spec_length);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
connection_id_length = tvb_get_ntohs(tvb, offset);
|
|
|
|
proto_tree_add_uint(tree, hf_ssl2_handshake_connection_id_len,
|
|
|
|
tvb, offset, 2, connection_id_length);
|
|
|
|
offset += 2;
|
|
|
|
|
|
|
|
/* now the variable length fields */
|
|
|
|
if (certificate_length > 0)
|
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
(void)dissect_x509af_Certificate(FALSE, tvb, offset, &asn1_ctx, tree, hf_ssl_handshake_certificate);
|
|
|
|
offset += certificate_length;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cipher_spec_length > 0)
|
|
|
|
{
|
|
|
|
/* provide a collapsing node for the cipher specs */
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, cipher_spec_length);
|
2002-08-28 21:04:11 +00:00
|
|
|
ti = proto_tree_add_none_format(tree,
|
2001-07-16 04:02:22 +00:00
|
|
|
hf_ssl_handshake_cipher_suites,
|
|
|
|
tvb, offset, cipher_spec_length,
|
|
|
|
"Cipher Specs (%u spec%s)",
|
|
|
|
cipher_spec_length/3,
|
|
|
|
plurality(cipher_spec_length/3, "", "s"));
|
2001-07-11 18:19:16 +00:00
|
|
|
subtree = proto_item_add_subtree(ti, ett_ssl_cipher_suites);
|
|
|
|
if (!subtree)
|
|
|
|
{
|
|
|
|
subtree = tree;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate through the cipher specs */
|
|
|
|
while (cipher_spec_length > 0)
|
|
|
|
{
|
|
|
|
proto_tree_add_item(subtree, hf_ssl2_handshake_cipher_spec,
|
|
|
|
tvb, offset, 3, FALSE);
|
|
|
|
offset += 3;
|
|
|
|
cipher_spec_length -= 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (connection_id_length > 0)
|
|
|
|
{
|
2005-04-18 02:33:11 +00:00
|
|
|
tvb_ensure_bytes_exist(tvb, offset, connection_id_length);
|
2001-07-11 18:19:16 +00:00
|
|
|
proto_tree_add_item(tree, hf_ssl2_handshake_connection_id,
|
|
|
|
tvb, offset, connection_id_length, FALSE);
|
|
|
|
offset += connection_id_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-18 04:13:50 +00:00
|
|
|
void ssl_set_master_secret(guint32 frame_num, address *addr_srv, address *addr_cli,
|
2007-01-04 09:20:18 +00:00
|
|
|
port_type ptype, guint32 port_srv, guint32 port_cli,
|
|
|
|
guint32 version, gint cipher, const guchar *_master_secret,
|
|
|
|
const guchar *_client_random, const guchar *_server_random,
|
|
|
|
guint32 client_seq, guint32 server_seq)
|
|
|
|
{
|
|
|
|
conversation_t *conversation = NULL;
|
|
|
|
void *conv_data = NULL;
|
|
|
|
SslDecryptSession *ssl = NULL;
|
|
|
|
guint iv_len;
|
|
|
|
|
|
|
|
ssl_debug_printf("\nssl_set_master_secret enter frame #%u\n", frame_num);
|
|
|
|
|
|
|
|
conversation = find_conversation(frame_num, addr_srv, addr_cli, ptype, port_srv, port_cli, 0);
|
|
|
|
|
|
|
|
if (!conversation) {
|
|
|
|
/* create a new conversation */
|
|
|
|
conversation = conversation_new(frame_num, addr_srv, addr_cli, ptype, port_srv, port_cli, 0);
|
2008-02-11 17:04:51 +00:00
|
|
|
ssl_debug_printf(" new conversation = %p created\n", (void *)conversation);
|
2007-01-04 09:20:18 +00:00
|
|
|
}
|
|
|
|
conv_data = conversation_get_proto_data(conversation, proto_ssl);
|
|
|
|
|
|
|
|
if (conv_data) {
|
|
|
|
ssl = conv_data;
|
|
|
|
} else {
|
|
|
|
ssl = se_alloc0(sizeof(SslDecryptSession));
|
|
|
|
ssl_session_init(ssl);
|
|
|
|
ssl->version = SSL_VER_UNKNOWN;
|
|
|
|
conversation_add_proto_data(conversation, proto_ssl, ssl);
|
|
|
|
}
|
|
|
|
|
2008-02-11 17:04:51 +00:00
|
|
|
ssl_debug_printf(" conversation = %p, ssl_session = %p\n", (void *)conversation, (void *)ssl);
|
2007-11-21 14:10:55 +00:00
|
|
|
|
2007-01-04 09:20:18 +00:00
|
|
|
/* version */
|
|
|
|
if ((ssl->version==SSL_VER_UNKNOWN) && (version!=SSL_VER_UNKNOWN)) {
|
|
|
|
switch (version) {
|
|
|
|
case SSL_VER_SSLv3:
|
|
|
|
ssl->version = SSL_VER_SSLv3;
|
|
|
|
ssl->version_netorder = SSLV3_VERSION;
|
|
|
|
ssl->state |= SSL_VERSION;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_VER_TLS:
|
|
|
|
ssl->version = SSL_VER_TLS;
|
|
|
|
ssl->version_netorder = TLSV1_VERSION;
|
|
|
|
ssl->state |= SSL_VERSION;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL_VER_TLSv1DOT1:
|
|
|
|
ssl->version = SSL_VER_TLSv1DOT1;
|
|
|
|
ssl->version_netorder = TLSV1DOT1_VERSION;
|
|
|
|
ssl->state |= SSL_VERSION;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
|
|
|
break;
|
2009-02-11 07:03:51 +00:00
|
|
|
|
|
|
|
case SSL_VER_TLSv1DOT2:
|
|
|
|
ssl->version = SSL_VER_TLSv1DOT2;
|
|
|
|
ssl->version_netorder = TLSV1DOT2_VERSION;
|
|
|
|
ssl->state |= SSL_VERSION;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set version 0x%04X -> state 0x%02X\n", ssl->version_netorder, ssl->state);
|
|
|
|
break;
|
2007-01-04 09:20:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cipher */
|
|
|
|
if (cipher > 0) {
|
|
|
|
ssl->cipher = cipher;
|
|
|
|
if (ssl_find_cipher(ssl->cipher,&ssl->cipher_suite) < 0) {
|
|
|
|
ssl_debug_printf("ssl_set_master_secret can't find cipher suite 0x%X\n", ssl->cipher);
|
|
|
|
} else {
|
|
|
|
ssl->state |= SSL_CIPHER;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set CIPHER 0x%04X -> state 0x%02X\n", ssl->cipher, ssl->state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* client random */
|
|
|
|
if (_client_random) {
|
|
|
|
ssl_data_set(&ssl->client_random, _client_random, 32);
|
|
|
|
ssl->state |= SSL_CLIENT_RANDOM;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set CLIENT RANDOM -> state 0x%02X\n", ssl->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* server random */
|
|
|
|
if (_server_random) {
|
|
|
|
ssl_data_set(&ssl->server_random, _server_random, 32);
|
|
|
|
ssl->state |= SSL_SERVER_RANDOM;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret set SERVER RANDOM -> state 0x%02X\n", ssl->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* master secret */
|
|
|
|
if (_master_secret) {
|
|
|
|
ssl_data_set(&ssl->master_secret, _master_secret, 48);
|
2007-04-18 04:13:50 +00:00
|
|
|
ssl->state |= SSL_MASTER_SECRET;
|
2007-01-04 09:20:18 +00:00
|
|
|
ssl_debug_printf("ssl_set_master_secret set MASTER SECRET -> state 0x%02X\n", ssl->state);
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_debug_printf("ssl_set_master_secret trying to generate keys\n");
|
|
|
|
if (ssl_generate_keyring_material(ssl)<0) {
|
|
|
|
ssl_debug_printf("ssl_set_master_secret can't generate keyring material\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* change ciphers immediately */
|
2007-04-10 15:12:48 +00:00
|
|
|
ssl_change_cipher(ssl, TRUE);
|
|
|
|
ssl_change_cipher(ssl, FALSE);
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
/* update seq numbers if available */
|
2007-04-10 15:12:48 +00:00
|
|
|
if (ssl->client && (client_seq != (guint32)-1)) {
|
|
|
|
ssl->client->seq = client_seq;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret client->seq updated to %u\n", ssl->client->seq);
|
2007-01-04 09:20:18 +00:00
|
|
|
}
|
2007-04-10 15:12:48 +00:00
|
|
|
if (ssl->server && (server_seq != (guint32)-1)) {
|
|
|
|
ssl->server->seq = server_seq;
|
|
|
|
ssl_debug_printf("ssl_set_master_secret server->seq updated to %u\n", ssl->server->seq);
|
2007-01-04 09:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* update IV from last data */
|
|
|
|
iv_len = (ssl->cipher_suite.block>1) ? ssl->cipher_suite.block : 8;
|
2007-04-10 15:12:48 +00:00
|
|
|
if (ssl->client && ((ssl->client->seq > 0) || (ssl->client_data_for_iv.data_len > iv_len))) {
|
|
|
|
ssl_cipher_setiv(&ssl->client->evp, ssl->client_data_for_iv.data + ssl->client_data_for_iv.data_len - iv_len, iv_len);
|
2007-01-04 09:20:18 +00:00
|
|
|
ssl_print_data("ssl_set_master_secret client IV updated",ssl->client_data_for_iv.data + ssl->client_data_for_iv.data_len - iv_len, iv_len);
|
|
|
|
}
|
2007-04-10 15:12:48 +00:00
|
|
|
if (ssl->server && ((ssl->server->seq > 0) || (ssl->server_data_for_iv.data_len > iv_len))) {
|
|
|
|
ssl_cipher_setiv(&ssl->server->evp, ssl->server_data_for_iv.data + ssl->server_data_for_iv.data_len - iv_len, iv_len);
|
2007-01-04 09:20:18 +00:00
|
|
|
ssl_print_data("ssl_set_master_secret server IV updated",ssl->server_data_for_iv.data + ssl->server_data_for_iv.data_len - iv_len, iv_len);
|
|
|
|
}
|
|
|
|
}
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************
|
|
|
|
*
|
|
|
|
* Support Functions
|
|
|
|
*
|
|
|
|
*********************************************************************/
|
2006-02-04 23:44:05 +00:00
|
|
|
#if 0
|
2001-07-11 18:19:16 +00:00
|
|
|
static void
|
|
|
|
ssl_set_conv_version(packet_info *pinfo, guint version)
|
|
|
|
{
|
|
|
|
conversation_t *conversation;
|
2001-09-03 10:33:12 +00:00
|
|
|
|
|
|
|
if (pinfo->fd->flags.visited)
|
|
|
|
{
|
|
|
|
/* We've already processed this frame; no need to do any more
|
|
|
|
* work on it.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-02 20:07:03 +00:00
|
|
|
conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
|
2001-07-11 18:19:16 +00:00
|
|
|
pinfo->srcport, pinfo->destport, 0);
|
|
|
|
|
2001-09-03 10:33:12 +00:00
|
|
|
if (conversation == NULL)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-09-03 10:33:12 +00:00
|
|
|
/* create a new conversation */
|
2005-02-02 20:07:03 +00:00
|
|
|
conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst, pinfo->ptype,
|
2001-09-03 10:33:12 +00:00
|
|
|
pinfo->srcport, pinfo->destport, 0);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2001-09-03 10:33:12 +00:00
|
|
|
|
|
|
|
if (conversation_get_proto_data(conversation, proto_ssl) != NULL)
|
2001-07-11 18:19:16 +00:00
|
|
|
{
|
2001-09-03 10:33:12 +00:00
|
|
|
/* get rid of the current data */
|
|
|
|
conversation_delete_proto_data(conversation, proto_ssl);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2003-03-10 02:06:33 +00:00
|
|
|
conversation_add_proto_data(conversation, proto_ssl, GINT_TO_POINTER(version));
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2006-02-04 23:44:05 +00:00
|
|
|
#endif
|
2001-07-11 18:19:16 +00:00
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_is_valid_handshake_type(guint8 type)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case SSL_HND_HELLO_REQUEST:
|
|
|
|
case SSL_HND_CLIENT_HELLO:
|
|
|
|
case SSL_HND_SERVER_HELLO:
|
|
|
|
case SSL_HND_CERTIFICATE:
|
|
|
|
case SSL_HND_SERVER_KEY_EXCHG:
|
|
|
|
case SSL_HND_CERT_REQUEST:
|
|
|
|
case SSL_HND_SVR_HELLO_DONE:
|
|
|
|
case SSL_HND_CERT_VERIFY:
|
|
|
|
case SSL_HND_CLIENT_KEY_EXCHG:
|
|
|
|
case SSL_HND_FINISHED:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_is_valid_ssl_version(guint16 version)
|
|
|
|
{
|
2006-08-02 08:15:51 +00:00
|
|
|
const gchar *version_str;
|
|
|
|
version_str = match_strval(version, ssl_versions);
|
2001-07-11 18:19:16 +00:00
|
|
|
return version_str != NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_is_authoritative_version_message(guint8 content_type,
|
|
|
|
guint8 next_byte)
|
|
|
|
{
|
|
|
|
if (content_type == SSL_ID_HANDSHAKE
|
|
|
|
&& ssl_is_valid_handshake_type(next_byte))
|
|
|
|
{
|
|
|
|
return (next_byte != SSL_HND_CLIENT_HELLO);
|
|
|
|
}
|
|
|
|
else if (ssl_is_valid_content_type(content_type)
|
|
|
|
&& content_type != SSL_ID_HANDSHAKE)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_is_v2_client_hello(tvbuff_t *tvb, guint32 offset)
|
|
|
|
{
|
|
|
|
guint8 byte;
|
|
|
|
|
|
|
|
byte = tvb_get_guint8(tvb, offset);
|
|
|
|
if (byte != 0x80) /* v2 client hello should start this way */
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
byte = tvb_get_guint8(tvb, offset+2);
|
|
|
|
if (byte != 0x01) /* v2 client hello msg type */
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 1 in 2^16 of being right; improve later if necessary */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this applies a heuristic to determine whether
|
|
|
|
* or not the data beginning at offset looks like a
|
|
|
|
* valid sslv2 record. this isn't really possible,
|
|
|
|
* but we'll try to do a reasonable job anyway.
|
|
|
|
*/
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_looks_like_sslv2(tvbuff_t *tvb, guint32 offset)
|
|
|
|
{
|
|
|
|
/* here's the current approach:
|
|
|
|
*
|
|
|
|
* we only try to catch unencrypted handshake messages, so we can
|
|
|
|
* assume that there is not padding. This means that the
|
|
|
|
* first byte must be >= 0x80 and there must be a valid sslv2
|
|
|
|
* msg_type in the third byte
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* get the first byte; must have high bit set */
|
2006-08-02 08:15:51 +00:00
|
|
|
guint8 byte;
|
|
|
|
byte = tvb_get_guint8(tvb, offset);
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
if (byte < 0x80)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the supposed msg_type byte; since we only care about
|
|
|
|
* unencrypted handshake messages (we can't tell the type for
|
|
|
|
* encrypted messages), we just check against that list
|
|
|
|
*/
|
|
|
|
byte = tvb_get_guint8(tvb, offset + 2);
|
|
|
|
switch(byte) {
|
|
|
|
case SSL2_HND_ERROR:
|
|
|
|
case SSL2_HND_CLIENT_HELLO:
|
|
|
|
case SSL2_HND_CLIENT_MASTER_KEY:
|
|
|
|
case SSL2_HND_SERVER_HELLO:
|
2002-04-11 09:43:22 +00:00
|
|
|
case PCT_MSG_CLIENT_MASTER_KEY:
|
|
|
|
case PCT_MSG_ERROR:
|
2001-07-11 18:19:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this applies a heuristic to determine whether
|
|
|
|
* or not the data beginning at offset looks like a
|
|
|
|
* valid sslv3 record. this is somewhat more reliable
|
|
|
|
* than sslv2 due to the structure of the v3 protocol
|
|
|
|
*/
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_looks_like_sslv3(tvbuff_t *tvb, guint32 offset)
|
|
|
|
{
|
|
|
|
/* have to have a valid content type followed by a valid
|
|
|
|
* protocol version
|
|
|
|
*/
|
|
|
|
guint8 byte;
|
|
|
|
guint16 version;
|
|
|
|
|
|
|
|
/* see if the first byte is a valid content type */
|
|
|
|
byte = tvb_get_guint8(tvb, offset);
|
|
|
|
if (!ssl_is_valid_content_type(byte))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now check to see if the version byte appears valid */
|
|
|
|
version = tvb_get_ntohs(tvb, offset + 1);
|
2008-07-09 07:24:13 +00:00
|
|
|
switch(version) {
|
|
|
|
case SSLV3_VERSION:
|
|
|
|
case TLSV1_VERSION:
|
|
|
|
case TLSV1DOT1_VERSION:
|
2009-02-11 07:03:51 +00:00
|
|
|
case TLSV1DOT2_VERSION:
|
2008-07-09 07:24:13 +00:00
|
|
|
return 1;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2008-07-09 07:24:13 +00:00
|
|
|
return 0;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* applies a heuristic to determine whether
|
|
|
|
* or not the data beginning at offset looks
|
|
|
|
* like a valid, unencrypted v2 handshake message.
|
|
|
|
* since it isn't possible to completely tell random
|
|
|
|
* data apart from a valid message without state,
|
|
|
|
* we try to help the odds.
|
|
|
|
*/
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2001-07-11 18:19:16 +00:00
|
|
|
ssl_looks_like_valid_v2_handshake(tvbuff_t *tvb, guint32 offset,
|
|
|
|
guint32 record_length)
|
|
|
|
{
|
|
|
|
/* first byte should be a msg_type.
|
|
|
|
*
|
|
|
|
* - we know we only see client_hello, client_master_key,
|
|
|
|
* and server_hello in the clear, so check to see if
|
|
|
|
* msg_type is one of those (this gives us a 3 in 2^8
|
|
|
|
* chance of saying yes with random payload)
|
|
|
|
*
|
|
|
|
* - for those three types that we know about, do some
|
|
|
|
* further validation to reduce the chance of an error
|
|
|
|
*/
|
|
|
|
guint8 msg_type;
|
|
|
|
guint16 version;
|
|
|
|
guint32 sum;
|
2008-02-07 12:14:40 +00:00
|
|
|
gint ret = 0;
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* fetch the msg_type */
|
|
|
|
msg_type = tvb_get_guint8(tvb, offset);
|
|
|
|
|
|
|
|
switch (msg_type) {
|
|
|
|
case SSL2_HND_CLIENT_HELLO:
|
|
|
|
/* version follows msg byte, so verify that this is valid */
|
|
|
|
version = tvb_get_ntohs(tvb, offset+1);
|
2008-02-07 12:14:40 +00:00
|
|
|
ret = ssl_is_valid_ssl_version(version);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL2_HND_SERVER_HELLO:
|
|
|
|
/* version is three bytes after msg_type */
|
|
|
|
version = tvb_get_ntohs(tvb, offset+3);
|
2008-02-07 12:14:40 +00:00
|
|
|
ret = ssl_is_valid_ssl_version(version);
|
2001-07-11 18:19:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SSL2_HND_CLIENT_MASTER_KEY:
|
|
|
|
/* sum of clear_key_length, encrypted_key_length, and key_arg_length
|
|
|
|
* must be less than record length
|
|
|
|
*/
|
|
|
|
sum = tvb_get_ntohs(tvb, offset + 4); /* clear_key_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 6); /* encrypted_key_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 8); /* key_arg_length */
|
2008-02-07 12:14:40 +00:00
|
|
|
if (sum <= record_length) {
|
|
|
|
ret = 1;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-02-07 12:14:40 +00:00
|
|
|
break;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2008-02-07 12:14:40 +00:00
|
|
|
|
|
|
|
return ret;
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 09:43:22 +00:00
|
|
|
/* applies a heuristic to determine whether
|
|
|
|
* or not the data beginning at offset looks
|
2008-07-09 07:24:13 +00:00
|
|
|
* like a valid, unencrypted pct handshake message.
|
2002-04-11 09:43:22 +00:00
|
|
|
* since it isn't possible to completely tell random
|
|
|
|
* data apart from a valid message without state,
|
|
|
|
* we try to help the odds.
|
|
|
|
*/
|
2006-08-02 08:15:51 +00:00
|
|
|
static gint
|
2002-04-11 09:43:22 +00:00
|
|
|
ssl_looks_like_valid_pct_handshake(tvbuff_t *tvb, guint32 offset,
|
2008-07-09 07:24:13 +00:00
|
|
|
guint32 record_length)
|
2002-04-11 09:43:22 +00:00
|
|
|
{
|
|
|
|
/* first byte should be a msg_type.
|
|
|
|
*
|
|
|
|
* - we know we only see client_hello, client_master_key,
|
|
|
|
* and server_hello in the clear, so check to see if
|
|
|
|
* msg_type is one of those (this gives us a 3 in 2^8
|
|
|
|
* chance of saying yes with random payload)
|
|
|
|
*
|
|
|
|
* - for those three types that we know about, do some
|
|
|
|
* further validation to reduce the chance of an error
|
|
|
|
*/
|
|
|
|
guint8 msg_type;
|
|
|
|
guint16 version;
|
|
|
|
guint32 sum;
|
2008-02-07 12:14:40 +00:00
|
|
|
gint ret = 0;
|
2002-04-11 09:43:22 +00:00
|
|
|
|
|
|
|
/* fetch the msg_type */
|
|
|
|
msg_type = tvb_get_guint8(tvb, offset);
|
|
|
|
|
|
|
|
switch (msg_type) {
|
|
|
|
case PCT_MSG_CLIENT_HELLO:
|
|
|
|
/* version follows msg byte, so verify that this is valid */
|
|
|
|
version = tvb_get_ntohs(tvb, offset+1);
|
2008-02-07 12:14:40 +00:00
|
|
|
ret = (version == PCT_VERSION_1);
|
2002-04-11 09:43:22 +00:00
|
|
|
|
|
|
|
case PCT_MSG_SERVER_HELLO:
|
|
|
|
/* version is one byte after msg_type */
|
|
|
|
version = tvb_get_ntohs(tvb, offset+2);
|
2008-02-07 12:14:40 +00:00
|
|
|
ret = (version == PCT_VERSION_1);
|
2002-04-11 09:43:22 +00:00
|
|
|
|
|
|
|
case PCT_MSG_CLIENT_MASTER_KEY:
|
|
|
|
/* sum of various length fields must be less than record length */
|
|
|
|
sum = tvb_get_ntohs(tvb, offset + 6); /* clear_key_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 8); /* encrypted_key_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 10); /* key_arg_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 12); /* verify_prelude_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 14); /* client_cert_length */
|
|
|
|
sum += tvb_get_ntohs(tvb, offset + 16); /* response_length */
|
2008-02-07 12:14:40 +00:00
|
|
|
if (sum <= record_length) {
|
|
|
|
ret = 1;
|
2002-04-11 09:43:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCT_MSG_SERVER_VERIFY:
|
2008-07-09 07:24:13 +00:00
|
|
|
/* record is 36 bytes longer than response_length */
|
|
|
|
sum = tvb_get_ntohs(tvb, offset + 34); /* response_length */
|
|
|
|
if ((sum + 36) == record_length) {
|
|
|
|
ret = 1;
|
2008-02-07 12:14:40 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-04-11 09:43:22 +00:00
|
|
|
|
|
|
|
default:
|
2008-02-07 12:14:40 +00:00
|
|
|
break;
|
2002-04-11 09:43:22 +00:00
|
|
|
}
|
2008-02-07 12:14:40 +00:00
|
|
|
|
|
|
|
return ret;
|
2002-04-11 09:43:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-11 18:19:16 +00:00
|
|
|
/*********************************************************************
|
|
|
|
*
|
2007-01-02 14:11:35 +00:00
|
|
|
* Standard Wireshark Protocol Registration and housekeeping
|
2001-07-11 18:19:16 +00:00
|
|
|
*
|
|
|
|
*********************************************************************/
|
|
|
|
void
|
|
|
|
proto_register_ssl(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Setup list of header fields See Section 1.6.1 for details*/
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_ssl_record,
|
|
|
|
{ "Record Layer", "ssl.record",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Record layer", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_record_content_type,
|
|
|
|
{ "Content Type", "ssl.record.content_type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_31_content_type), 0x0,
|
|
|
|
"Content type", HFILL}
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_msg_type,
|
|
|
|
{ "Handshake Message Type", "ssl.handshake.type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_20_msg_types), 0x0,
|
|
|
|
"SSLv2 handshake message type", HFILL}
|
|
|
|
},
|
2002-04-11 09:43:22 +00:00
|
|
|
{ &hf_pct_msg_type,
|
|
|
|
{ "Handshake Message Type", "ssl.pct_handshake.type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(pct_msg_types), 0x0,
|
|
|
|
"PCT handshake message type", HFILL}
|
|
|
|
},
|
2001-07-11 18:19:16 +00:00
|
|
|
{ &hf_ssl_record_version,
|
|
|
|
{ "Version", "ssl.record.version",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(ssl_versions), 0x0,
|
2008-07-09 07:24:13 +00:00
|
|
|
"Record layer version", HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
|
|
|
{ &hf_ssl_record_length,
|
|
|
|
{ "Length", "ssl.record.length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of SSL record data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_record_appdata,
|
2006-07-01 05:41:30 +00:00
|
|
|
{ "Encrypted Application Data", "ssl.app_data",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
2006-07-01 05:41:30 +00:00
|
|
|
"Payload is encrypted application data", HFILL }
|
2006-02-04 23:44:05 +00:00
|
|
|
},
|
|
|
|
|
2008-07-09 07:24:13 +00:00
|
|
|
{ &hf_ssl2_record,
|
2002-04-11 09:43:22 +00:00
|
|
|
{ "SSLv2/PCT Record Header", "ssl.record",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
2002-04-11 09:43:22 +00:00
|
|
|
"SSLv2/PCT record data", HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
|
|
|
{ &hf_ssl2_record_is_escape,
|
|
|
|
{ "Is Escape", "ssl.record.is_escape",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Indicates a security escape", HFILL}
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_record_padding_length,
|
|
|
|
{ "Padding Length", "ssl.record.padding_length",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of padding at end of record", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_change_cipher_spec,
|
|
|
|
{ "Change Cipher Spec Message", "ssl.change_cipher_spec",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Signals a change in cipher specifications", HFILL }
|
|
|
|
},
|
2008-07-09 07:24:13 +00:00
|
|
|
{ &hf_ssl_alert_message,
|
2001-07-11 18:19:16 +00:00
|
|
|
{ "Alert Message", "ssl.alert_message",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Alert message", HFILL }
|
|
|
|
},
|
2008-07-09 07:24:13 +00:00
|
|
|
{ &hf_ssl_alert_message_level,
|
2001-07-11 18:19:16 +00:00
|
|
|
{ "Level", "ssl.alert_message.level",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_31_alert_level), 0x0,
|
|
|
|
"Alert message level", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_alert_message_description,
|
|
|
|
{ "Description", "ssl.alert_message.desc",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_31_alert_description), 0x0,
|
|
|
|
"Alert message description", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_protocol,
|
|
|
|
{ "Handshake Protocol", "ssl.handshake",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Handshake protocol message", HFILL}
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_type,
|
|
|
|
{ "Handshake Type", "ssl.handshake.type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_31_handshake_type), 0x0,
|
|
|
|
"Type of handshake message", HFILL}
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_length,
|
|
|
|
{ "Length", "ssl.handshake.length",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of handshake message", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_client_version,
|
|
|
|
{ "Version", "ssl.handshake.version",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(ssl_versions), 0x0,
|
|
|
|
"Maximum version supported by client", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_server_version,
|
|
|
|
{ "Version", "ssl.handshake.version",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(ssl_versions), 0x0,
|
|
|
|
"Version selected by server", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_random_time,
|
2006-08-30 07:31:36 +00:00
|
|
|
{ "gmt_unix_time", "ssl.handshake.random_time",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_ABSOLUTE_TIME, BASE_NONE, NULL, 0x0,
|
2001-07-11 18:19:16 +00:00
|
|
|
"Unix time field of random structure", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_random_bytes,
|
2006-08-30 07:31:36 +00:00
|
|
|
{ "random_bytes", "ssl.handshake.random_bytes",
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
2001-07-11 18:19:16 +00:00
|
|
|
"Random challenge used to authenticate server", HFILL }
|
|
|
|
},
|
2001-07-16 01:38:34 +00:00
|
|
|
{ &hf_ssl_handshake_cipher_suites_len,
|
2001-07-16 05:17:30 +00:00
|
|
|
{ "Cipher Suites Length", "ssl.handshake.cipher_suites_length",
|
2001-07-16 01:38:34 +00:00
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of cipher suites field", HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
2001-07-16 04:02:22 +00:00
|
|
|
{ &hf_ssl_handshake_cipher_suites,
|
|
|
|
{ "Cipher Suites", "ssl.handshake.ciphersuites",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"List of cipher suites supported by client", HFILL }
|
|
|
|
},
|
2001-07-11 18:19:16 +00:00
|
|
|
{ &hf_ssl_handshake_cipher_suite,
|
|
|
|
{ "Cipher Suite", "ssl.handshake.ciphersuite",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(ssl_31_ciphersuite), 0x0,
|
|
|
|
"Cipher suite", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_cipher_spec,
|
|
|
|
{ "Cipher Spec", "ssl.handshake.cipherspec",
|
|
|
|
FT_UINT24, BASE_HEX, VALS(ssl_20_cipher_suites), 0x0,
|
|
|
|
"Cipher specification", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_session_id,
|
|
|
|
{ "Session ID", "ssl.handshake.session_id",
|
2001-07-16 01:38:34 +00:00
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
2001-07-11 18:19:16 +00:00
|
|
|
"Identifies the SSL session, allowing later resumption", HFILL }
|
|
|
|
},
|
2001-07-16 01:38:34 +00:00
|
|
|
{ &hf_ssl_handshake_comp_methods_len,
|
|
|
|
{ "Compression Methods Length", "ssl.handshake.comp_methods_length",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of compression methods field", HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
2001-07-16 04:02:22 +00:00
|
|
|
{ &hf_ssl_handshake_comp_methods,
|
|
|
|
{ "Compression Methods", "ssl.handshake.comp_methods",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"List of compression methods supported by client", HFILL }
|
|
|
|
},
|
2001-07-11 18:19:16 +00:00
|
|
|
{ &hf_ssl_handshake_comp_method,
|
|
|
|
{ "Compression Method", "ssl.handshake.comp_method",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_31_compression_method), 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
2004-12-26 00:28:47 +00:00
|
|
|
{ &hf_ssl_handshake_extensions_len,
|
|
|
|
{ "Extensions Length", "ssl.handshake.extensions_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of hello extensions", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_extension_type,
|
|
|
|
{ "Type", "ssl.handshake.extension.type",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(tls_hello_extension_types), 0x0,
|
|
|
|
"Hello extension type", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_extension_len,
|
|
|
|
{ "Length", "ssl.handshake.extension.len",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of a hello extension", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_extension_data,
|
|
|
|
{ "Data", "ssl.handshake.extension.data",
|
|
|
|
FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
|
|
"Hello Extension data", HFILL }
|
|
|
|
},
|
2001-07-16 01:38:34 +00:00
|
|
|
{ &hf_ssl_handshake_certificates_len,
|
2001-07-16 04:02:22 +00:00
|
|
|
{ "Certificates Length", "ssl.handshake.certificates_length",
|
2001-07-16 01:38:34 +00:00
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of certificates field", HFILL }
|
|
|
|
},
|
2001-07-16 04:02:22 +00:00
|
|
|
{ &hf_ssl_handshake_certificates,
|
|
|
|
{ "Certificates", "ssl.handshake.certificates",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"List of certificates", HFILL }
|
|
|
|
},
|
2001-07-11 18:19:16 +00:00
|
|
|
{ &hf_ssl_handshake_certificate,
|
|
|
|
{ "Certificate", "ssl.handshake.certificate",
|
2007-08-24 06:52:19 +00:00
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_certificate_len,
|
|
|
|
{ "Certificate Length", "ssl.handshake.certificate_length",
|
|
|
|
FT_UINT24, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of certificate", HFILL }
|
|
|
|
},
|
2001-07-16 01:38:34 +00:00
|
|
|
{ &hf_ssl_handshake_cert_types_count,
|
|
|
|
{ "Certificate types count", "ssl.handshake.cert_types_count",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Count of certificate types", HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
2001-07-16 04:02:22 +00:00
|
|
|
{ &hf_ssl_handshake_cert_types,
|
|
|
|
{ "Certificate types", "ssl.handshake.cert_types",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"List of certificate types", HFILL }
|
|
|
|
},
|
2001-07-11 18:19:16 +00:00
|
|
|
{ &hf_ssl_handshake_cert_type,
|
|
|
|
{ "Certificate type", "ssl.handshake.cert_type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_31_client_certificate_type), 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_finished,
|
|
|
|
{ "Verify Data", "ssl.handshake.verify_data",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Opaque verification data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_md5_hash,
|
|
|
|
{ "MD5 Hash", "ssl.handshake.md5_hash",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Hash of messages, master_secret, etc.", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_sha_hash,
|
|
|
|
{ "SHA-1 Hash", "ssl.handshake.sha_hash",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Hash of messages, master_secret, etc.", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_session_id_len,
|
|
|
|
{ "Session ID Length", "ssl.handshake.session_id_length",
|
|
|
|
FT_UINT8, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of session ID field", HFILL }
|
|
|
|
},
|
2001-07-16 01:38:34 +00:00
|
|
|
{ &hf_ssl_handshake_dnames_len,
|
|
|
|
{ "Distinguished Names Length", "ssl.handshake.dnames_len",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of list of CAs that server trusts", HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
2001-07-16 04:02:22 +00:00
|
|
|
{ &hf_ssl_handshake_dnames,
|
|
|
|
{ "Distinguished Names", "ssl.handshake.dnames",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"List of CAs that server trusts", HFILL }
|
|
|
|
},
|
2001-07-11 18:19:16 +00:00
|
|
|
{ &hf_ssl_handshake_dname_len,
|
|
|
|
{ "Distinguished Name Length", "ssl.handshake.dname_len",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of distinguished name", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl_handshake_dname,
|
2001-07-15 19:09:07 +00:00
|
|
|
{ "Distinguished Name", "ssl.handshake.dname",
|
2008-01-13 14:10:02 +00:00
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
2001-07-11 18:19:16 +00:00
|
|
|
"Distinguished name of a CA that server trusts", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_challenge,
|
|
|
|
{ "Challenge", "ssl.handshake.challenge",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Challenge data used to authenticate server", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_cipher_spec_len,
|
|
|
|
{ "Cipher Spec Length", "ssl.handshake.cipher_spec_len",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of cipher specs field", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_session_id_len,
|
|
|
|
{ "Session ID Length", "ssl.handshake.session_id_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of session ID field", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_challenge_len,
|
|
|
|
{ "Challenge Length", "ssl.handshake.challenge_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of challenge field", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_clear_key_len,
|
|
|
|
{ "Clear Key Data Length", "ssl.handshake.clear_key_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of clear key data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_enc_key_len,
|
|
|
|
{ "Encrypted Key Data Length", "ssl.handshake.encrypted_key_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of encrypted key data", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_key_arg_len,
|
|
|
|
{ "Key Argument Length", "ssl.handshake.key_arg_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of key argument", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_clear_key,
|
|
|
|
{ "Clear Key Data", "ssl.handshake.clear_key_data",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Clear portion of MASTER-KEY", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_enc_key,
|
|
|
|
{ "Encrypted Key", "ssl.handshake.encrypted_key",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Secret portion of MASTER-KEY encrypted to server", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_key_arg,
|
|
|
|
{ "Key Argument", "ssl.handshake.key_arg",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Key Argument (e.g., Initialization Vector)", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_session_id_hit,
|
|
|
|
{ "Session ID Hit", "ssl.handshake.session_id_hit",
|
|
|
|
FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Did the server find the client's Session ID?", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_cert_type,
|
|
|
|
{ "Certificate Type", "ssl.handshake.cert_type",
|
|
|
|
FT_UINT8, BASE_DEC, VALS(ssl_20_certificate_type), 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2001-07-11 18:19:16 +00:00
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_connection_id_len,
|
|
|
|
{ "Connection ID Length", "ssl.handshake.connection_id_length",
|
|
|
|
FT_UINT16, BASE_DEC, NULL, 0x0,
|
|
|
|
"Length of connection ID", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_ssl2_handshake_connection_id,
|
|
|
|
{ "Connection ID", "ssl.handshake.connection_id",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"Server's challenge to client", HFILL }
|
|
|
|
},
|
2006-02-04 23:44:05 +00:00
|
|
|
{ &hf_pct_handshake_cipher_spec,
|
|
|
|
{ "Cipher Spec", "pct.handshake.cipherspec",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"PCT Cipher specification", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_cipher,
|
|
|
|
{ "Cipher", "pct.handshake.cipher",
|
2006-08-07 19:52:18 +00:00
|
|
|
FT_UINT16, BASE_HEX, VALS(pct_cipher_type), 0x0,
|
2006-02-04 23:44:05 +00:00
|
|
|
"PCT Ciper", HFILL }
|
2008-07-09 07:24:13 +00:00
|
|
|
},
|
2006-02-04 23:44:05 +00:00
|
|
|
{ &hf_pct_handshake_hash_spec,
|
|
|
|
{ "Hash Spec", "pct.handshake.hashspec",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"PCT Hash specification", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_hash,
|
|
|
|
{ "Hash", "pct.handshake.hash",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(pct_hash_type), 0x0,
|
|
|
|
"PCT Hash", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_cert_spec,
|
|
|
|
{ "Cert Spec", "pct.handshake.certspec",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"PCT Certificate specification", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_cert,
|
|
|
|
{ "Cert", "pct.handshake.cert",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(pct_cert_type), 0x0,
|
|
|
|
"PCT Certificate", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_exch_spec,
|
|
|
|
{ "Exchange Spec", "pct.handshake.exchspec",
|
|
|
|
FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"PCT Exchange specification", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_exch,
|
|
|
|
{ "Exchange", "pct.handshake.exch",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(pct_exch_type), 0x0,
|
|
|
|
"PCT Exchange", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_sig,
|
|
|
|
{ "Sig Spec", "pct.handshake.sig",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(pct_sig_type), 0x0,
|
|
|
|
"PCT Signature", HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_pct_msg_error_type,
|
|
|
|
{ "PCT Error Code", "pct.msg_error_code",
|
|
|
|
FT_UINT16, BASE_HEX, VALS(pct_error_code), 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }
|
2006-02-04 23:44:05 +00:00
|
|
|
},
|
|
|
|
{ &hf_pct_handshake_server_cert,
|
|
|
|
{ "Server Cert", "pct.handshake.server_cert",
|
|
|
|
FT_NONE, BASE_NONE, NULL , 0x0,
|
|
|
|
"PCT Server Certificate", HFILL }
|
|
|
|
},
|
2007-04-10 15:12:48 +00:00
|
|
|
{ &hf_ssl_segment_overlap,
|
|
|
|
{ "Segment overlap", "ssl.segment.overlap", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Segment overlaps with other segments", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_ssl_segment_overlap_conflict,
|
|
|
|
{ "Conflicting data in segment overlap", "ssl.segment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Overlapping segments contained conflicting data", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_ssl_segment_multiple_tails,
|
|
|
|
{ "Multiple tail segments found", "ssl.segment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Several tails were found when reassembling the pdu", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_ssl_segment_too_long_fragment,
|
|
|
|
{ "Segment too long", "ssl.segment.toolongfragment", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
|
|
|
|
"Segment contained data past end of the pdu", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_ssl_segment_error,
|
|
|
|
{ "Reassembling error", "ssl.segment.error", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
|
|
|
"Reassembling error due to illegal segments", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_ssl_segment,
|
|
|
|
{ "SSL Segment", "ssl.segment", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2007-04-10 15:12:48 +00:00
|
|
|
|
|
|
|
{ &hf_ssl_segments,
|
|
|
|
{ "Reassembled SSL Segments", "ssl.segments", FT_NONE, BASE_NONE, NULL, 0x0,
|
|
|
|
"SSL Segments", HFILL }},
|
|
|
|
|
|
|
|
{ &hf_ssl_reassembled_in,
|
|
|
|
{ "Reassembled PDU in frame", "ssl.reassembled_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
|
|
|
|
"The PDU that doesn't end in this segment is reassembled in this frame", HFILL }},
|
2001-07-11 18:19:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Setup protocol subtree array */
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_ssl,
|
|
|
|
&ett_ssl_record,
|
|
|
|
&ett_ssl_alert,
|
|
|
|
&ett_ssl_handshake,
|
|
|
|
&ett_ssl_cipher_suites,
|
|
|
|
&ett_ssl_comp_methods,
|
2008-07-09 07:24:13 +00:00
|
|
|
&ett_ssl_extension,
|
2001-07-11 18:19:16 +00:00
|
|
|
&ett_ssl_certs,
|
|
|
|
&ett_ssl_cert_types,
|
|
|
|
&ett_ssl_dnames,
|
2006-08-30 07:31:36 +00:00
|
|
|
&ett_ssl_random,
|
2008-07-09 07:24:13 +00:00
|
|
|
&ett_pct_cipher_suites,
|
|
|
|
&ett_pct_hash_suites,
|
|
|
|
&ett_pct_cert_suites,
|
|
|
|
&ett_pct_exch_suites,
|
|
|
|
&ett_ssl_segments,
|
|
|
|
&ett_ssl_segment
|
2001-07-11 18:19:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Register the protocol name and description */
|
2006-02-08 12:45:14 +00:00
|
|
|
proto_ssl = proto_register_protocol("Secure Socket Layer",
|
|
|
|
"SSL", "ssl");
|
2001-07-11 18:19:16 +00:00
|
|
|
|
|
|
|
/* Required function calls to register the header fields and
|
|
|
|
* subtrees used */
|
|
|
|
proto_register_field_array(proto_ssl, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2002-01-04 07:01:54 +00:00
|
|
|
|
|
|
|
{
|
2008-07-09 07:24:13 +00:00
|
|
|
module_t *ssl_module = prefs_register_protocol(proto_ssl, proto_reg_handoff_ssl);
|
|
|
|
prefs_register_bool_preference(ssl_module,
|
2004-08-21 09:02:52 +00:00
|
|
|
"desegment_ssl_records",
|
|
|
|
"Reassemble SSL records spanning multiple TCP segments",
|
|
|
|
"Whether the SSL dissector should reassemble SSL records spanning multiple TCP segments. "
|
|
|
|
"To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
|
|
|
|
&ssl_desegment);
|
2008-07-09 07:24:13 +00:00
|
|
|
prefs_register_bool_preference(ssl_module,
|
2006-06-27 13:36:10 +00:00
|
|
|
"desegment_ssl_application_data",
|
|
|
|
"Reassemble SSL Application Data spanning multiple SSL records",
|
|
|
|
"Whether the SSL dissector should reassemble SSL Application Data spanning multiple SSL records. ",
|
|
|
|
&ssl_desegment_app_data);
|
2006-06-29 07:31:52 +00:00
|
|
|
#ifdef HAVE_LIBGNUTLS
|
2008-07-09 07:24:13 +00:00
|
|
|
prefs_register_string_preference(ssl_module, "keys_list", "RSA keys list",
|
2006-12-11 13:33:46 +00:00
|
|
|
"Semicolon-separated list of private RSA keys used for SSL decryption; "
|
|
|
|
"each list entry must be in the form of <ip>,<port>,<protocol>,<key_file_name>. "
|
|
|
|
"<key_file_name> is the local file name of the RSA private key used by the specified server "
|
|
|
|
"(or name of the file containing such a list)",
|
2006-08-02 08:15:51 +00:00
|
|
|
(const gchar **)&ssl_keys_list);
|
2006-02-13 17:06:41 +00:00
|
|
|
prefs_register_string_preference(ssl_module, "debug_file", "SSL debug file",
|
2008-07-09 07:24:13 +00:00
|
|
|
"Redirect SSL debug to file name; leave empty to disable debugging, "
|
|
|
|
"or use \"" SSL_DEBUG_USE_STDERR "\" to redirect output to stderr\n",
|
2006-08-02 08:15:51 +00:00
|
|
|
(const gchar **)&ssl_debug_file_name);
|
2006-06-29 07:31:52 +00:00
|
|
|
#endif
|
2002-01-04 07:01:54 +00:00
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2006-02-08 12:45:14 +00:00
|
|
|
register_dissector("ssl", dissect_ssl, proto_ssl);
|
2006-08-25 08:07:26 +00:00
|
|
|
ssl_handle = find_dissector("ssl");
|
|
|
|
|
|
|
|
ssl_associations = g_tree_new(ssl_association_cmp);
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-02-04 23:44:05 +00:00
|
|
|
register_init_routine(ssl_init);
|
|
|
|
ssl_lib_init();
|
2006-02-08 12:45:14 +00:00
|
|
|
ssl_tap = register_tap("ssl");
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_debug_printf("proto_register_ssl: registered tap %s:%d\n",
|
2006-02-08 12:45:14 +00:00
|
|
|
"ssl", ssl_tap);
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If this dissector uses sub-dissector registration add a registration
|
|
|
|
* routine. This format is required because a script is used to find
|
|
|
|
* these routines and create the code that calls these routines.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
proto_reg_handoff_ssl(void)
|
|
|
|
{
|
2006-08-07 19:52:18 +00:00
|
|
|
|
2006-08-25 08:07:26 +00:00
|
|
|
/* parse key list */
|
2006-02-04 23:44:05 +00:00
|
|
|
ssl_parse();
|
2001-07-11 18:19:16 +00:00
|
|
|
}
|
2006-06-27 13:36:10 +00:00
|
|
|
|
2006-08-25 08:07:26 +00:00
|
|
|
void
|
2006-08-29 08:33:52 +00:00
|
|
|
ssl_dissector_add(guint port, const gchar *protocol, gboolean tcp)
|
2006-08-25 08:07:26 +00:00
|
|
|
{
|
|
|
|
SslAssociation *assoc;
|
|
|
|
|
|
|
|
assoc = ssl_association_find(ssl_associations, port, tcp);
|
|
|
|
if (assoc) {
|
|
|
|
ssl_association_remove(ssl_associations, assoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
ssl_association_add(ssl_associations, ssl_handle, port, protocol, tcp, FALSE);
|
|
|
|
}
|
2006-08-28 07:05:02 +00:00
|
|
|
|
|
|
|
void
|
2006-08-29 08:33:52 +00:00
|
|
|
ssl_dissector_delete(guint port, const gchar *protocol, gboolean tcp)
|
2006-08-28 07:05:02 +00:00
|
|
|
{
|
|
|
|
SslAssociation *assoc;
|
|
|
|
|
|
|
|
assoc = ssl_association_find(ssl_associations, port, tcp);
|
|
|
|
if (assoc && (assoc->handle == find_dissector(protocol))) {
|
|
|
|
ssl_association_remove(ssl_associations, assoc);
|
|
|
|
}
|
|
|
|
}
|