Moved lots of declaration out of priv.h
Этот коммит содержится в:
родитель
b359229a2e
Коммит
f84ebc2e27
@ -1,6 +1,8 @@
|
|||||||
#ifndef __AGENT_H
|
#ifndef __AGENT_H
|
||||||
#define __AGENT_H
|
#define __AGENT_H
|
||||||
|
|
||||||
|
#include "libssh/libssh.h"
|
||||||
|
|
||||||
/* Messages for the authentication agent connection. */
|
/* Messages for the authentication agent connection. */
|
||||||
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
|
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
|
||||||
#define SSH_AGENT_RSA_IDENTITIES_ANSWER 2
|
#define SSH_AGENT_RSA_IDENTITIES_ANSWER 2
|
||||||
@ -45,5 +47,51 @@
|
|||||||
|
|
||||||
#define SSH_AGENT_OLD_SIGNATURE 0x01
|
#define SSH_AGENT_OLD_SIGNATURE 0x01
|
||||||
|
|
||||||
|
struct ssh_agent_struct {
|
||||||
|
struct socket *sock;
|
||||||
|
ssh_buffer ident;
|
||||||
|
unsigned int count;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
/* agent.c */
|
||||||
|
/**
|
||||||
|
* @brief Create a new ssh agent structure.
|
||||||
|
*
|
||||||
|
* @return An allocated ssh agent structure or NULL on error.
|
||||||
|
*/
|
||||||
|
struct ssh_agent_struct *agent_new(struct ssh_session_struct *session);
|
||||||
|
|
||||||
|
void agent_close(struct ssh_agent_struct *agent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Free an allocated ssh agent structure.
|
||||||
|
*
|
||||||
|
* @param agent The ssh agent structure to free.
|
||||||
|
*/
|
||||||
|
void agent_free(struct ssh_agent_struct *agent);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Check if the ssh agent is running.
|
||||||
|
*
|
||||||
|
* @param session The ssh session to check for the agent.
|
||||||
|
*
|
||||||
|
* @return 1 if it is running, 0 if not.
|
||||||
|
*/
|
||||||
|
int agent_is_running(struct ssh_session_struct *session);
|
||||||
|
|
||||||
|
int agent_get_ident_count(struct ssh_session_struct *session);
|
||||||
|
|
||||||
|
struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session_struct *session,
|
||||||
|
char **comment);
|
||||||
|
|
||||||
|
struct ssh_public_key_struct *agent_get_first_ident(struct ssh_session_struct *session,
|
||||||
|
char **comment);
|
||||||
|
|
||||||
|
ssh_string agent_sign_data(struct ssh_session_struct *session,
|
||||||
|
struct ssh_buffer_struct *data,
|
||||||
|
struct ssh_public_key_struct *pubkey);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __AGENT_H */
|
#endif /* __AGENT_H */
|
||||||
/* vim: set ts=2 sw=2 et cindent: */
|
/* vim: set ts=2 sw=2 et cindent: */
|
||||||
|
62
include/libssh/buffer.h
Обычный файл
62
include/libssh/buffer.h
Обычный файл
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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 BUFFER_H_
|
||||||
|
#define BUFFER_H_
|
||||||
|
|
||||||
|
/** Describes a buffer state at a moment
|
||||||
|
*/
|
||||||
|
struct ssh_buffer_struct {
|
||||||
|
char *data;
|
||||||
|
uint32_t used;
|
||||||
|
uint32_t allocated;
|
||||||
|
uint32_t pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
|
||||||
|
int buffer_add_u8(ssh_buffer buffer, uint8_t data);
|
||||||
|
int buffer_add_u32(ssh_buffer buffer, uint32_t data);
|
||||||
|
int buffer_add_u64(ssh_buffer buffer, uint64_t data);
|
||||||
|
int buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
|
||||||
|
int buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
|
||||||
|
int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
|
||||||
|
int buffer_reinit(ssh_buffer buffer);
|
||||||
|
|
||||||
|
/* buffer_get_rest returns a pointer to the current position into the buffer */
|
||||||
|
void *buffer_get_rest(ssh_buffer buffer);
|
||||||
|
/* buffer_get_rest_len returns the number of bytes which can be read */
|
||||||
|
uint32_t buffer_get_rest_len(ssh_buffer buffer);
|
||||||
|
|
||||||
|
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
|
||||||
|
int buffer_get_u8(ssh_buffer buffer, uint8_t *data);
|
||||||
|
int buffer_get_u32(ssh_buffer buffer, uint32_t *data);
|
||||||
|
int buffer_get_u64(ssh_buffer buffer, uint64_t *data);
|
||||||
|
|
||||||
|
uint32_t buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
|
||||||
|
/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
|
||||||
|
ssh_string buffer_get_ssh_string(ssh_buffer buffer);
|
||||||
|
/* gets a string out of a SSH-1 mpint */
|
||||||
|
ssh_string buffer_get_mpint(ssh_buffer buffer);
|
||||||
|
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
|
||||||
|
uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
|
||||||
|
uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
|
||||||
|
|
||||||
|
#endif /* BUFFER_H_ */
|
58
include/libssh/channels.h
Обычный файл
58
include/libssh/channels.h
Обычный файл
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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 CHANNELS_H_
|
||||||
|
#define CHANNELS_H_
|
||||||
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
struct ssh_channel_struct {
|
||||||
|
struct ssh_channel_struct *prev;
|
||||||
|
struct ssh_channel_struct *next;
|
||||||
|
ssh_session session; /* SSH_SESSION pointer */
|
||||||
|
uint32_t local_channel;
|
||||||
|
uint32_t local_window;
|
||||||
|
int local_eof;
|
||||||
|
uint32_t local_maxpacket;
|
||||||
|
|
||||||
|
uint32_t remote_channel;
|
||||||
|
uint32_t remote_window;
|
||||||
|
int remote_eof; /* end of file received */
|
||||||
|
uint32_t remote_maxpacket;
|
||||||
|
int open; /* shows if the channel is still opened */
|
||||||
|
int delayed_close;
|
||||||
|
ssh_buffer stdout_buffer;
|
||||||
|
ssh_buffer stderr_buffer;
|
||||||
|
void *userarg;
|
||||||
|
int version;
|
||||||
|
int blocking;
|
||||||
|
int exit_status;
|
||||||
|
};
|
||||||
|
|
||||||
|
void channel_handle(ssh_session session, int type);
|
||||||
|
ssh_channel channel_new(ssh_session session);
|
||||||
|
int channel_default_bufferize(ssh_channel channel, void *data, int len,
|
||||||
|
int is_stderr);
|
||||||
|
uint32_t ssh_channel_new_id(ssh_session session);
|
||||||
|
ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
|
||||||
|
int channel_write_common(ssh_channel channel, const void *data,
|
||||||
|
uint32_t len, int is_stderr);
|
||||||
|
|
||||||
|
#endif /* CHANNELS_H_ */
|
33
include/libssh/keyfiles.h
Обычный файл
33
include/libssh/keyfiles.h
Обычный файл
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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 KEYFILES_H_
|
||||||
|
#define KEYFILES_H_
|
||||||
|
|
||||||
|
/* in keyfiles.c */
|
||||||
|
|
||||||
|
ssh_private_key _privatekey_from_file(void *session, const char *filename,
|
||||||
|
int type);
|
||||||
|
ssh_string try_publickey_from_file(ssh_session session,
|
||||||
|
struct ssh_keys_struct keytab,
|
||||||
|
char **privkeyfile, int *type);
|
||||||
|
|
||||||
|
#endif /* KEYFILES_H_ */
|
34
include/libssh/packet.h
Обычный файл
34
include/libssh/packet.h
Обычный файл
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* 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 PACKET_H_
|
||||||
|
#define PACKET_H_
|
||||||
|
|
||||||
|
void packet_parse(ssh_session session);
|
||||||
|
int packet_send(ssh_session session);
|
||||||
|
|
||||||
|
int packet_read(ssh_session session);
|
||||||
|
int packet_translate(ssh_session session);
|
||||||
|
int packet_wait(ssh_session session,int type,int blocking);
|
||||||
|
int packet_flush(ssh_session session, int enforce_blocking);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PACKET_H_ */
|
61
include/libssh/poll.h
Обычный файл
61
include/libssh/poll.h
Обычный файл
@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* 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 POLL_H_
|
||||||
|
#define POLL_H_
|
||||||
|
|
||||||
|
/* poll.c */
|
||||||
|
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
|
||||||
|
typedef struct ssh_poll_ctx SSH_POLL_CTX;
|
||||||
|
typedef struct ssh_poll SSH_POLL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SSH poll callback.
|
||||||
|
*
|
||||||
|
* @param p Poll object this callback belongs to.
|
||||||
|
* @param fd The raw socket.
|
||||||
|
* @param revents The current poll events on the socket.
|
||||||
|
* @param userdata Userdata to be passed to the callback function.
|
||||||
|
*
|
||||||
|
* @return 0 on success, < 0 if you removed the poll object from
|
||||||
|
* it's poll context.
|
||||||
|
*/
|
||||||
|
typedef int (*ssh_poll_callback)(SSH_POLL *p, int fd, int revents,
|
||||||
|
void *userdata);
|
||||||
|
|
||||||
|
|
||||||
|
SSH_POLL *ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
|
||||||
|
void *userdata);
|
||||||
|
void ssh_poll_free(SSH_POLL *p);
|
||||||
|
SSH_POLL_CTX *ssh_poll_get_ctx(SSH_POLL *p);
|
||||||
|
short ssh_poll_get_events(SSH_POLL *p);
|
||||||
|
void ssh_poll_set_events(SSH_POLL *p, short events);
|
||||||
|
void ssh_poll_add_events(SSH_POLL *p, short events);
|
||||||
|
void ssh_poll_remove_events(SSH_POLL *p, short events);
|
||||||
|
socket_t ssh_poll_get_fd(SSH_POLL *p);
|
||||||
|
void ssh_poll_set_callback(SSH_POLL *p, ssh_poll_callback cb, void *userdata);
|
||||||
|
SSH_POLL_CTX *ssh_poll_ctx_new(size_t chunk_size);
|
||||||
|
void ssh_poll_ctx_free(SSH_POLL_CTX *ctx);
|
||||||
|
int ssh_poll_ctx_add(SSH_POLL_CTX *ctx, SSH_POLL *p);
|
||||||
|
void ssh_poll_ctx_remove(SSH_POLL_CTX *ctx, SSH_POLL *p);
|
||||||
|
int ssh_poll_ctx(SSH_POLL_CTX *ctx, int timeout);
|
||||||
|
|
||||||
|
#endif /* POLL_H_ */
|
@ -192,32 +192,6 @@ HMACCTX hmac_init(const void *key,int len,int type);
|
|||||||
void hmac_update(HMACCTX c, const void *data, unsigned long len);
|
void hmac_update(HMACCTX c, const void *data, unsigned long len);
|
||||||
void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
|
void hmac_final(HMACCTX ctx,unsigned char *hashmacbuf,unsigned int *len);
|
||||||
|
|
||||||
/* strings and buffers */
|
|
||||||
/* must be 32 bits number + immediatly our data */
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma pack(1)
|
|
||||||
#endif
|
|
||||||
struct ssh_string_struct {
|
|
||||||
uint32_t size;
|
|
||||||
unsigned char string[MAX_PACKET_LEN];
|
|
||||||
}
|
|
||||||
#if !defined(__SUNPRO_C) && !defined(_MSC_VER)
|
|
||||||
__attribute__ ((packed))
|
|
||||||
#endif
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma pack()
|
|
||||||
#endif
|
|
||||||
;
|
|
||||||
|
|
||||||
/** Describes a buffer state at a moment
|
|
||||||
*/
|
|
||||||
struct ssh_buffer_struct {
|
|
||||||
char *data;
|
|
||||||
uint32_t used;
|
|
||||||
uint32_t allocated;
|
|
||||||
uint32_t pos;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* i should remove it one day */
|
/* i should remove it one day */
|
||||||
typedef struct packet_struct {
|
typedef struct packet_struct {
|
||||||
int valid;
|
int valid;
|
||||||
@ -320,137 +294,13 @@ typedef struct ssh_crypto_struct {
|
|||||||
void *compress_in_ctx; /* really, don't */
|
void *compress_in_ctx; /* really, don't */
|
||||||
} CRYPTO;
|
} CRYPTO;
|
||||||
|
|
||||||
struct ssh_channel_struct {
|
|
||||||
struct ssh_channel_struct *prev;
|
|
||||||
struct ssh_channel_struct *next;
|
|
||||||
ssh_session session; /* SSH_SESSION pointer */
|
|
||||||
uint32_t local_channel;
|
|
||||||
uint32_t local_window;
|
|
||||||
int local_eof;
|
|
||||||
uint32_t local_maxpacket;
|
|
||||||
|
|
||||||
uint32_t remote_channel;
|
|
||||||
uint32_t remote_window;
|
|
||||||
int remote_eof; /* end of file received */
|
|
||||||
uint32_t remote_maxpacket;
|
|
||||||
int open; /* shows if the channel is still opened */
|
|
||||||
int delayed_close;
|
|
||||||
ssh_buffer stdout_buffer;
|
|
||||||
ssh_buffer stderr_buffer;
|
|
||||||
void *userarg;
|
|
||||||
int version;
|
|
||||||
int blocking;
|
|
||||||
int exit_status;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ssh_agent_struct {
|
|
||||||
struct socket *sock;
|
|
||||||
ssh_buffer ident;
|
|
||||||
unsigned int count;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ssh_keys_struct {
|
struct ssh_keys_struct {
|
||||||
const char *privatekey;
|
const char *privatekey;
|
||||||
const char *publickey;
|
const char *publickey;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ssh_scp_states {
|
|
||||||
SSH_SCP_NEW, //Data structure just created
|
|
||||||
SSH_SCP_WRITE_INITED, //Gave our intention to write
|
|
||||||
SSH_SCP_WRITE_WRITING,//File was opened and currently writing
|
|
||||||
SSH_SCP_READ_INITED, //Gave our intention to read
|
|
||||||
SSH_SCP_READ_REQUESTED, //We got a read request
|
|
||||||
SSH_SCP_READ_READING, //File is opened and reading
|
|
||||||
SSH_SCP_ERROR, //Something bad happened
|
|
||||||
SSH_SCP_TERMINATED //Transfer finished
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ssh_scp_struct {
|
|
||||||
ssh_session session;
|
|
||||||
int mode;
|
|
||||||
int recursive;
|
|
||||||
ssh_channel channel;
|
|
||||||
char *location;
|
|
||||||
enum ssh_scp_states state;
|
|
||||||
size_t filelen;
|
|
||||||
size_t processed;
|
|
||||||
enum ssh_scp_request_types request_type;
|
|
||||||
char *request_name;
|
|
||||||
char *warning;
|
|
||||||
int request_mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ssh_message_struct;
|
struct ssh_message_struct;
|
||||||
|
|
||||||
struct ssh_session_struct {
|
|
||||||
struct error_struct error;
|
|
||||||
struct socket *socket;
|
|
||||||
ssh_options options;
|
|
||||||
char *serverbanner;
|
|
||||||
char *clientbanner;
|
|
||||||
int protoversion;
|
|
||||||
int server;
|
|
||||||
int client;
|
|
||||||
int openssh;
|
|
||||||
uint32_t send_seq;
|
|
||||||
uint32_t recv_seq;
|
|
||||||
/* status flags */
|
|
||||||
int closed;
|
|
||||||
int closed_by_except;
|
|
||||||
|
|
||||||
int connected;
|
|
||||||
/* !=0 when the user got a session handle */
|
|
||||||
int alive;
|
|
||||||
/* two previous are deprecated */
|
|
||||||
int auth_service_asked;
|
|
||||||
|
|
||||||
/* socket status */
|
|
||||||
int blocking; // functions should block
|
|
||||||
|
|
||||||
ssh_string banner; /* that's the issue banner from
|
|
||||||
the server */
|
|
||||||
char *remotebanner; /* that's the SSH- banner from
|
|
||||||
remote host. */
|
|
||||||
char *discon_msg; /* disconnect message from
|
|
||||||
the remote host */
|
|
||||||
ssh_buffer in_buffer;
|
|
||||||
PACKET in_packet;
|
|
||||||
ssh_buffer out_buffer;
|
|
||||||
|
|
||||||
/* the states are used by the nonblocking stuff to remember */
|
|
||||||
/* where it was before being interrupted */
|
|
||||||
int packet_state;
|
|
||||||
int dh_handshake_state;
|
|
||||||
ssh_string dh_server_signature; //information used by dh_handshake.
|
|
||||||
|
|
||||||
KEX server_kex;
|
|
||||||
KEX client_kex;
|
|
||||||
ssh_buffer in_hashbuf;
|
|
||||||
ssh_buffer out_hashbuf;
|
|
||||||
CRYPTO *current_crypto;
|
|
||||||
CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
|
|
||||||
|
|
||||||
ssh_channel channels; /* linked list of channels */
|
|
||||||
int maxchannel;
|
|
||||||
int exec_channel_opened; /* version 1 only. more
|
|
||||||
info in channels1.c */
|
|
||||||
ssh_agent agent; /* ssh agent */
|
|
||||||
|
|
||||||
/* keyb interactive data */
|
|
||||||
struct ssh_kbdint_struct *kbdint;
|
|
||||||
int version; /* 1 or 2 */
|
|
||||||
/* server host keys */
|
|
||||||
ssh_private_key rsa_key;
|
|
||||||
ssh_private_key dsa_key;
|
|
||||||
/* auths accepted by server */
|
|
||||||
int auth_methods;
|
|
||||||
int hostkeys; /* contains type of host key wanted by client, in server impl */
|
|
||||||
struct ssh_list *ssh_message_list; /* list of delayed SSH messages */
|
|
||||||
int (*ssh_message_callback)( struct ssh_session_struct *session, ssh_message msg);
|
|
||||||
int log_verbosity; /*cached copy of the option structure */
|
|
||||||
int log_indent; /* indentation level in enter_function logs */
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ssh_kbdint_struct {
|
struct ssh_kbdint_struct {
|
||||||
uint32_t nprompts;
|
uint32_t nprompts;
|
||||||
char *name;
|
char *name;
|
||||||
@ -523,111 +373,8 @@ struct ssh_message_struct {
|
|||||||
struct ssh_service_request service_request;
|
struct ssh_service_request service_request;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
/* agent.c */
|
|
||||||
/**
|
|
||||||
* @brief Create a new ssh agent structure.
|
|
||||||
*
|
|
||||||
* @return An allocated ssh agent structure or NULL on error.
|
|
||||||
*/
|
|
||||||
struct ssh_agent_struct *agent_new(struct ssh_session_struct *session);
|
|
||||||
|
|
||||||
void agent_close(struct ssh_agent_struct *agent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Free an allocated ssh agent structure.
|
|
||||||
*
|
|
||||||
* @param agent The ssh agent structure to free.
|
|
||||||
*/
|
|
||||||
void agent_free(struct ssh_agent_struct *agent);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if the ssh agent is running.
|
|
||||||
*
|
|
||||||
* @param session The ssh session to check for the agent.
|
|
||||||
*
|
|
||||||
* @return 1 if it is running, 0 if not.
|
|
||||||
*/
|
|
||||||
int agent_is_running(struct ssh_session_struct *session);
|
|
||||||
|
|
||||||
int agent_get_ident_count(struct ssh_session_struct *session);
|
|
||||||
|
|
||||||
struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session_struct *session,
|
|
||||||
char **comment);
|
|
||||||
|
|
||||||
struct ssh_public_key_struct *agent_get_first_ident(struct ssh_session_struct *session,
|
|
||||||
char **comment);
|
|
||||||
|
|
||||||
ssh_string agent_sign_data(struct ssh_session_struct *session,
|
|
||||||
struct ssh_buffer_struct *data,
|
|
||||||
struct ssh_public_key_struct *pubkey);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* poll.c */
|
|
||||||
int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout);
|
|
||||||
typedef struct ssh_poll_ctx SSH_POLL_CTX;
|
|
||||||
typedef struct ssh_poll SSH_POLL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SSH poll callback.
|
|
||||||
*
|
|
||||||
* @param p Poll object this callback belongs to.
|
|
||||||
* @param fd The raw socket.
|
|
||||||
* @param revents The current poll events on the socket.
|
|
||||||
* @param userdata Userdata to be passed to the callback function.
|
|
||||||
*
|
|
||||||
* @return 0 on success, < 0 if you removed the poll object from
|
|
||||||
* it's poll context.
|
|
||||||
*/
|
|
||||||
typedef int (*ssh_poll_callback)(SSH_POLL *p, int fd, int revents,
|
|
||||||
void *userdata);
|
|
||||||
|
|
||||||
|
|
||||||
SSH_POLL *ssh_poll_new(socket_t fd, short events, ssh_poll_callback cb,
|
|
||||||
void *userdata);
|
|
||||||
void ssh_poll_free(SSH_POLL *p);
|
|
||||||
SSH_POLL_CTX *ssh_poll_get_ctx(SSH_POLL *p);
|
|
||||||
short ssh_poll_get_events(SSH_POLL *p);
|
|
||||||
void ssh_poll_set_events(SSH_POLL *p, short events);
|
|
||||||
void ssh_poll_add_events(SSH_POLL *p, short events);
|
|
||||||
void ssh_poll_remove_events(SSH_POLL *p, short events);
|
|
||||||
socket_t ssh_poll_get_fd(SSH_POLL *p);
|
|
||||||
void ssh_poll_set_callback(SSH_POLL *p, ssh_poll_callback cb, void *userdata);
|
|
||||||
SSH_POLL_CTX *ssh_poll_ctx_new(size_t chunk_size);
|
|
||||||
void ssh_poll_ctx_free(SSH_POLL_CTX *ctx);
|
|
||||||
int ssh_poll_ctx_add(SSH_POLL_CTX *ctx, SSH_POLL *p);
|
|
||||||
void ssh_poll_ctx_remove(SSH_POLL_CTX *ctx, SSH_POLL *p);
|
|
||||||
int ssh_poll_ctx(SSH_POLL_CTX *ctx, int timeout);
|
|
||||||
|
|
||||||
/* socket.c */
|
|
||||||
|
|
||||||
struct socket;
|
|
||||||
int ssh_socket_init(void);
|
|
||||||
struct socket *ssh_socket_new(ssh_session session);
|
|
||||||
void ssh_socket_free(struct socket *s);
|
|
||||||
void ssh_socket_set_fd(struct socket *s, socket_t fd);
|
|
||||||
socket_t ssh_socket_get_fd(struct socket *s);
|
|
||||||
#ifndef _WIN32
|
|
||||||
int ssh_socket_unix(struct socket *s, const char *path);
|
|
||||||
#endif
|
|
||||||
void ssh_socket_close(struct socket *s);
|
|
||||||
int ssh_socket_read(struct socket *s, void *buffer, int len);
|
|
||||||
int ssh_socket_write(struct socket *s,const void *buffer, int len);
|
|
||||||
int ssh_socket_is_open(struct socket *s);
|
|
||||||
int ssh_socket_fd_isset(struct socket *s, fd_set *set);
|
|
||||||
void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max);
|
|
||||||
int ssh_socket_completeread(struct socket *s, void *buffer, uint32_t len);
|
|
||||||
int ssh_socket_completewrite(struct socket *s, const void *buffer, uint32_t len);
|
|
||||||
int ssh_socket_wait_for_data(struct socket *s, ssh_session session, uint32_t len);
|
|
||||||
int ssh_socket_nonblocking_flush(struct socket *s);
|
|
||||||
int ssh_socket_blocking_flush(struct socket *s);
|
|
||||||
int ssh_socket_poll(struct socket *s, int *writeable, int *except);
|
|
||||||
void ssh_socket_set_towrite(struct socket *s);
|
|
||||||
void ssh_socket_set_toread(struct socket *s);
|
|
||||||
void ssh_socket_set_except(struct socket *s);
|
|
||||||
int ssh_socket_get_status(struct socket *s);
|
|
||||||
int ssh_socket_data_available(struct socket *s);
|
|
||||||
int ssh_socket_data_writable(struct socket *s);
|
|
||||||
/* session.c */
|
/* session.c */
|
||||||
|
|
||||||
void ssh_cleanup(ssh_session session);
|
void ssh_cleanup(ssh_session session);
|
||||||
@ -679,15 +426,6 @@ unsigned char *packet_encrypt(ssh_session session,void *packet,unsigned int len)
|
|||||||
/* it returns the hmac buffer if exists*/
|
/* it returns the hmac buffer if exists*/
|
||||||
int packet_hmac_verify(ssh_session session,ssh_buffer buffer,unsigned char *mac);
|
int packet_hmac_verify(ssh_session session,ssh_buffer buffer,unsigned char *mac);
|
||||||
|
|
||||||
/* in packet.c */
|
|
||||||
|
|
||||||
void packet_parse(ssh_session session);
|
|
||||||
int packet_send(ssh_session session);
|
|
||||||
|
|
||||||
int packet_read(ssh_session session);
|
|
||||||
int packet_translate(ssh_session session);
|
|
||||||
int packet_wait(ssh_session session,int type,int blocking);
|
|
||||||
int packet_flush(ssh_session session, int enforce_blocking);
|
|
||||||
|
|
||||||
/* connect.c */
|
/* connect.c */
|
||||||
int ssh_regex_init(void);
|
int ssh_regex_init(void);
|
||||||
@ -707,14 +445,6 @@ char **space_tokenize(const char *chain);
|
|||||||
int ssh_get_kex1(ssh_session session);
|
int ssh_get_kex1(ssh_session session);
|
||||||
char *ssh_find_matching(const char *in_d, const char *what_d);
|
char *ssh_find_matching(const char *in_d, const char *what_d);
|
||||||
|
|
||||||
/* in keyfiles.c */
|
|
||||||
|
|
||||||
ssh_private_key _privatekey_from_file(void *session, const char *filename,
|
|
||||||
int type);
|
|
||||||
ssh_string try_publickey_from_file(ssh_session session,
|
|
||||||
struct ssh_keys_struct keytab,
|
|
||||||
char **privkeyfile, int *type);
|
|
||||||
|
|
||||||
/* in keys.c */
|
/* in keys.c */
|
||||||
const char *ssh_type_to_char(int type);
|
const char *ssh_type_to_char(int type);
|
||||||
int ssh_type_from_name(const char *name);
|
int ssh_type_from_name(const char *name);
|
||||||
@ -736,15 +466,7 @@ ssh_string ssh_do_sign(ssh_session session,ssh_buffer sigbuf,
|
|||||||
ssh_private_key privatekey);
|
ssh_private_key privatekey);
|
||||||
ssh_string ssh_sign_session_id(ssh_session session, ssh_private_key privatekey);
|
ssh_string ssh_sign_session_id(ssh_session session, ssh_private_key privatekey);
|
||||||
ssh_string ssh_encrypt_rsa1(ssh_session session, ssh_string data, ssh_public_key key);
|
ssh_string ssh_encrypt_rsa1(ssh_session session, ssh_string data, ssh_public_key key);
|
||||||
/* channel.c */
|
|
||||||
void channel_handle(ssh_session session, int type);
|
|
||||||
ssh_channel channel_new(ssh_session session);
|
|
||||||
int channel_default_bufferize(ssh_channel channel, void *data, int len,
|
|
||||||
int is_stderr);
|
|
||||||
uint32_t ssh_channel_new_id(ssh_session session);
|
|
||||||
ssh_channel ssh_channel_from_local(ssh_session session, uint32_t id);
|
|
||||||
int channel_write_common(ssh_channel channel, const void *data,
|
|
||||||
uint32_t len, int is_stderr);
|
|
||||||
|
|
||||||
/* options.c */
|
/* options.c */
|
||||||
|
|
||||||
@ -753,35 +475,6 @@ int ssh_options_default_username(ssh_options opt);
|
|||||||
int ssh_options_default_ssh_dir(ssh_options opt);
|
int ssh_options_default_ssh_dir(ssh_options opt);
|
||||||
int ssh_options_default_known_hosts_file(ssh_options opt);
|
int ssh_options_default_known_hosts_file(ssh_options opt);
|
||||||
|
|
||||||
/* buffer.c */
|
|
||||||
int buffer_add_ssh_string(ssh_buffer buffer, ssh_string string);
|
|
||||||
int buffer_add_u8(ssh_buffer buffer, uint8_t data);
|
|
||||||
int buffer_add_u32(ssh_buffer buffer, uint32_t data);
|
|
||||||
int buffer_add_u64(ssh_buffer buffer, uint64_t data);
|
|
||||||
int buffer_add_data(ssh_buffer buffer, const void *data, uint32_t len);
|
|
||||||
int buffer_prepend_data(ssh_buffer buffer, const void *data, uint32_t len);
|
|
||||||
int buffer_add_buffer(ssh_buffer buffer, ssh_buffer source);
|
|
||||||
int buffer_reinit(ssh_buffer buffer);
|
|
||||||
|
|
||||||
/* buffer_get_rest returns a pointer to the current position into the buffer */
|
|
||||||
void *buffer_get_rest(ssh_buffer buffer);
|
|
||||||
/* buffer_get_rest_len returns the number of bytes which can be read */
|
|
||||||
uint32_t buffer_get_rest_len(ssh_buffer buffer);
|
|
||||||
|
|
||||||
/* buffer_read_*() returns the number of bytes read, except for ssh strings */
|
|
||||||
int buffer_get_u8(ssh_buffer buffer, uint8_t *data);
|
|
||||||
int buffer_get_u32(ssh_buffer buffer, uint32_t *data);
|
|
||||||
int buffer_get_u64(ssh_buffer buffer, uint64_t *data);
|
|
||||||
|
|
||||||
uint32_t buffer_get_data(ssh_buffer buffer, void *data, uint32_t requestedlen);
|
|
||||||
/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
|
|
||||||
ssh_string buffer_get_ssh_string(ssh_buffer buffer);
|
|
||||||
/* gets a string out of a SSH-1 mpint */
|
|
||||||
ssh_string buffer_get_mpint(ssh_buffer buffer);
|
|
||||||
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
|
|
||||||
uint32_t buffer_pass_bytes_end(ssh_buffer buffer, uint32_t len);
|
|
||||||
uint32_t buffer_pass_bytes(ssh_buffer buffer, uint32_t len);
|
|
||||||
|
|
||||||
/* in base64.c */
|
/* in base64.c */
|
||||||
ssh_buffer base64_to_bin(const char *source);
|
ssh_buffer base64_to_bin(const char *source);
|
||||||
unsigned char *bin_to_base64(const unsigned char *source, int len);
|
unsigned char *bin_to_base64(const unsigned char *source, int len);
|
||||||
@ -859,10 +552,6 @@ int channel_request_exec1(ssh_channel channel, const char *cmd);
|
|||||||
int channel_handle1(ssh_session session, int type);
|
int channel_handle1(ssh_session session, int type);
|
||||||
int channel_write1(ssh_channel channel, const void *data, int len);
|
int channel_write1(ssh_channel channel, const void *data, int len);
|
||||||
|
|
||||||
/* session.c */
|
|
||||||
|
|
||||||
int ssh_handle_packets(ssh_session session);
|
|
||||||
|
|
||||||
/* match.c */
|
/* match.c */
|
||||||
int match_hostname(const char *host, const char *pattern, unsigned int len);
|
int match_hostname(const char *host, const char *pattern, unsigned int len);
|
||||||
|
|
||||||
@ -871,12 +560,6 @@ int match_hostname(const char *host, const char *pattern, unsigned int len);
|
|||||||
void message_handle(ssh_session session, uint32_t type);
|
void message_handle(ssh_session session, uint32_t type);
|
||||||
int ssh_execute_message_callbacks(ssh_session session);
|
int ssh_execute_message_callbacks(ssh_session session);
|
||||||
|
|
||||||
/* scp.c */
|
|
||||||
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len);
|
|
||||||
int ssh_scp_integer_mode(const char *mode);
|
|
||||||
char *ssh_scp_string_mode(int mode);
|
|
||||||
int ssh_scp_response(ssh_scp scp, char **response);
|
|
||||||
|
|
||||||
/* log.c */
|
/* log.c */
|
||||||
|
|
||||||
#ifndef __FUNCTION__
|
#ifndef __FUNCTION__
|
||||||
|
56
include/libssh/scp.h
Обычный файл
56
include/libssh/scp.h
Обычный файл
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the SSH Library
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003-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 _SCP_H
|
||||||
|
#define _SCP_H
|
||||||
|
|
||||||
|
enum ssh_scp_states {
|
||||||
|
SSH_SCP_NEW, //Data structure just created
|
||||||
|
SSH_SCP_WRITE_INITED, //Gave our intention to write
|
||||||
|
SSH_SCP_WRITE_WRITING,//File was opened and currently writing
|
||||||
|
SSH_SCP_READ_INITED, //Gave our intention to read
|
||||||
|
SSH_SCP_READ_REQUESTED, //We got a read request
|
||||||
|
SSH_SCP_READ_READING, //File is opened and reading
|
||||||
|
SSH_SCP_ERROR, //Something bad happened
|
||||||
|
SSH_SCP_TERMINATED //Transfer finished
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ssh_scp_struct {
|
||||||
|
ssh_session session;
|
||||||
|
int mode;
|
||||||
|
int recursive;
|
||||||
|
ssh_channel channel;
|
||||||
|
char *location;
|
||||||
|
enum ssh_scp_states state;
|
||||||
|
size_t filelen;
|
||||||
|
size_t processed;
|
||||||
|
enum ssh_scp_request_types request_type;
|
||||||
|
char *request_name;
|
||||||
|
char *warning;
|
||||||
|
int request_mode;
|
||||||
|
};
|
||||||
|
|
||||||
|
int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len);
|
||||||
|
int ssh_scp_integer_mode(const char *mode);
|
||||||
|
char *ssh_scp_string_mode(int mode);
|
||||||
|
int ssh_scp_response(ssh_scp scp, char **response);
|
||||||
|
|
||||||
|
#endif
|
97
include/libssh/session.h
Обычный файл
97
include/libssh/session.h
Обычный файл
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* 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 SESSION_H_
|
||||||
|
#define SESSION_H_
|
||||||
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
struct ssh_session_struct {
|
||||||
|
struct error_struct error;
|
||||||
|
struct socket *socket;
|
||||||
|
ssh_options options;
|
||||||
|
char *serverbanner;
|
||||||
|
char *clientbanner;
|
||||||
|
int protoversion;
|
||||||
|
int server;
|
||||||
|
int client;
|
||||||
|
int openssh;
|
||||||
|
uint32_t send_seq;
|
||||||
|
uint32_t recv_seq;
|
||||||
|
/* status flags */
|
||||||
|
int closed;
|
||||||
|
int closed_by_except;
|
||||||
|
|
||||||
|
int connected;
|
||||||
|
/* !=0 when the user got a session handle */
|
||||||
|
int alive;
|
||||||
|
/* two previous are deprecated */
|
||||||
|
int auth_service_asked;
|
||||||
|
|
||||||
|
/* socket status */
|
||||||
|
int blocking; // functions should block
|
||||||
|
|
||||||
|
ssh_string banner; /* that's the issue banner from
|
||||||
|
the server */
|
||||||
|
char *remotebanner; /* that's the SSH- banner from
|
||||||
|
remote host. */
|
||||||
|
char *discon_msg; /* disconnect message from
|
||||||
|
the remote host */
|
||||||
|
ssh_buffer in_buffer;
|
||||||
|
PACKET in_packet;
|
||||||
|
ssh_buffer out_buffer;
|
||||||
|
|
||||||
|
/* the states are used by the nonblocking stuff to remember */
|
||||||
|
/* where it was before being interrupted */
|
||||||
|
int packet_state;
|
||||||
|
int dh_handshake_state;
|
||||||
|
ssh_string dh_server_signature; //information used by dh_handshake.
|
||||||
|
|
||||||
|
KEX server_kex;
|
||||||
|
KEX client_kex;
|
||||||
|
ssh_buffer in_hashbuf;
|
||||||
|
ssh_buffer out_hashbuf;
|
||||||
|
CRYPTO *current_crypto;
|
||||||
|
CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */
|
||||||
|
|
||||||
|
ssh_channel channels; /* linked list of channels */
|
||||||
|
int maxchannel;
|
||||||
|
int exec_channel_opened; /* version 1 only. more
|
||||||
|
info in channels1.c */
|
||||||
|
ssh_agent agent; /* ssh agent */
|
||||||
|
|
||||||
|
/* keyb interactive data */
|
||||||
|
struct ssh_kbdint_struct *kbdint;
|
||||||
|
int version; /* 1 or 2 */
|
||||||
|
/* server host keys */
|
||||||
|
ssh_private_key rsa_key;
|
||||||
|
ssh_private_key dsa_key;
|
||||||
|
/* auths accepted by server */
|
||||||
|
int auth_methods;
|
||||||
|
int hostkeys; /* contains type of host key wanted by client, in server impl */
|
||||||
|
struct ssh_list *ssh_message_list; /* list of delayed SSH messages */
|
||||||
|
int (*ssh_message_callback)( struct ssh_session_struct *session, ssh_message msg);
|
||||||
|
int log_verbosity; /*cached copy of the option structure */
|
||||||
|
int log_indent; /* indentation level in enter_function logs */
|
||||||
|
};
|
||||||
|
|
||||||
|
int ssh_handle_packets(ssh_session session);
|
||||||
|
|
||||||
|
#endif /* SESSION_H_ */
|
55
include/libssh/socket.h
Обычный файл
55
include/libssh/socket.h
Обычный файл
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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 SOCKET_H_
|
||||||
|
#define SOCKET_H_
|
||||||
|
|
||||||
|
/* socket.c */
|
||||||
|
|
||||||
|
struct socket;
|
||||||
|
int ssh_socket_init(void);
|
||||||
|
struct socket *ssh_socket_new(ssh_session session);
|
||||||
|
void ssh_socket_free(struct socket *s);
|
||||||
|
void ssh_socket_set_fd(struct socket *s, socket_t fd);
|
||||||
|
socket_t ssh_socket_get_fd(struct socket *s);
|
||||||
|
#ifndef _WIN32
|
||||||
|
int ssh_socket_unix(struct socket *s, const char *path);
|
||||||
|
#endif
|
||||||
|
void ssh_socket_close(struct socket *s);
|
||||||
|
int ssh_socket_read(struct socket *s, void *buffer, int len);
|
||||||
|
int ssh_socket_write(struct socket *s,const void *buffer, int len);
|
||||||
|
int ssh_socket_is_open(struct socket *s);
|
||||||
|
int ssh_socket_fd_isset(struct socket *s, fd_set *set);
|
||||||
|
void ssh_socket_fd_set(struct socket *s, fd_set *set, int *fd_max);
|
||||||
|
int ssh_socket_completeread(struct socket *s, void *buffer, uint32_t len);
|
||||||
|
int ssh_socket_completewrite(struct socket *s, const void *buffer, uint32_t len);
|
||||||
|
int ssh_socket_wait_for_data(struct socket *s, ssh_session session, uint32_t len);
|
||||||
|
int ssh_socket_nonblocking_flush(struct socket *s);
|
||||||
|
int ssh_socket_blocking_flush(struct socket *s);
|
||||||
|
int ssh_socket_poll(struct socket *s, int *writeable, int *except);
|
||||||
|
void ssh_socket_set_towrite(struct socket *s);
|
||||||
|
void ssh_socket_set_toread(struct socket *s);
|
||||||
|
void ssh_socket_set_except(struct socket *s);
|
||||||
|
int ssh_socket_get_status(struct socket *s);
|
||||||
|
int ssh_socket_data_available(struct socket *s);
|
||||||
|
int ssh_socket_data_writable(struct socket *s);
|
||||||
|
|
||||||
|
#endif /* SOCKET_H_ */
|
42
include/libssh/string.h
Обычный файл
42
include/libssh/string.h
Обычный файл
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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 STRING_H_
|
||||||
|
#define STRING_H_
|
||||||
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
/* must be 32 bits number + immediately our data */
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(1)
|
||||||
|
#endif
|
||||||
|
struct ssh_string_struct {
|
||||||
|
uint32_t size;
|
||||||
|
unsigned char string[MAX_PACKET_LEN];
|
||||||
|
}
|
||||||
|
#if !defined(__SUNPRO_C) && !defined(_MSC_VER)
|
||||||
|
__attribute__ ((packed))
|
||||||
|
#endif
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack()
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
#endif /* STRING_H_ */
|
@ -50,6 +50,9 @@
|
|||||||
|
|
||||||
#include "libssh/agent.h"
|
#include "libssh/agent.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
/* macro to check for "agent failure" message */
|
/* macro to check for "agent failure" message */
|
||||||
#define agent_failed(x) \
|
#define agent_failed(x) \
|
||||||
|
@ -32,6 +32,11 @@
|
|||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/agent.h"
|
||||||
|
#include "libssh/keyfiles.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
/** \defgroup ssh_auth SSH Authentication functions
|
/** \defgroup ssh_auth SSH Authentication functions
|
||||||
* \brief functions to authenticate to servers
|
* \brief functions to authenticate to servers
|
||||||
|
@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh1.h"
|
#include "libssh/ssh1.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
#include "libssh/string.h"
|
||||||
|
|
||||||
#ifdef WITH_SSH1
|
#ifdef WITH_SSH1
|
||||||
static int wait_auth1_status(ssh_session session) {
|
static int wait_auth1_status(ssh_session session) {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
|
||||||
static char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
static char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz"
|
"abcdefghijklmnopqrstuvwxyz"
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
/** \defgroup ssh_buffer SSH Buffers
|
/** \defgroup ssh_buffer SSH Buffers
|
||||||
* \brief buffer handling
|
* \brief buffer handling
|
||||||
*/
|
*/
|
||||||
@ -167,7 +167,7 @@ int buffer_add_ssh_string(struct ssh_buffer_struct *buffer,
|
|||||||
struct ssh_string_struct *string) {
|
struct ssh_string_struct *string) {
|
||||||
uint32_t len = 0;
|
uint32_t len = 0;
|
||||||
|
|
||||||
len = ntohl(string->size);
|
len = string_len(string);
|
||||||
if (buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) {
|
if (buffer_add_data(buffer, string, len + sizeof(uint32_t)) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -404,7 +404,7 @@ struct ssh_string_struct *buffer_get_ssh_string(struct ssh_buffer_struct *buffer
|
|||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (buffer_get_data(buffer, str->string, hostlen) != hostlen) {
|
if (buffer_get_data(buffer, string_data(str), hostlen) != hostlen) {
|
||||||
/* should never happen */
|
/* should never happen */
|
||||||
SAFE_FREE(str);
|
SAFE_FREE(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -437,7 +437,7 @@ struct ssh_string_struct *buffer_get_mpint(struct ssh_buffer_struct *buffer) {
|
|||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (buffer_get_data(buffer, str->string, len) != len) {
|
if (buffer_get_data(buffer, string_data(str), len) != len) {
|
||||||
SAFE_FREE(str);
|
SAFE_FREE(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#define WINDOWBASE 128000
|
#define WINDOWBASE 128000
|
||||||
#define WINDOWLIMIT (WINDOWBASE/2)
|
#define WINDOWLIMIT (WINDOWBASE/2)
|
||||||
@ -384,7 +389,7 @@ static void channel_rcv_data(ssh_session session,int is_stderr) {
|
|||||||
channel->local_window);
|
channel->local_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel_default_bufferize(channel, str->string, len,
|
if (channel_default_bufferize(channel, string_data(str), len,
|
||||||
is_stderr) < 0) {
|
is_stderr) < 0) {
|
||||||
string_free(str);
|
string_free(str);
|
||||||
leave_function();
|
leave_function();
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh1.h"
|
#include "libssh/ssh1.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#ifdef WITH_SSH1
|
#ifdef WITH_SSH1
|
||||||
|
|
||||||
@ -218,7 +222,7 @@ static int channel_rcv_data1(ssh_session session, int is_stderr) {
|
|||||||
"Adding %zu bytes data in %d",
|
"Adding %zu bytes data in %d",
|
||||||
string_len(str), is_stderr);
|
string_len(str), is_stderr);
|
||||||
|
|
||||||
if (channel_default_bufferize(channel, str->string, string_len(str),
|
if (channel_default_bufferize(channel, string_data(str), string_len(str),
|
||||||
is_stderr) < 0) {
|
is_stderr) < 0) {
|
||||||
string_free(str);
|
string_free(str);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#define set_status(opt,status) do {\
|
#define set_status(opt,status) do {\
|
||||||
if (opt->callbacks && opt->callbacks->connect_status_function) \
|
if (opt->callbacks && opt->callbacks->connect_status_function) \
|
||||||
|
@ -64,6 +64,9 @@
|
|||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#ifndef HAVE_SELECT
|
#ifndef HAVE_SELECT
|
||||||
#error "Your system must have select()"
|
#error "Your system must have select()"
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/crypto.h"
|
#include "libssh/crypto.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
uint32_t packet_decrypt_len(ssh_session session, char *crypted){
|
uint32_t packet_decrypt_len(ssh_session session, char *crypted){
|
||||||
uint32_t decrypted;
|
uint32_t decrypted;
|
||||||
|
@ -50,7 +50,10 @@
|
|||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/crypto.h"
|
#include "libssh/crypto.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
/* todo: remove it */
|
||||||
|
#include "libssh/string.h"
|
||||||
#ifdef HAVE_LIBCRYPTO
|
#ifdef HAVE_LIBCRYPTO
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
@ -340,7 +343,7 @@ ssh_string make_bignum_string(bignum num) {
|
|||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
fprintf(stderr, "%d bits, %d bytes, %d padding\n", bits, len, pad);
|
fprintf(stderr, "%d bits, %d bytes, %d padding\n", bits, len, pad);
|
||||||
#endif /* DEBUG_CRYPTO */
|
#endif /* DEBUG_CRYPTO */
|
||||||
|
/* TODO: fix that crap !! */
|
||||||
ptr = malloc(4 + len + pad);
|
ptr = malloc(4 + len + pad);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#if defined(HAVE_LIBZ) && defined(WITH_LIBZ)
|
#if defined(HAVE_LIBZ) && defined(WITH_LIBZ)
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,6 +33,9 @@
|
|||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
#include "libssh/ssh1.h"
|
#include "libssh/ssh1.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
#define BLOWFISH "blowfish-cbc,"
|
#define BLOWFISH "blowfish-cbc,"
|
||||||
@ -488,8 +491,8 @@ static int build_session_id1(ssh_session session, ssh_string servern,
|
|||||||
ssh_print_hexa("host modulus",hostn->string,string_len(hostn));
|
ssh_print_hexa("host modulus",hostn->string,string_len(hostn));
|
||||||
ssh_print_hexa("server modulus",servern->string,string_len(servern));
|
ssh_print_hexa("server modulus",servern->string,string_len(servern));
|
||||||
#endif
|
#endif
|
||||||
md5_update(md5,hostn->string,string_len(hostn));
|
md5_update(md5,string_data(hostn),string_len(hostn));
|
||||||
md5_update(md5,servern->string,string_len(servern));
|
md5_update(md5,string_data(servern),string_len(servern));
|
||||||
md5_update(md5,session->server_kex.cookie,8);
|
md5_update(md5,session->server_kex.cookie,8);
|
||||||
md5_final(session->next_crypto->session_id,md5);
|
md5_final(session->next_crypto->session_id,md5);
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
@ -741,7 +744,7 @@ int ssh_get_kex1(ssh_session session) {
|
|||||||
if (buffer_add_data(session->out_buffer, &bits, sizeof(uint16_t)) < 0) {
|
if (buffer_add_data(session->out_buffer, &bits, sizeof(uint16_t)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (buffer_add_data(session->out_buffer, enc_session->string,
|
if (buffer_add_data(session->out_buffer, string_data(enc_session),
|
||||||
string_len(enc_session)) < 0) {
|
string_len(enc_session)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/keyfiles.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
/*todo: remove this include */
|
||||||
|
#include "libssh/string.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
@ -1194,6 +1199,7 @@ static int check_public_key(ssh_session session, char **tokens) {
|
|||||||
bignum_free(tmpbn);
|
bignum_free(tmpbn);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
/* TODO: fix the hardcoding */
|
||||||
tmpstring->size = htonl(len);
|
tmpstring->size = htonl(len);
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
bignum_bn2bin(tmpbn, len, tmpstring->string);
|
bignum_bn2bin(tmpbn, len, tmpstring->string);
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
#include "libssh/server.h"
|
#include "libssh/server.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/agent.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
/** \addtogroup ssh_auth
|
/** \addtogroup ssh_auth
|
||||||
* @{
|
* @{
|
||||||
@ -258,7 +261,7 @@ ssh_public_key publickey_from_string(ssh_session session, ssh_string pubkey_s) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_add_data(tmpbuf, pubkey_s->string, string_len(pubkey_s)) < 0) {
|
if (buffer_add_data(tmpbuf, string_data(pubkey_s), string_len(pubkey_s)) < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,8 +781,8 @@ static ssh_string signature_to_string(SIGNATURE *sign) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(buffer, r->string + string_len(r) - 20, 20);
|
memcpy(buffer, (char *)string_data(r) + string_len(r) - 20, 20);
|
||||||
memcpy(buffer + 20, s->string + string_len(s) - 20, 20);
|
memcpy(buffer + 20, (char *)string_data(s) + string_len(s) - 20, 20);
|
||||||
|
|
||||||
string_free(r);
|
string_free(r);
|
||||||
string_free(s);
|
string_free(s);
|
||||||
@ -879,7 +882,7 @@ SIGNATURE *signature_from_string(ssh_session session, ssh_string signature,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_add_data(tmpbuf, signature->string, string_len(signature)) < 0) {
|
if (buffer_add_data(tmpbuf, string_data(signature), string_len(signature)) < 0) {
|
||||||
signature_free(sign);
|
signature_free(sign);
|
||||||
buffer_free(tmpbuf);
|
buffer_free(tmpbuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -943,8 +946,8 @@ SIGNATURE *signature_from_string(ssh_session session, ssh_string signature,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
string_fill(r, rs->string, 20);
|
string_fill(r, string_data(rs), 20);
|
||||||
string_fill(s, rs->string + 20, 20);
|
string_fill(s, (char *)string_data(rs) + 20, 20);
|
||||||
|
|
||||||
sig = DSA_SIG_new();
|
sig = DSA_SIG_new();
|
||||||
if (sig == NULL) {
|
if (sig == NULL) {
|
||||||
@ -1368,7 +1371,7 @@ ssh_string ssh_encrypt_rsa1(ssh_session session, ssh_string data, ssh_public_key
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RSA_public_encrypt(len, data->string, str->string, key->rsa_pub,
|
if (RSA_public_encrypt(len, string_data(data), string_data(str), key->rsa_pub,
|
||||||
RSA_PKCS1_PADDING) < 0) {
|
RSA_PKCS1_PADDING) < 0) {
|
||||||
string_free(str);
|
string_free(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup ssh_log SSH Logging
|
* @defgroup ssh_log SSH Logging
|
||||||
|
@ -42,7 +42,10 @@
|
|||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
static ssh_message message_new(ssh_session session){
|
static ssh_message message_new(ssh_session session){
|
||||||
ssh_message msg = malloc(sizeof(struct ssh_message_struct));
|
ssh_message msg = malloc(sizeof(struct ssh_message_struct));
|
||||||
|
@ -35,6 +35,11 @@
|
|||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
#include "libssh/ssh1.h"
|
#include "libssh/ssh1.h"
|
||||||
#include "libssh/crypto.h"
|
#include "libssh/crypto.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
/* XXX include selected mac size */
|
/* XXX include selected mac size */
|
||||||
static int macsize=SHA_DIGEST_LEN;
|
static int macsize=SHA_DIGEST_LEN;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
|
#include "libssh/poll.h"
|
||||||
|
|
||||||
#ifndef SSH_POLL_CTX_CHUNK
|
#ifndef SSH_POLL_CTX_CHUNK
|
||||||
#define SSH_POLL_CTX_CHUNK 5
|
#define SSH_POLL_CTX_CHUNK 5
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/scp.h"
|
||||||
|
|
||||||
/** @brief Creates a new scp session
|
/** @brief Creates a new scp session
|
||||||
* @param session the SSH session to use
|
* @param session the SSH session to use
|
||||||
|
@ -37,6 +37,12 @@
|
|||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/server.h"
|
#include "libssh/server.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
|
#include "libssh/keyfiles.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
@ -27,6 +27,11 @@
|
|||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/server.h"
|
#include "libssh/server.h"
|
||||||
#include "libssh/callback.h"
|
#include "libssh/callback.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/agent.h"
|
||||||
|
#include "libssh/packet.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
|
#define FIRST_CHANNEL 42 // why not ? it helps to find bugs.
|
||||||
|
|
||||||
/** \defgroup ssh_session SSH Session
|
/** \defgroup ssh_session SSH Session
|
||||||
|
@ -46,6 +46,9 @@
|
|||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
#include "libssh/sftp.h"
|
#include "libssh/sftp.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/channels.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#ifdef WITH_SFTP
|
#ifdef WITH_SFTP
|
||||||
|
|
||||||
@ -1668,7 +1671,7 @@ ssize_t sftp_read(SFTP_FILE *handle, void *buf, size_t count) {
|
|||||||
}
|
}
|
||||||
count = string_len(datastring);
|
count = string_len(datastring);
|
||||||
handle->offset += count;
|
handle->offset += count;
|
||||||
memcpy(buf, datastring->string, count);
|
memcpy(buf, string_data(datastring), count);
|
||||||
string_free(datastring);
|
string_free(datastring);
|
||||||
return count;
|
return count;
|
||||||
default:
|
default:
|
||||||
@ -1787,7 +1790,7 @@ int sftp_async_read(SFTP_FILE *file, void *data, uint32_t size, uint32_t id){
|
|||||||
//handle->offset+=len;
|
//handle->offset+=len;
|
||||||
/* We already have set the offset previously. All we can do is warn that the expected len
|
/* We already have set the offset previously. All we can do is warn that the expected len
|
||||||
* and effective lengths are different */
|
* and effective lengths are different */
|
||||||
memcpy(data, datastring->string, len);
|
memcpy(data, string_data(datastring), len);
|
||||||
string_free(datastring);
|
string_free(datastring);
|
||||||
sftp_leave_function();
|
sftp_leave_function();
|
||||||
return len;
|
return len;
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "libssh/sftp.h"
|
#include "libssh/sftp.h"
|
||||||
#include "libssh/ssh2.h"
|
#include "libssh/ssh2.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
|
||||||
SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp) {
|
SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp) {
|
||||||
SFTP_PACKET *packet;
|
SFTP_PACKET *packet;
|
||||||
@ -448,7 +449,7 @@ ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ret->string, &val, sizeof(uint32_t));
|
memcpy(string_data(ret), &val, sizeof(uint32_t));
|
||||||
sftp->handles[i] = info;
|
sftp->handles[i] = info;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -465,7 +466,7 @@ void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&val, handle->string, sizeof(uint32_t));
|
memcpy(&val, string_data(handle), sizeof(uint32_t));
|
||||||
|
|
||||||
if (val > SFTP_HANDLES) {
|
if (val > SFTP_HANDLES) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -34,6 +34,10 @@
|
|||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
#endif
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/socket.h"
|
||||||
|
#include "libssh/buffer.h"
|
||||||
|
#include "libssh/poll.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
/** \defgroup ssh_socket SSH Sockets
|
/** \defgroup ssh_socket SSH Sockets
|
||||||
* \addtogroup ssh_socket
|
* \addtogroup ssh_socket
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/string.h"
|
||||||
/** \defgroup ssh_string SSH Strings
|
/** \defgroup ssh_string SSH Strings
|
||||||
* \brief string manipulations
|
* \brief string manipulations
|
||||||
*/
|
*/
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
#include "libssh/session.h"
|
||||||
|
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user