[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] session: add getter for kexalgo
[Thread Prev] | [Thread Next]
- Subject: [PATCH] session: add getter for kexalgo
- From: Jon Simons <jon@xxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Wed, 15 Oct 2014 22:25:18 -0700
- To: libssh@xxxxxxxxxx
From 0df81df5420a0233fade2e9ef576ae187fc7d206 Mon Sep 17 00:00:00 2001
From: Jon Simons <jon@xxxxxxxxxxxxx>
Date: Wed, 15 Oct 2014 21:24:23 -0700
Subject: [PATCH] session: add getter for kexalgo
Signed-off-by: Jon Simons <jon@xxxxxxxxxxxxx>
---
include/libssh/libssh.h | 1 +
src/session.c | 29 +++++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index ba4f5f4..f4e4fe9 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -658,6 +658,7 @@ LIBSSH_API int ssh_event_remove_session(ssh_event event, ssh_session session);
LIBSSH_API void ssh_event_free(ssh_event event);
LIBSSH_API const char* ssh_get_clientbanner(ssh_session session);
LIBSSH_API const char* ssh_get_serverbanner(ssh_session session);
+LIBSSH_API const char* ssh_get_kex_algo(ssh_session session);
LIBSSH_API const char* ssh_get_cipher_in(ssh_session session);
LIBSSH_API const char* ssh_get_cipher_out(ssh_session session);
LIBSSH_API const char* ssh_get_hmac_in(ssh_session session);
diff --git a/src/session.c b/src/session.c
index a3b19ed..90206d4 100644
--- a/src/session.c
+++ b/src/session.c
@@ -315,6 +315,35 @@ const char* ssh_get_serverbanner(ssh_session session) {
}
/**
+ * @brief get the name of the current key exchange algorithm.
+ *
+ * @param[in] session The SSH session
+ *
+ * @return Returns the key exchange algorithm string or NULL.
+ */
+const char* ssh_get_kex_algo(ssh_session session) {
+ if ((session == NULL) ||
+ (session->current_crypto == NULL)) {
+ return NULL;
+ }
+
+ switch (session->current_crypto->kex_type) {
+ case SSH_KEX_DH_GROUP1_SHA1:
+ return "diffie-hellman-group1-sha1";
+ case SSH_KEX_DH_GROUP14_SHA1:
+ return "diffie-hellman-group14-sha1";
+ case SSH_KEX_ECDH_SHA2_NISTP256:
+ return "ecdh-sha2-nistp256";
+ case SSH_KEX_CURVE25519_SHA256_LIBSSH_ORG:
+ return "curve25519-sha256@xxxxxxxxxx";
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
+/**
* @brief get the name of the input cipher for the given session.
*
* @param[in] session The SSH session.
--
2.1.1.602.g02f248d
Archive administrator: postmaster@lists.cynapses.org