From 07abc3406df3b6b37471e10e495efb79003f5679 Mon Sep 17 00:00:00 2001 From: Aris Adamantiadis Date: Fri, 16 Sep 2011 23:36:20 +0200 Subject: kex: split key selection and sending --- include/libssh/ecdh.h | 3 +++ include/libssh/kex.h | 7 +++++++ include/libssh/priv.h | 11 ++++------- include/libssh/session.h | 4 ++++ 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'include/libssh') diff --git a/include/libssh/ecdh.h b/include/libssh/ecdh.h index 5cc208ce..e86bbe82 100644 --- a/include/libssh/ecdh.h +++ b/include/libssh/ecdh.h @@ -35,5 +35,8 @@ int ssh_client_ecdh_init(ssh_session session); int ssh_client_ecdh_reply(ssh_session session, ssh_buffer packet); +#ifdef WITH_SERVER +int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet); +#endif /* WITH_SERVER */ #endif /* ECDH_H_ */ diff --git a/include/libssh/kex.h b/include/libssh/kex.h index ce2a102b..dbf69ab9 100644 --- a/include/libssh/kex.h +++ b/include/libssh/kex.h @@ -25,6 +25,13 @@ #include "libssh/priv.h" #include "libssh/callbacks.h" +#define SSH_KEX_METHODS 10 + +typedef struct ssh_kex_struct { + unsigned char cookie[16]; + char *methods[SSH_KEX_METHODS]; +} KEX; + SSH_PACKET_CALLBACK(ssh_packet_kexinit); #ifdef WITH_SSH1 SSH_PACKET_CALLBACK(ssh_packet_publickey1); diff --git a/include/libssh/priv.h b/include/libssh/priv.h index aa22d10f..80175ece 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -121,11 +121,6 @@ extern "C" { #include #endif -typedef struct kex_struct { - unsigned char cookie[16]; - char **methods; -} KEX; - struct error_struct { /* error handling */ int error_code; @@ -137,6 +132,7 @@ struct error_struct { struct ssh_message_struct; struct ssh_common_struct; +struct ssh_kex_struct; /* server data */ @@ -197,8 +193,9 @@ void ssh_sock_set_blocking(socket_t sock); /* in kex.c */ extern const char *ssh_kex_nums[]; int ssh_send_kex(ssh_session session, int server_kex); -void ssh_list_kex(ssh_session session, KEX *kex); -int set_kex(ssh_session session); +void ssh_list_kex(ssh_session session, struct ssh_kex_struct *kex); +int set_client_kex(ssh_session session); +int ssh_kex_select_methods(ssh_session session); int verify_existing_algo(int algo, const char *name); char **space_tokenize(const char *chain); int ssh_get_kex1(ssh_session session); diff --git a/include/libssh/session.h b/include/libssh/session.h index a1b2a798..ac2ca76e 100644 --- a/include/libssh/session.h +++ b/include/libssh/session.h @@ -27,6 +27,7 @@ #include "libssh/auth.h" #include "libssh/channels.h" #include "libssh/poll.h" +#include "libssh/kex.h" /* These are the different states a SSH session can be into its life */ enum ssh_session_state_e { @@ -122,8 +123,11 @@ struct ssh_session_struct { struct ssh_agent_state_struct *agent_state; struct ssh_auth_auto_state_struct *auth_auto_state; + /* kex sent by server, client, and mutually elected methods */ KEX server_kex; KEX client_kex; + char *kex_methods[SSH_KEX_METHODS]; + ssh_buffer in_hashbuf; ssh_buffer out_hashbuf; struct ssh_crypto_struct *current_crypto; -- cgit v1.2.3