From 6529b36c548b4a9de4e5b5b9e49e236d885a5907 Mon Sep 17 00:00:00 2001 From: Alexis La Goutte Date: Thu, 29 Sep 2016 10:17:07 +0200 Subject: [PATCH] TLS(1.3): Add cookie (44) hello extension Ping-Bug: 12779 Change-Id: I94d492d126050fdff6f98608f9d68d55c19e0a50 Reviewed-on: https://code.wireshark.org/review/18092 Petri-Dish: Anders Broman Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/dissectors/packet-ssl-utils.c | 23 +++++++++++++++++++++++ epan/dissectors/packet-ssl-utils.h | 14 +++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c index a088b164b5..7aafa99fd7 100644 --- a/epan/dissectors/packet-ssl-utils.c +++ b/epan/dissectors/packet-ssl-utils.c @@ -5632,6 +5632,26 @@ ssl_dissect_hnd_hello_ext_early_data(ssl_common_dissect_t *hf, tvbuff_t *tvb, return offset; } +static gint +ssl_dissect_hnd_hello_ext_cookie(ssl_common_dissect_t *hf, tvbuff_t *tvb, + proto_tree *tree, guint32 offset, guint32 ext_len) +{ + + if (ext_len < 2) { + return offset; + } + + proto_tree_add_item(tree, hf->hf.hs_ext_cookie_len, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; + ext_len -= 2; + + proto_tree_add_item(tree, hf->hf.hs_ext_cookie, tvb, offset, ext_len, ENC_NA); + offset += ext_len; + + return offset; +} + + static gint ssl_dissect_hnd_hello_ext_server_name(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree, guint32 offset, guint32 ext_len) @@ -6754,6 +6774,9 @@ ssl_dissect_hnd_hello_ext(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *t case SSL_HND_HELLO_EXT_EARLY_DATA: offset = ssl_dissect_hnd_hello_ext_early_data(hf, tvb, ext_tree, offset, ext_len, hnd_type); break; + case SSL_HND_HELLO_EXT_COOKIE: + offset = ssl_dissect_hnd_hello_ext_cookie(hf, tvb, ext_tree, offset, ext_len); + break; case SSL_HND_HELLO_EXT_DRAFT_VERSION_TLS13: proto_tree_add_item(ext_tree, hf->hf.hs_ext_draft_version_tls13, tvb, offset, 2, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-ssl-utils.h b/epan/dissectors/packet-ssl-utils.h index 6e588ea6fb..1e589a137c 100644 --- a/epan/dissectors/packet-ssl-utils.h +++ b/epan/dissectors/packet-ssl-utils.h @@ -681,6 +681,8 @@ typedef struct ssl_common_dissect { gint hs_ext_psk_identity; gint hs_ext_psk_identity_selected; gint hs_ext_early_data_obfuscated_ticket_age; + gint hs_ext_cookie_len; + gint hs_ext_cookie; gint hs_ext_server_name; gint hs_ext_server_name_len; gint hs_ext_server_name_list_len; @@ -879,7 +881,7 @@ ssl_common_dissect_t name = { \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ - -1, \ + -1, -1, -1, \ }, \ /* ett */ { \ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, \ @@ -1048,6 +1050,16 @@ ssl_common_dissect_t name = { \ FT_UINT32, BASE_DEC, NULL, 0x0, \ "The time since the client learned about the server configuration that it is using, in milliseconds", HFILL } \ }, \ + { & name .hf.hs_ext_cookie_len, \ + { "Cookie length", prefix ".handshake.extensions.cookie_len", \ + FT_UINT16, BASE_DEC, NULL, 0x0, \ + NULL, HFILL } \ + }, \ + { & name .hf.hs_ext_cookie, \ + { "Cookie", prefix ".handshake.extensions.cookie", \ + FT_BYTES, BASE_NONE, NULL, 0x0, \ + NULL, HFILL } \ + }, \ { & name .hf.hs_ext_server_name_list_len, \ { "Server Name list length", prefix ".handshake.extensions_server_name_list_len", \ FT_UINT16, BASE_DEC, NULL, 0x0, \