ssh: add RSA host key printing
authorKenny Root <kenny@the-b.org>
Thu, 16 Jun 2016 07:12:53 +0000 (00:12 -0700)
committerAnders Broman <a.broman58@gmail.com>
Fri, 17 Jun 2016 17:27:50 +0000 (17:27 +0000)
Adds a dissector for the ssh-rsa type of public key where the modulus
and public exponent are extracted out.

Change-Id: I10b1f2d6f41878d9f7ffe5d399b9b7d4f69ad96e
Reviewed-on: https://code.wireshark.org/review/15975
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/dissectors/packet-ssh.c

index 08bad96b129e5f77ac7c4e9826014ff1359d3361..940f7aeb9dea4889b71a2bf17969b69751a3d27f 100644 (file)
@@ -142,6 +142,8 @@ static int hf_ssh_kexdh_host_key= -1;
 static int hf_ssh_hostkey_length= -1;
 static int hf_ssh_hostkey_type= -1;
 static int hf_ssh_hostkey_data= -1;
+static int hf_ssh_hostkey_rsa_n= -1;
+static int hf_ssh_hostkey_rsa_e= -1;
 static int hf_ssh_kexdh_h_sig= -1;
 static int hf_ssh_kexdh_h_sig_length= -1;
 static int hf_ssh_kex_algorithms = -1;
@@ -647,9 +649,14 @@ ssh_tree_add_hostkey(tvbuff_t *tvb, int offset, proto_tree *parent_tree, const c
     proto_tree_add_string(tree, hf_ssh_hostkey_type, tvb, offset, type_len, key_type);
     offset += type_len;
 
-    remaining_len = key_len - (type_len + 4);
-    proto_tree_add_item(tree, hf_ssh_hostkey_data, tvb, offset, remaining_len, ENC_NA);
-    offset += remaining_len;
+    if (0 == strcmp(key_type, "ssh-rsa")) {
+        offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_rsa_e);
+        offset += ssh_tree_add_mpint(tvb, offset, tree, hf_ssh_hostkey_rsa_n);
+    } else {
+        remaining_len = key_len - (type_len + 4);
+        proto_tree_add_item(tree, hf_ssh_hostkey_data, tvb, offset, remaining_len, ENC_NA);
+        offset += remaining_len;
+    }
 
     return 4+key_len;
 }
@@ -1259,6 +1266,16 @@ proto_register_ssh(void)
             FT_BYTES, BASE_NONE, NULL, 0x0,
             NULL, HFILL }},
 
+        { &hf_ssh_hostkey_rsa_n,
+          { "RSA modulus (N)",         "ssh.host_key.rsa.n",
+            FT_BYTES, BASE_NONE, NULL, 0x0,
+            NULL, HFILL }},
+
+        { &hf_ssh_hostkey_rsa_e,
+          { "RSA public exponent (e)",         "ssh.host_key.rsa.e",
+            FT_BYTES, BASE_NONE, NULL, 0x0,
+            NULL, HFILL }},
+
         { &hf_ssh_kexdh_h_sig_length,
           { "KEX DH H signature length",         "ssh.kexdh.h_sig_length",
             FT_UINT32, BASE_DEC, NULL, 0x0,