summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-07-25 17:52:00 +0200
committerAndreas Schneider <mail@cynapses.org>2009-07-25 17:52:00 +0200
commit3f778d9a3172ae49ef2f1862c544e65dd3dc2b8d (patch)
treebf30f5512fd324381ddef4e9288bd384c00fb089
parenta935ad1857b91b6aa179d14137f520d978647341 (diff)
downloadlibssh-3f778d9a3172ae49ef2f1862c544e65dd3dc2b8d.tar.gz
libssh-3f778d9a3172ae49ef2f1862c544e65dd3dc2b8d.tar.xz
libssh-3f778d9a3172ae49ef2f1862c544e65dd3dc2b8d.zip
Add ssh_clean_pubkey_hash() which is needed on Windows.
-rw-r--r--include/libssh/libssh.h1
-rw-r--r--libssh/dh.c16
2 files changed, 17 insertions, 0 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 76ede946..699fe28e 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -245,6 +245,7 @@ int ssh_get_random(void *where,int len,int strong);
/* this one can be called by the client to see the hash of the public key before accepting it */
int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash);
+void ssh_clean_pubkey_hash(unsigned char **hash);
ssh_string ssh_get_pubkey(SSH_SESSION *session);
/* in connect.c */
diff --git a/libssh/dh.c b/libssh/dh.c
index 0edd19da..26bcbc7a 100644
--- a/libssh/dh.c
+++ b/libssh/dh.c
@@ -847,6 +847,22 @@ int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) {
return MD5_DIGEST_LEN;
}
+/** \addtogroup ssh_session
+ * @{ */
+/**
+ * @brief Deallocate the hash obtained by ssh_get_pubkey_hash.
+ * This is required under Microsoft platform as this library might use a
+ * different C library than your software, hence a different heap.
+ *
+ * @param hash The buffer to deallocate.
+ *
+ * @see ssh_get_pubkey_hash()
+ */
+void ssh_clean_pubkey_hash(unsigned char **hash) {
+ SAFE_FREE(*hash);
+ *hash = NULL;
+}
+
ssh_string ssh_get_pubkey(SSH_SESSION *session){
return string_copy(session->current_crypto->server_pubkey);
}