[hotssh] gssh: Export remote host key type string in addition to SHA1



commit bde2d2f7f358d2fabba1f9ed3693488220f19e12
Author: Colin Walters <walters verbum org>
Date:   Wed Dec 4 09:31:07 2013 -0500

    gssh: Export remote host key type string in addition to SHA1
    
    This is important to distinguish between different types of keys.

 libgssh/gssh-connection-private.h |    1 +
 libgssh/gssh-connection.c         |    8 ++++++--
 libgssh/gssh-connection.h         |   13 ++++++++++++-
 src/hotssh-tab.c                  |    6 +++++-
 4 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/libgssh/gssh-connection-private.h b/libgssh/gssh-connection-private.h
index 0b4ea62..6a0d7d3 100644
--- a/libgssh/gssh-connection-private.h
+++ b/libgssh/gssh-connection-private.h
@@ -46,6 +46,7 @@ struct _GSshConnection
   GHashTable *channels;
 
   GError *cached_error;
+  char *remote_hostkey_type;
   GBytes *remote_hostkey_sha1;
   GMainContext *maincontext;
   GSocketClient *socket_client;
diff --git a/libgssh/gssh-connection.c b/libgssh/gssh-connection.c
index 897c06c..52996af 100644
--- a/libgssh/gssh-connection.c
+++ b/libgssh/gssh-connection.c
@@ -365,6 +365,7 @@ set_hostkey_sha1 (GSshConnection           *self,
   g_assert (sha1len == sizeof (sha1buf));
 
   self->remote_hostkey_sha1 = g_bytes_new (sha1buf, sha1len);
+  self->remote_hostkey_type = g_strdup (ssh_key_type_to_char (ssh_key_type (key)));
 
   ret = TRUE;
  out:
@@ -737,14 +738,17 @@ gssh_connection_get_state (GSshConnection        *self)
 }
 
 /**
- * gssh_connection_preauth_get_fingerprint_sha1:
+ * gssh_connection_preauth_get_host_key_fingerprint_sha1:
  * @self: Self
+ * @out_key_type: (out): String representation of key type
  *
  * Returns: (transfer none): 20 bytes for the remote host's SHA1 fingerprint
  */
 GBytes *
-gssh_connection_preauth_get_fingerprint_sha1 (GSshConnection *self)
+gssh_connection_preauth_get_host_key_fingerprint_sha1 (GSshConnection          *self,
+                                                       char                   **out_key_type)
 {
+  *out_key_type = g_strdup (self->remote_hostkey_type);
   return self->remote_hostkey_sha1;
 }
 
diff --git a/libgssh/gssh-connection.h b/libgssh/gssh-connection.h
index a1cf69e..e5fdbda 100644
--- a/libgssh/gssh-connection.h
+++ b/libgssh/gssh-connection.h
@@ -72,7 +72,8 @@ gboolean                gssh_connection_handshake_finish (GSshConnection    *sel
 void                    gssh_connection_set_interaction (GSshConnection   *self,
                                                          GTlsInteraction  *interaction);
 
-GBytes *                gssh_connection_preauth_get_fingerprint_sha1 (GSshConnection *self);
+GBytes *                gssh_connection_preauth_get_host_key_fingerprint_sha1 (GSshConnection  *self,
+                                                                               char           
**out_key_type);
 
 void                    gssh_connection_negotiate_async (GSshConnection      *self,
                                                          GCancellable        *cancellable,
@@ -106,3 +107,13 @@ GSshChannel *         gssh_connection_open_shell_finish (GSshConnection
                                                              GAsyncResult             *result,
                                                              GError                  **error);
 
+void                    gssh_connection_exec_async (GSshConnection           *self,
+                                                    const char               *shell_string,
+                                                    GCancellable             *cancellable,
+                                                    GAsyncReadyCallback       callback,
+                                                    gpointer                  user_data);
+
+GSshChannel *         gssh_connection_exec_finish (GSshConnection         *self,
+                                                   GAsyncResult             *result,
+                                                   GError                  **error);
+
diff --git a/src/hotssh-tab.c b/src/hotssh-tab.c
index 5c3bffa..40c8d80 100644
--- a/src/hotssh-tab.c
+++ b/src/hotssh-tab.c
@@ -429,13 +429,15 @@ on_connection_handshake (GObject         *object,
   const guint8 *binbuf;
   gsize len;
   gs_free char *hostkey_sha1_text = NULL;
+  gs_free char *hostkey_type = NULL;
 
   if (!gssh_connection_handshake_finish ((GSshConnection*)object, result, error))
     goto out;
 
   g_debug ("handshake complete");
 
-  hostkey_sha1_binary = gssh_connection_preauth_get_fingerprint_sha1 (priv->connection);
+  hostkey_sha1_binary = gssh_connection_preauth_get_host_key_fingerprint_sha1 (priv->connection,
+                                                                               &hostkey_type);
   binbuf = g_bytes_get_data (hostkey_sha1_binary, &len);
   buf = g_string_new ("");
   for (i = 0; i < len; i++)
@@ -445,6 +447,8 @@ on_connection_handshake (GObject         *object,
        g_string_append_c (buf, ':');
     }
   hostkey_sha1_text = g_string_free (buf, FALSE);
+  
+  g_debug ("remote key type:%s SHA1:%s", hostkey_type, hostkey_sha1_text);
 
   gtk_label_set_text ((GtkLabel*)priv->hostkey_fingerprint_label,
                      hostkey_sha1_text);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]