TLS(1.3): Add PSK Key Exchanges Modes (45) hello extension
authorAlexis La Goutte <alexis.lagoutte@gmail.com>
Sat, 12 Nov 2016 16:04:14 +0000 (17:04 +0100)
committerAnders Broman <a.broman58@gmail.com>
Sat, 31 Dec 2016 07:36:57 +0000 (07:36 +0000)
Ping-Bug: 12779
Change-Id: Ie797a437240e5530d74e3039f12a60a6f0395d0a
Reviewed-on: https://code.wireshark.org/review/18916
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/dissectors/packet-ssl-utils.c
epan/dissectors/packet-ssl-utils.h

index 32984f208acf982c73dce3f0c02cff72023b76b6..04a0c3ed37079e75bf1de8988e3585dfc9b8f2fd 100644 (file)
@@ -1172,6 +1172,7 @@ const value_string tls_hello_extension_types[] = {
     { SSL_HND_HELLO_EXT_EARLY_DATA, "early_data" }, /* TLS 1.3 https://tools.ietf.org/html/draft-ietf-tls-tls13 */
     { SSL_HND_HELLO_EXT_SUPPORTED_VERSIONS, "supported_versions" }, /* TLS 1.3 https://tools.ietf.org/html/draft-ietf-tls-tls13 */
     { SSL_HND_HELLO_EXT_COOKIE, "cookie" }, /* TLS 1.3 https://tools.ietf.org/html/draft-ietf-tls-tls13 */
+    { SSL_HND_HELLO_EXT_PSK_KEY_EXCHANGE_MODES, "psk_key_exchange_modes" }, /* TLS 1.3 https://tools.ietf.org/html/draft-ietf-tls-tls13 */
     { SSL_HND_HELLO_EXT_NPN, "next_protocol_negotiation"}, /* https://tools.ietf.org/id/draft-agl-tls-nextprotoneg-03.html */
     { SSL_HND_HELLO_EXT_CHANNEL_ID_OLD, "channel_id_old" }, /* http://tools.ietf.org/html/draft-balfanz-tls-channelid-00
        https://twitter.com/ericlaw/status/274237352531083264 */
@@ -1187,7 +1188,7 @@ const value_string tls_hello_ext_server_name_type_vs[] = {
     { 0, NULL }
 };
 
-/* draft-ietf-tls-tls13-15 4.2.5 */
+/* draft-ietf-tls-tls13-18 4.2.7 */
 const value_string tls_hello_ext_psk_ke_mode[] = {
     { 0, "PSK-only key establishment (psk_ke)" },
     { 1, "PSK key establishment with (EC)DHE key establishment (psk_dhe_ke)" },
@@ -5692,6 +5693,40 @@ ssl_dissect_hnd_hello_ext_cookie(ssl_common_dissect_t *hf, tvbuff_t *tvb,
     return offset;
 }
 
+static gint
+ssl_dissect_hnd_hello_ext_psk_key_exchange_modes(ssl_common_dissect_t *hf, tvbuff_t *tvb,
+                                                 proto_tree *tree, guint32 offset, guint32 ext_len)
+{
+    /*
+     * enum { psk_ke(0), psk_dhe_ke(1), (255) } PskKeyExchangeMode;
+     *
+     * struct {
+     *     PskKeyExchangeMode ke_modes<1..255>;
+     * } PskKeyExchangeModes;
+     */
+    guint32 offset_end = offset + ext_len;
+    guint32 ke_modes_length, i;
+
+    if (ext_len < 1) {
+        /* XXX expert info, there must be at least 1 ke mode */
+        return offset;
+    }
+
+    proto_tree_add_item_ret_uint(tree, hf->hf.hs_ext_psk_ke_modes_len, tvb, offset, 1, ENC_NA, &ke_modes_length);
+    offset += 1;
+
+    if (ke_modes_length > offset_end - offset) {
+        ke_modes_length = offset_end - offset;
+        /* XXX expert info: size too large */
+    }
+
+    for (i = 0; i < ke_modes_length; i++) {
+        proto_tree_add_item(tree, hf->hf.hs_ext_psk_ke_mode, tvb, offset, 1, ENC_NA);
+        offset += 1;
+    }
+
+    return offset;
+}
 
 static gint
 ssl_dissect_hnd_hello_ext_server_name(ssl_common_dissect_t *hf, tvbuff_t *tvb,
@@ -6852,6 +6887,9 @@ ssl_dissect_hnd_hello_ext(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *t
         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_PSK_KEY_EXCHANGE_MODES:
+            offset = ssl_dissect_hnd_hello_ext_psk_key_exchange_modes(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);
index 28d197a20bdff84ee32474800ce89c8f18ba7bb1..c1808ed90dd4ae29a595266e6236da2418b99051 100644 (file)
@@ -171,6 +171,7 @@ typedef enum {
 #define SSL_HND_HELLO_EXT_EARLY_DATA                    42
 #define SSL_HND_HELLO_EXT_SUPPORTED_VERSIONS            43
 #define SSL_HND_HELLO_EXT_COOKIE                        44
+#define SSL_HND_HELLO_EXT_PSK_KEY_EXCHANGE_MODES        45
 #define SSL_HND_HELLO_EXT_NPN                           13172 /* 0x3374 */
 #define SSL_HND_HELLO_EXT_CHANNEL_ID_OLD                30031 /* 0x754f */
 #define SSL_HND_HELLO_EXT_CHANNEL_ID                    30032 /* 0x7550 */
@@ -761,6 +762,8 @@ typedef struct ssl_common_dissect {
 
         /* TLS 1.3 */
         gint hs_ext_draft_version_tls13;
+        gint hs_ext_psk_ke_modes_len;
+        gint hs_ext_psk_ke_mode;
 
         /* do not forget to update SSL_COMMON_LIST_T and SSL_COMMON_HF_LIST! */
     } hf;
@@ -896,7 +899,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, -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, \
@@ -1500,6 +1503,16 @@ ssl_common_dissect_t name = {   \
       { "Draft version of TLS 1.3", prefix ".extension.draft_version_tls13", \
         FT_UINT16, BASE_DEC, NULL, 0x0,                                 \
         "Indicate the version of draft supported by client", HFILL }    \
+    },                                                                  \
+    { & name .hf.hs_ext_psk_ke_modes_len,                                   \
+      { "PSK Key Exchange Modes Length", prefix ".handshake.psk_ke_modes_len", \
+        FT_UINT8, BASE_DEC, NULL, 0x0,                                  \
+        NULL, HFILL }                                                   \
+    },                                                                  \
+    { & name .hf.hs_ext_psk_ke_mode,                                    \
+      { "PSK Key Exchange Mode", prefix ".handshake.psk_ke_mode",       \
+        FT_UINT8, BASE_DEC, VALS(tls_hello_ext_psk_ke_mode), 0x0,       \
+        "Key exchange modes where the client supports use of PSKs", HFILL } \
     }
 /* }}} */