QUIC: support CRYPTO_ERROR (draft -13)
authorPeter Wu <peter@lekensteyn.nl>
Wed, 19 Sep 2018 10:55:05 +0000 (12:55 +0200)
committerAnders Broman <a.broman58@gmail.com>
Sun, 23 Sep 2018 21:00:17 +0000 (21:00 +0000)
Append a corresponding TLS alert description if available.

Change-Id: Ief6f458f1c1e623cb7e0b0f57333b72890f48d91
Ping-Bug: 13881
Reviewed-on: https://code.wireshark.org/review/29740
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/dissectors/packet-quic.c

index 0353209617c9e2b1d83a68cf1b5d7d5559217327..e73375935fcba7c558089f4eef8b7e1a0b264042 100644 (file)
@@ -93,6 +93,7 @@ static int hf_quic_frame_type_rsts_stream_id = -1;
 static int hf_quic_frame_type_rsts_application_error_code = -1;
 static int hf_quic_frame_type_rsts_final_offset = -1;
 static int hf_quic_frame_type_cc_error_code = -1;
+static int hf_quic_frame_type_cc_error_code_tls_alert = -1;
 static int hf_quic_frame_type_cc_frame_type = -1;
 static int hf_quic_frame_type_cc_reason_phrase_length = -1;
 static int hf_quic_frame_type_cc_reason_phrase = -1;
@@ -401,6 +402,7 @@ static const range_string quic_transport_error_code_vals[] = {
     { 0x0009, 0x0009, "VERSION_NEGOTIATION_ERROR" },
     { 0x000A, 0x000A, "PROTOCOL_VIOLATION" },
     { 0x000C, 0x000C, "INVALID_MIGRATION" },
+    { 0x0100, 0x01FF, "CRYPTO_ERROR" },
     { 0, 0, NULL }
 };
 
@@ -928,10 +930,17 @@ dissect_quic_frame_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree
         case FT_CONNECTION_CLOSE:{
             guint32 len_reasonphrase, len_frametype, error_code;
             guint64 len_reason = 0;
+            const char *tls_alert = NULL;
 
             col_append_fstr(pinfo->cinfo, COL_INFO, ", CC");
 
             proto_tree_add_item_ret_uint(ft_tree, hf_quic_frame_type_cc_error_code, tvb, offset, 2, ENC_BIG_ENDIAN, &error_code);
+            if ((error_code & 0xff00) == 0x0100) {  // CRYPTO_ERROR
+                tls_alert = try_val_to_str(error_code & 0xff, ssl_31_alert_description);
+                if (tls_alert) {
+                    proto_tree_add_item(ft_tree, hf_quic_frame_type_cc_error_code_tls_alert, tvb, offset + 1, 1, ENC_BIG_ENDIAN);
+                }
+            }
             offset += 2;
 
             proto_tree_add_item_ret_varint(ft_tree, hf_quic_frame_type_cc_frame_type, tvb, offset, -1, ENC_VARINT_QUIC, NULL, &len_frametype);
@@ -944,6 +953,9 @@ dissect_quic_frame_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *quic_tree
             offset += (guint32)len_reason;
 
             proto_item_append_text(ti_ft, " Error code: %s", rval_to_str(error_code, quic_transport_error_code_vals, "Unknown (%d)"));
+            if (tls_alert) {
+                proto_item_append_text(ti_ft, " (%s)", tls_alert);
+            }
         }
         break;
         case FT_APPLICATION_CLOSE:{
@@ -2566,6 +2578,11 @@ proto_register_quic(void)
               FT_UINT16, BASE_DEC|BASE_RANGE_STRING, RVALS(quic_transport_error_code_vals), 0x0,
               "Indicates the reason for closing this connection", HFILL }
         },
+        { &hf_quic_frame_type_cc_error_code_tls_alert,
+            { "TLS Alert Description", "quic.frame_type.cc.error_code.tls_alert",
+              FT_UINT8, BASE_DEC, VALS(ssl_31_alert_description), 0x0,
+              NULL, HFILL }
+        },
         { &hf_quic_frame_type_cc_frame_type,
             { "Frame Type", "quic.frame_type.cc.frame_type",
               FT_UINT64, BASE_DEC, NULL, 0x0,