aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libssh/crypto.h23
-rw-r--r--include/libssh/libssh.h2
-rw-r--r--include/libssh/messages.h84
-rw-r--r--include/libssh/packet.h7
-rw-r--r--include/libssh/priv.h94
-rw-r--r--include/libssh/session.h3
-rw-r--r--libssh/auth.c9
-rw-r--r--libssh/channels.c1
-rw-r--r--libssh/keys.c1
-rw-r--r--libssh/messages.c1
-rw-r--r--libssh/packet.c1
-rw-r--r--libssh/server.c1
12 files changed, 131 insertions, 96 deletions
diff --git a/include/libssh/crypto.h b/include/libssh/crypto.h
index 33d0114..d838f24 100644
--- a/include/libssh/crypto.h
+++ b/include/libssh/crypto.h
@@ -37,6 +37,29 @@
#ifdef HAVE_LIBGCRYPT
#include <gcrypt.h>
#endif
+#include "libssh/wrapper.h"
+
+struct ssh_crypto_struct {
+ bignum e,f,x,k,y;
+ unsigned char session_id[SHA_DIGEST_LEN];
+
+ unsigned char encryptIV[SHA_DIGEST_LEN*2];
+ unsigned char decryptIV[SHA_DIGEST_LEN*2];
+
+ unsigned char decryptkey[SHA_DIGEST_LEN*2];
+ unsigned char encryptkey[SHA_DIGEST_LEN*2];
+
+ unsigned char encryptMAC[SHA_DIGEST_LEN];
+ unsigned char decryptMAC[SHA_DIGEST_LEN];
+ unsigned char hmacbuf[EVP_MAX_MD_SIZE];
+ struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
+ ssh_string server_pubkey;
+ const char *server_pubkey_type;
+ int do_compress_out; /* idem */
+ int do_compress_in; /* don't set them, set the option instead */
+ void *compress_out_ctx; /* don't touch it */
+ void *compress_in_ctx; /* really, don't */
+};
struct crypto_struct {
const char *name; /* ssh name of the algorithm */
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h
index 721b613..8f7029c 100644
--- a/include/libssh/libssh.h
+++ b/include/libssh/libssh.h
@@ -107,7 +107,6 @@ typedef struct ssh_channel_struct CHANNEL;
typedef struct ssh_agent_struct AGENT;
#endif
-typedef struct ssh_kbdint_struct SSH_KBDINT;
typedef struct ssh_message_struct SSH_MESSAGE;
typedef struct ssh_options_struct SSH_OPTIONS;
typedef struct ssh_session_struct SSH_SESSION;
@@ -115,7 +114,6 @@ typedef struct ssh_session_struct SSH_SESSION;
typedef struct ssh_agent_struct* ssh_agent;
typedef struct ssh_buffer_struct* ssh_buffer;
typedef struct ssh_channel_struct* ssh_channel;
-typedef struct ssh_kbdint_struct* ssh_kbdint;
typedef struct ssh_message_struct *ssh_message;
typedef struct ssh_options_struct* ssh_options;
typedef struct ssh_private_key_struct* ssh_private_key;
diff --git a/include/libssh/messages.h b/include/libssh/messages.h
new file mode 100644
index 0000000..0eb7b64
--- /dev/null
+++ b/include/libssh/messages.h
@@ -0,0 +1,84 @@
+/*
+ * This file is part of the SSH Library
+ *
+ * Copyright (c) 2009 by Aris Adamantiadis
+ *
+ * The SSH Library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or (at your
+ * option) any later version.
+ *
+ * The SSH Library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with the SSH Library; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ */
+
+#ifndef MESSAGES_H_
+#define MESSAGES_H_
+
+#include "config.h"
+
+struct ssh_auth_request {
+ char *username;
+ int method;
+ char *password;
+ struct ssh_public_key_struct *public_key;
+ char signature_state;
+};
+
+struct ssh_channel_request_open {
+ int type;
+ uint32_t sender;
+ uint32_t window;
+ uint32_t packet_size;
+ char *originator;
+ uint16_t originator_port;
+ char *destination;
+ uint16_t destination_port;
+};
+
+struct ssh_service_request {
+ char *service;
+};
+
+struct ssh_channel_request {
+ int type;
+ ssh_channel channel;
+ uint8_t want_reply;
+ /* pty-req type specifics */
+ char *TERM;
+ uint32_t width;
+ uint32_t height;
+ uint32_t pxwidth;
+ uint32_t pxheight;
+ ssh_string modes;
+
+ /* env type request */
+ char *var_name;
+ char *var_value;
+ /* exec type request */
+ char *command;
+ /* subsystem */
+ char *subsystem;
+};
+
+struct ssh_message_struct {
+ ssh_session session;
+ int type;
+ struct ssh_auth_request auth_request;
+ struct ssh_channel_request_open channel_request_open;
+ struct ssh_channel_request channel_request;
+ struct ssh_service_request service_request;
+};
+
+
+void message_handle(ssh_session session, uint32_t type);
+int ssh_execute_message_callbacks(ssh_session session);
+
+#endif /* MESSAGES_H_ */
diff --git a/include/libssh/packet.h b/include/libssh/packet.h
index b06221d..155f304 100644
--- a/include/libssh/packet.h
+++ b/include/libssh/packet.h
@@ -22,6 +22,13 @@
#ifndef PACKET_H_
#define PACKET_H_
+/* this structure should go someday */
+typedef struct packet_struct {
+ int valid;
+ uint32_t len;
+ uint8_t type;
+} PACKET;
+
void packet_parse(ssh_session session);
int packet_send(ssh_session session);
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index bfe355e..a9da5a5 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -70,13 +70,6 @@ extern "C" {
#include <sys/time.h>
#endif
-/* i should remove it one day */
-typedef struct packet_struct {
- int valid;
- uint32_t len;
- uint8_t type;
-} PACKET;
-
typedef struct kex_struct {
unsigned char cookie[16];
char **methods;
@@ -91,28 +84,6 @@ struct error_struct {
/* TODO: remove that include */
#include "libssh/wrapper.h"
-struct ssh_crypto_struct {
- bignum e,f,x,k,y;
- unsigned char session_id[SHA_DIGEST_LEN];
-
- unsigned char encryptIV[SHA_DIGEST_LEN*2];
- unsigned char decryptIV[SHA_DIGEST_LEN*2];
-
- unsigned char decryptkey[SHA_DIGEST_LEN*2];
- unsigned char encryptkey[SHA_DIGEST_LEN*2];
-
- unsigned char encryptMAC[SHA_DIGEST_LEN];
- unsigned char decryptMAC[SHA_DIGEST_LEN];
- unsigned char hmacbuf[EVP_MAX_MD_SIZE];
- struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
- ssh_string server_pubkey;
- const char *server_pubkey_type;
- int do_compress_out; /* idem */
- int do_compress_in; /* don't set them, set the option instead */
- void *compress_out_ctx; /* don't touch it */
- void *compress_in_ctx; /* really, don't */
-};
-
struct ssh_keys_struct {
const char *privatekey;
const char *publickey;
@@ -120,14 +91,6 @@ struct ssh_keys_struct {
struct ssh_message_struct;
-struct ssh_kbdint_struct {
- uint32_t nprompts;
- char *name;
- char *instruction;
- char **prompts;
- unsigned char *echo; /* bool array */
- char **answers;
-};
/* server data */
@@ -139,58 +102,6 @@ struct ssh_bind_struct {
int toaccept;
};
-struct ssh_auth_request {
- char *username;
- int method;
- char *password;
- struct ssh_public_key_struct *public_key;
- char signature_state;
-};
-
-struct ssh_channel_request_open {
- int type;
- uint32_t sender;
- uint32_t window;
- uint32_t packet_size;
- char *originator;
- uint16_t originator_port;
- char *destination;
- uint16_t destination_port;
-};
-
-struct ssh_service_request {
- char *service;
-};
-
-struct ssh_channel_request {
- int type;
- ssh_channel channel;
- uint8_t want_reply;
- /* pty-req type specifics */
- char *TERM;
- uint32_t width;
- uint32_t height;
- uint32_t pxwidth;
- uint32_t pxheight;
- ssh_string modes;
-
- /* env type request */
- char *var_name;
- char *var_value;
- /* exec type request */
- char *command;
- /* subsystem */
- char *subsystem;
-};
-
-struct ssh_message_struct {
- ssh_session session;
- int type;
- struct ssh_auth_request auth_request;
- struct ssh_channel_request_open channel_request_open;
- struct ssh_channel_request channel_request;
- struct ssh_service_request service_request;
-};
/* client.c */
@@ -259,11 +170,6 @@ int channel_write1(ssh_channel channel, const void *data, int len);
/* match.c */
int match_hostname(const char *host, const char *pattern, unsigned int len);
-/* messages.c */
-
-void message_handle(ssh_session session, uint32_t type);
-int ssh_execute_message_callbacks(ssh_session session);
-
/* log.c */
#ifndef __FUNCTION__
diff --git a/include/libssh/session.h b/include/libssh/session.h
index 7eecb69..d7bbfcf 100644
--- a/include/libssh/session.h
+++ b/include/libssh/session.h
@@ -22,6 +22,9 @@
#ifndef SESSION_H_
#define SESSION_H_
#include "libssh/priv.h"
+#include "libssh/packet.h"
+
+typedef struct ssh_kbdint_struct* ssh_kbdint;
struct ssh_session_struct {
struct error_struct error;
diff --git a/libssh/auth.c b/libssh/auth.c
index 3b64e0f..d7fd3fa 100644
--- a/libssh/auth.c
+++ b/libssh/auth.c
@@ -1018,6 +1018,15 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) {
return SSH_AUTH_DENIED;
}
+struct ssh_kbdint_struct {
+ uint32_t nprompts;
+ char *name;
+ char *instruction;
+ char **prompts;
+ unsigned char *echo; /* bool array */
+ char **answers;
+};
+
static ssh_kbdint kbdint_new(void) {
ssh_kbdint kbd;
diff --git a/libssh/channels.c b/libssh/channels.c
index 1f2c64c..6f1e3ee 100644
--- a/libssh/channels.c
+++ b/libssh/channels.c
@@ -40,6 +40,7 @@
#include "libssh/channels.h"
#include "libssh/session.h"
#include "libssh/misc.h"
+#include "libssh/messages.h"
#define WINDOWBASE 128000
#define WINDOWLIMIT (WINDOWBASE/2)
diff --git a/libssh/keys.c b/libssh/keys.c
index 4908608..d6bb8de 100644
--- a/libssh/keys.c
+++ b/libssh/keys.c
@@ -35,6 +35,7 @@
#include "libssh/session.h"
#include "libssh/keys.h"
#include "libssh/dh.h"
+#include "libssh/messages.h"
/** \addtogroup ssh_auth
* @{
diff --git a/libssh/messages.c b/libssh/messages.c
index 1540dd6..ab4457c 100644
--- a/libssh/messages.c
+++ b/libssh/messages.c
@@ -49,6 +49,7 @@
#include "libssh/misc.h"
#include "libssh/keys.h"
#include "libssh/dh.h"
+#include "libssh/messages.h"
static ssh_message message_new(ssh_session session){
ssh_message msg = malloc(sizeof(struct ssh_message_struct));
diff --git a/libssh/packet.c b/libssh/packet.c
index 7e25479..00b09ff 100644
--- a/libssh/packet.c
+++ b/libssh/packet.c
@@ -41,6 +41,7 @@
#include "libssh/socket.h"
#include "libssh/channels.h"
#include "libssh/session.h"
+#include "libssh/messages.h"
/* XXX include selected mac size */
static int macsize=SHA_DIGEST_LEN;
diff --git a/libssh/server.c b/libssh/server.c
index ebd5dc2..703a24f 100644
--- a/libssh/server.c
+++ b/libssh/server.c
@@ -49,6 +49,7 @@
#include "libssh/misc.h"
#include "libssh/keys.h"
#include "libssh/dh.h"
+#include "libssh/messages.h"
#ifdef _WIN32