kex: split key selection and sending

This commit is contained in:
Aris Adamantiadis
2011-09-16 23:36:20 +02:00
parent 1b10b175fc
commit 07abc3406d
10 changed files with 118 additions and 88 deletions

View File

@@ -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_ */

View File

@@ -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);

View File

@@ -121,11 +121,6 @@ extern "C" {
#include <sys/time.h>
#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);

View File

@@ -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;