diff options
Diffstat (limited to 'include')
l--------- | include/libssh/config.h | 1 | ||||
-rw-r--r-- | include/libssh/crypto.h | 47 | ||||
-rw-r--r-- | include/libssh/libssh.h | 234 | ||||
-rw-r--r-- | include/libssh/priv.h | 444 | ||||
-rw-r--r-- | include/libssh/server.h | 31 | ||||
-rw-r--r-- | include/libssh/sftp.h | 225 | ||||
-rw-r--r-- | include/libssh/ssh1.h | 82 | ||||
-rw-r--r-- | include/libssh/ssh2.h | 69 |
8 files changed, 1133 insertions, 0 deletions
diff --git a/include/libssh/config.h b/include/libssh/config.h new file mode 120000 index 00000000..bce5bfdd --- /dev/null +++ b/include/libssh/config.h @@ -0,0 +1 @@ +../../config.h
\ No newline at end of file diff --git a/include/libssh/crypto.h b/include/libssh/crypto.h new file mode 100644 index 00000000..3b8426cc --- /dev/null +++ b/include/libssh/crypto.h @@ -0,0 +1,47 @@ +/* +Copyright 2003 Aris Adamantiadis + +This file is part of the SSH Library + +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. */ + +/* Crypto.h is an include file for internal structures of libssh */ +/* It hasn't to be into the final development set of files (and btw the filename would cause problems on most systems) */ +/* Openssl has (really) stupid defines */ +#ifdef set_key +#undef set_key +#endif +#ifdef cbc_encrypt +#undef cbc_encrypt +#endif +#ifdef cbc_decrypt +#undef cbc_decrypt +#endif +#ifdef des_set_key +#undef des_set_key +#endif +struct crypto_struct { + char *name; /* ssh name of the algorithm */ + unsigned int blocksize; /* blocksize of the algo */ + unsigned int keylen; /* length of the key structure */ + void *key; /* a key buffer allocated for the algo */ + unsigned int keysize; /* bytes of key used. != keylen */ + void (*set_encrypt_key)(struct crypto_struct *cipher, void *key); /* sets the new key for immediate use */ + void (*set_decrypt_key)(struct crypto_struct *cipher, void *key); + void (*cbc_encrypt)(struct crypto_struct *cipher, void *in, void *out,unsigned long len,void *IV); + void (*cbc_decrypt)(struct crypto_struct *cipher, void *in, void *out,unsigned long len,void *IV); +}; + diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h new file mode 100644 index 00000000..9e3495b8 --- /dev/null +++ b/include/libssh/libssh.h @@ -0,0 +1,234 @@ +/* +Copyright 2003,04 Aris Adamantiadis + +This file is part of the SSH Library + +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 _LIBSSH_H +#define _LIBSSH_H +#include <libssh/config.h> +#include <unistd.h> +#include <sys/select.h> /* for fd_set * */ +#include <sys/types.h> +#define LIBSSH_VERSION "libssh-0.2-dev" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct string_struct STRING; +typedef struct buffer_struct BUFFER; +typedef struct public_key_struct PUBLIC_KEY; +typedef struct private_key_struct PRIVATE_KEY; +typedef struct ssh_options_struct SSH_OPTIONS; +typedef struct channel_struct CHANNEL; +typedef struct ssh_session SSH_SESSION; +typedef struct ssh_kbdint SSH_KBDINT; + +/* integer values */ +typedef u_int32_t u32; +typedef u_int16_t u16; +typedef u_int64_t u64; +typedef u_int8_t u8; + +/* the offsets of methods */ +#define SSH_KEX 0 +#define SSH_HOSTKEYS 1 +#define SSH_CRYPT_C_S 2 +#define SSH_CRYPT_S_C 3 +#define SSH_MAC_C_S 4 +#define SSH_MAC_S_C 5 +#define SSH_COMP_C_S 6 +#define SSH_COMP_S_C 7 +#define SSH_LANG_C_S 8 +#define SSH_LANG_S_C 9 + +#define SSH_CRYPT 2 +#define SSH_MAC 3 +#define SSH_COMP 4 +#define SSH_LANG 5 + +#define SSH_AUTH_SUCCESS 0 +#define SSH_AUTH_DENIED 1 +#define SSH_AUTH_PARTIAL 2 +#define SSH_AUTH_INFO 3 +#define SSH_AUTH_ERROR -1 + +/* status flags */ + +#define SSH_CLOSED (1<<0) +#define SSH_READ_PENDING (1<<1) +#define SSH_CLOSED_ERROR (1<<2) + +#define SSH_SERVER_ERROR -1 +#define SSH_SERVER_NOT_KNOWN 0 +#define SSH_SERVER_KNOWN_OK 1 +#define SSH_SERVER_KNOWN_CHANGED 2 +#define SSH_SERVER_FOUND_OTHER 3 + +#ifndef MD5_DIGEST_LEN + #define MD5_DIGEST_LEN 16 +#endif +/* errors */ + +#define SSH_NO_ERROR 0 +#define SSH_REQUEST_DENIED 1 +#define SSH_FATAL 2 +#define SSH_EINTR 3 + + +char *ssh_get_error(SSH_SESSION *session); +int ssh_get_error_code(SSH_SESSION *session); +void ssh_say(int priority,char *format,...); +void ssh_set_verbosity(int num); + + /* There is a verbosity level */ + /* 3 : packet level */ + /* 2 : protocol level */ + /* 1 : functions level */ + /* 0 : important messages only */ + /* -1 : no messages */ + +/* in client.c */ + +SSH_SESSION *ssh_new(); +void ssh_set_options(SSH_SESSION *session, SSH_OPTIONS *options); +int ssh_connect(); +void ssh_disconnect(SSH_SESSION *session); +int ssh_service_request(SSH_SESSION *session,char *service); +char *ssh_get_issue_banner(SSH_SESSION *session); +/* get copyright informations */ +const char *ssh_copyright(); +/* string.h */ + +/* You can use these functions, they won't change */ +/* makestring returns a newly allocated string from a char * ptr */ +STRING *string_from_char(char *what); +/* it returns the string len in host byte orders. str->size is big endian warning ! */ +int string_len(STRING *str); +STRING *string_new(u32 size); +/* string_fill copies the data in the string. it does NOT check for boundary so allocate enough place with string_new */ +void string_fill(STRING *str,void *data,int len); +/* returns a newly allocated char array with the str string and a final nul caracter */ +char *string_to_char(STRING *str); +STRING *string_copy(STRING *str); +/* burns the data inside a string */ +void string_burn(STRING *str); + +/* deprecated */ +void ssh_crypto_init(); + +/* useful for debug */ +void ssh_print_hexa(char *descr,unsigned char *what, int len); +void ssh_get_random(void *,int); + +/* this one can be called by the client to see the hash of the public key before accepting it */ +int ssh_get_pubkey_hash(SSH_SESSION *session,char hash[MD5_DIGEST_LEN]); +STRING *ssh_get_pubkey(SSH_SESSION *session); + +/* deprecated */ +int pubkey_get_hash(SSH_SESSION *session,char hash[MD5_DIGEST_LEN]); + +/* in connect.c */ +int ssh_fd_poll(SSH_SESSION *session); +int ssh_select(CHANNEL **channels,CHANNEL **outchannels, int maxfd, fd_set *readfds, struct timeval *timeout); + +void publickey_free(PUBLIC_KEY *key); + +/* in keyfiles.c */ + +PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session,char *filename,int type,char *passphrase); +void private_key_free(PRIVATE_KEY *prv); +STRING *publickey_from_file(SSH_SESSION *session, char *filename,int *_type); +STRING *publickey_from_next_file(SSH_SESSION *session,char **pub_keys_path,char **keys_path, + char **privkeyfile,int *type,int *count); +int ssh_is_server_known(SSH_SESSION *session); +int ssh_write_knownhost(SSH_SESSION *session); + +/* in channels.c */ + +CHANNEL *channel_new(SSH_SESSION *session); +int channel_open_forward(CHANNEL *channel,char *remotehost, int remoteport, char *sourcehost, int localport); +int channel_open_session(CHANNEL *channel); +void channel_free(CHANNEL *channel); +int channel_request_pty(CHANNEL *channel); +int channel_request_pty_size(CHANNEL *channel, char *term,int cols, int rows); +int channel_change_pty_size(CHANNEL *channel,int cols,int rows); +int channel_request_shell(CHANNEL *channel); +int channel_request_subsystem(CHANNEL *channel, char *system); +int channel_request_env(CHANNEL *channel,char *name, char *value); +int channel_request_exec(CHANNEL *channel, char *cmd); +int channel_request_sftp(CHANNEL *channel); +int channel_write(CHANNEL *channel,void *data,int len); +int channel_send_eof(CHANNEL *channel); +int channel_read(CHANNEL *channel, BUFFER *buffer,int bytes,int is_stderr); +int channel_poll(CHANNEL *channel, int is_stderr); +int channel_close(CHANNEL *channel); +int channel_read_nonblocking(CHANNEL *channel, char *dest, int len, int is_stderr); +int channel_is_open(CHANNEL *channel); +/* in options.c */ + +SSH_OPTIONS *ssh_options_new(); +SSH_OPTIONS *ssh_options_copy(SSH_OPTIONS *opt); +int ssh_options_set_wanted_algos(SSH_OPTIONS *opt,int algo, char *list); +void ssh_options_set_username(SSH_OPTIONS *opt,char *username); +void ssh_options_set_port(SSH_OPTIONS *opt, unsigned int port); +int ssh_options_getopt(SSH_OPTIONS *options, int *argcptr, char **argv); +void ssh_options_set_host(SSH_OPTIONS *opt, const char *host); +void ssh_options_set_fd(SSH_OPTIONS *opt, int fd); +void ssh_options_set_bind(SSH_OPTIONS *opt, char *bindaddr,int port); +void ssh_options_set_identity(SSH_OPTIONS *opt, char *identity); +void ssh_options_set_status_callback(SSH_OPTIONS *opt, void (*callback) + (void *arg, float status), void *arg); +void ssh_options_set_timeout(SSH_OPTIONS *opt, long seconds, long usec); +void ssh_options_set_ssh_dir(SSH_OPTIONS *opt, char *dir); +void ssh_options_set_known_hosts_file(SSH_OPTIONS *opt, char *dir); +void ssh_options_allow_ssh1(SSH_OPTIONS *opt, int allow); +void ssh_options_allow_ssh2(SSH_OPTIONS *opt, int allow); + + +/* buffer.c */ + +BUFFER *buffer_new(); +void buffer_free(BUFFER *buffer); +/* buffer_get returns a pointer to the begining of the buffer. no position is taken into account */ +void *buffer_get(BUFFER *buffer); +/* same here */ +int buffer_get_len(BUFFER *buffer); + + +/* in auth.c */ +/* these functions returns AUTH_ERROR is some serious error has happened, + AUTH_SUCCESS if success, + AUTH_PARTIAL if partial success, + AUTH_DENIED if refused */ +int ssh_userauth_none(SSH_SESSION *session,char *username); +int ssh_userauth_password(SSH_SESSION *session,char *username,char *password); +int ssh_userauth_offer_pubkey(SSH_SESSION *session, char *username,int type, STRING *publickey); +int ssh_userauth_pubkey(SSH_SESSION *session, char *username, STRING *publickey, PRIVATE_KEY *privatekey); +int ssh_userauth_autopubkey(SSH_SESSION *session); +int ssh_userauth_kbdint(SSH_SESSION *session, char *user, char *submethods); +int ssh_userauth_kbdint_getnprompts(SSH_SESSION *session); +char *ssh_userauth_kbdint_getname(SSH_SESSION *session); +char *ssh_userauth_kbdint_getinstruction(SSH_SESSION *session); +char *ssh_userauth_kbdint_getprompt(SSH_SESSION *session, int i, char *echo); +void ssh_userauth_kbdint_setanswer(SSH_SESSION *session, unsigned int i, char *answer); + +#ifdef __cplusplus +} ; +#endif +#endif /* _LIBSSH_H */ diff --git a/include/libssh/priv.h b/include/libssh/priv.h new file mode 100644 index 00000000..5899fb6a --- /dev/null +++ b/include/libssh/priv.h @@ -0,0 +1,444 @@ +/* +Copyright 2003,04 Aris Adamantiadis + +This file is part of the SSH Library + +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. */ + +/* priv.h file */ +/* This include file contains everything you shouldn't deal with in user programs. */ +/* Consider that anything in this file might change without notice; libssh.h file will keep */ +/* backward compatibility on binary & source */ + +#ifndef _LIBSSH_PRIV_H +#define _LIBSSH_PRIV_H +#include "libssh/libssh.h" + +/* Debugging constants */ + +/* Define this if you want to debug crypto systems */ +/* it's usefull when you are debugging the lib */ +/*#define DEBUG_CRYPTO */ + +/* some constants */ +#define MAX_PACKET_LEN 262144 +#define ERROR_BUFFERLEN 1024 +#define CLIENTBANNER1 "SSH-1.5-" LIBSSH_VERSION +#define CLIENTBANNER2 "SSH-2.0-" LIBSSH_VERSION +#define KBDINT_MAX_PROMPT 256 /* more than openssh's :) */ +/* some types for public keys */ +#define TYPE_DSS 1 +#define TYPE_RSA 2 +#define TYPE_RSA1 3 + +/* profiling constants. Don't touch them unless you know what you do */ +#define OPENSSL_CRYPTO +#define OPENSSL_BIGNUMS + + +#ifdef __cplusplus +extern "C" { +#endif + +/* wrapper things */ + +#ifdef OPENSSL_CRYPTO +#include <openssl/dsa.h> +#include <openssl/rsa.h> +#include <openssl/sha.h> +#include <openssl/md5.h> +#include <openssl/hmac.h> +typedef SHA_CTX SHACTX; +typedef MD5_CTX MD5CTX; +typedef HMAC_CTX HMACCTX; +#ifdef MD5_DIGEST_LEN + #undef MD5_DIGEST_LEN +#endif +#define SHA_DIGEST_LEN SHA_DIGEST_LENGTH +#define MD5_DIGEST_LEN MD5_DIGEST_LENGTH + +#endif /* OPENSSL_CRYPTO */ +#ifdef OPENSSL_BIGNUMS +#include <openssl/bn.h> +typedef BIGNUM* bignum; +typedef BN_CTX* bignum_CTX; + +#define bignum_new() BN_new() +#define bignum_free(num) BN_clear_free(num) +#define bignum_set_word(bn,n) BN_set_word(bn,n) +#define bignum_bin2bn(bn,datalen,data) BN_bin2bn(bn,datalen,data) +#define bignum_bn2hex(num) BN_bn2hex(num) +#define bignum_rand(rnd, bits, top, bottom) BN_rand(rnd,bits,top,bottom) +#define bignum_ctx_new() BN_CTX_new() +#define bignum_ctx_free(num) BN_CTX_free(num) +#define bignum_mod_exp(dest,generator,exp,modulo,ctx) BN_mod_exp(dest,generator,exp,modulo,ctx) +#define bignum_num_bytes(num) BN_num_bytes(num) +#define bignum_num_bits(num) BN_num_bits(num) +#define bignum_is_bit_set(num,bit) BN_is_bit_set(num,bit) +#define bignum_bn2bin(num,ptr) BN_bn2bin(num,ptr) + +#endif /* OPENSSL_BIGNUMS */ +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif + +/* wrapper.c */ +MD5CTX *md5_init(void); +void md5_update(MD5CTX *c, const void *data, unsigned long len); +void md5_final(unsigned char *md,MD5CTX *c); +SHACTX *sha1_init(void); +void sha1_update(SHACTX *c, const void *data, unsigned long len); +void sha1_final(unsigned char *md,SHACTX *c); +void sha1(unsigned char *digest,int len,unsigned char *hash); +#define HMAC_SHA1 1 +#define HMAC_MD5 2 +HMACCTX *hmac_init(const void *key,int len,int type); +void hmac_update(HMACCTX *c, const void *data, unsigned long len); +void hmac_final(HMACCTX *ctx,unsigned char *hashmacbuf,int *len); + +/* strings and buffers */ +/* must be 32 bits number + immediatly our data */ +struct string_struct { + u32 size; + char string[MAX_PACKET_LEN]; +} __attribute__ ((packed)); + + +struct buffer_struct { + char *data; + int used; + int allocated; + int pos; +}; + +/* i should remove it one day */ +typedef struct packet_struct { + int valid; + u32 len; + u8 type; +} PACKET; + +typedef struct kex_struct { + char cookie[16]; + char **methods; +} KEX; + +struct public_key_struct { + int type; + char *type_c; /* Don't free it ! it is static */ + DSA *dsa_pub; + RSA *rsa_pub; +}; + +struct private_key_struct { + int type; + DSA *dsa_priv; + RSA *rsa_priv; +}; + +typedef struct signature_struct { + int type; + DSA_SIG *dsa_sign; + STRING *rsa_sign; +} SIGNATURE; + +struct ssh_options_struct { + char *banner; /* explicit banner to send */ + char *username; + char *host; + char *bindaddr; + int bindport; + char *identity; + char *ssh_dir; + char *known_hosts_file; + int fd; /* specificaly wanted file descriptor, don't connect host */ + int port; + int dont_verify_hostkey; /* Don't spare time, don't check host key ! unneeded to say it's dangerous and not safe */ + int use_nonexisting_algo; /* if user sets a not supported algorithm for kex, don't complain */ + char *wanted_methods[10]; /* the kex methods can be choosed. better use the kex fonctions to do that */ + void *wanted_cookie; /* wants a specific cookie to be sent ? if null, generate a new one */ + void *passphrase_function; /* this functions will be called if a keyphrase is needed. look keyfiles.c for more info */ + void (*connect_status_function)(void *arg, float status); /* status callback function */ + void *connect_status_arg; /* arbitrary argument */ + long timeout; /* seconds */ + long timeout_usec; + int ssh2allowed; + int ssh1allowed; +}; + +typedef struct ssh_crypto_struct { + bignum e,f,x,k; + char session_id[SHA_DIGEST_LEN]; + + char encryptIV[SHA_DIGEST_LEN*2]; + char decryptIV[SHA_DIGEST_LEN*2]; + + char decryptkey[SHA_DIGEST_LEN*2]; + char encryptkey[SHA_DIGEST_LEN*2]; + + char encryptMAC[SHA_DIGEST_LEN]; + char decryptMAC[SHA_DIGEST_LEN]; + char hmacbuf[EVP_MAX_MD_SIZE]; + struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */ + STRING *server_pubkey; + 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 */ +} CRYPTO; + +struct channel_struct { + struct channel_struct *prev; + struct channel_struct *next; + SSH_SESSION *session; /* SSH_SESSION pointer */ + u32 local_channel; + u32 local_window; + int local_eof; + u32 local_maxpacket; + + u32 remote_channel; + u32 remote_window; + int remote_eof; /* end of file received */ + u32 remote_maxpacket; + int open; /* shows if the channel is still opened */ + int delayed_close; + BUFFER *stdout_buffer; + BUFFER *stderr_buffer; + void *userarg; + int version; + int blocking; +}; + +struct ssh_session { + int fd; + SSH_OPTIONS *options; + char *serverbanner; + char *clientbanner; + int protoversion; + u32 send_seq; + u32 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 data_to_read; /* reading now on socket will + not block */ + int data_to_write; + int data_except; + int blocking; // functions should not block + + 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 */ + BUFFER *in_buffer; + PACKET in_packet; + BUFFER *out_buffer; + KEX server_kex; + KEX client_kex; + BUFFER *in_hashbuf; + BUFFER *out_hashbuf; + CRYPTO *current_crypto; + CRYPTO *next_crypto; /* next_crypto is going to be used after a SSH2_MSG_NEWKEYS */ + + int channel_bytes_toread; /* left number of bytes + in the channel buffers + */ + CHANNEL *channels; /* linked list of channels */ + int maxchannel; + int exec_channel_opened; /* version 1 only. more + info in channels1.c */ + +/* error handling */ + int error_code; + char error_buffer[ERROR_BUFFERLEN]; +/* keyb interactive data */ + struct ssh_kbdint *kbdint; + int version; /* 1 or 2 */ +}; + +struct ssh_kbdint { + u32 nprompts; + char *name; + char *instruction; + char **prompts; + char *echo; /* bool array */ + char **answers; +}; +/* session.c */ + +void ssh_cleanup(SSH_SESSION *session); + + +/* errors.c */ +void ssh_set_error(SSH_SESSION *session,int code,char *descr,...); + +/* in dh.c */ +/* DH key generation */ +void dh_generate_e(SSH_SESSION *session); +void dh_generate_x(SSH_SESSION *session); +STRING *dh_get_e(SSH_SESSION *session); +void dh_import_f(SSH_SESSION *session,STRING *f_string); +void dh_import_pubkey(SSH_SESSION *session,STRING *pubkey_string); +void dh_build_k(SSH_SESSION *session); +void make_sessionid(SSH_SESSION *session); +/* add data for the final cookie */ +void hashbufin_add_cookie(SSH_SESSION *session,unsigned char *cookie); +void hashbufout_add_cookie(SSH_SESSION *session); +void generate_session_keys(SSH_SESSION *session); +/* returns 1 if server signature ok, 0 otherwise. The NEXT crypto is checked, not the current one */ +int signature_verify(SSH_SESSION *session,STRING *signature); +bignum make_string_bn(STRING *string); +STRING *make_bignum_string(bignum num); + +/* in crypt.c */ +u32 packet_decrypt_len(SSH_SESSION *session,char *crypted); +int packet_decrypt(SSH_SESSION *session, void *packet,unsigned int len); +char *packet_encrypt(SSH_SESSION *session,void *packet,unsigned int len); + /* it returns the hmac buffer if exists*/ +int packet_hmac_verify(SSH_SESSION *session,BUFFER *buffer,char *mac); + +/* in packet.c */ +void packet_clear_out(SSH_SESSION *session); +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); + +/* connect.c */ +SSH_SESSION *ssh_session_new(); +int ssh_connect_host(SSH_SESSION *session, const char *host,const char + *bind_addr, int port, long timeout, long usec); + +/* in kex.c */ +extern char *ssh_kex_nums[]; +void send_kex(SSH_SESSION *session,int server_kex); +void list_kex(KEX *kex); +int set_kex(SSH_SESSION *session); +int ssh_get_kex(SSH_SESSION *session, int server_kex); +int verify_existing_algo(int algo,char *name); +char **space_tokenize(char *chain); +int ssh_get_kex1(SSH_SESSION *session); + +/* in keys.c */ +char *ssh_type_to_char(int type); +PUBLIC_KEY *publickey_make_dss(BUFFER *buffer); +PUBLIC_KEY *publickey_make_rsa(BUFFER *buffer,char *type); +PUBLIC_KEY *publickey_from_string(STRING *pubkey_s); +SIGNATURE *signature_from_string(STRING *signature,PUBLIC_KEY *pubkey,int needed_type); +void signature_free(SIGNATURE *sign); +STRING *ssh_do_sign(SSH_SESSION *session,BUFFER *sigbuf, + PRIVATE_KEY *privatekey); +STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key); +/* channel.c */ +void channel_handle(SSH_SESSION *session, int type); +CHANNEL *channel_new(SSH_SESSION *session); +void channel_default_bufferize(CHANNEL *channel, void *data, int len, + int is_stderr); +/* options.c */ +void options_free(SSH_OPTIONS *opt); +/* this function must be called when no specific username has been asked. it has to guess it */ +int options_default_username(SSH_OPTIONS *opt); +int options_default_ssh_dir(SSH_OPTIONS *opt); +int options_default_known_hosts_file(SSH_OPTIONS *opt); + +/* buffer.c */ +void buffer_add_ssh_string(BUFFER *buffer,STRING *string); +void buffer_add_u8(BUFFER *buffer, u8 data); +void buffer_add_u32(BUFFER *buffer, u32 data); +void buffer_add_u64(BUFFER *buffer,u64 data); +void buffer_add_data(BUFFER *buffer, void *data, int len); +void buffer_add_data_begin(BUFFER *buffer,void *data,int len); +void buffer_add_buffer(BUFFER *buffer, BUFFER *source); +void buffer_reinit(BUFFER *buffer); + +/* buffer_get_rest returns a pointer to the current position into the buffer */ +void *buffer_get_rest(BUFFER *buffer); +/* buffer_get_rest_len returns the number of bytes which can be read */ +int buffer_get_rest_len(BUFFER *buffer); + +/* buffer_read_*() returns the number of bytes read, except for ssh strings */ +int buffer_get_u8(BUFFER *buffer,u8 *data); +int buffer_get_u32(BUFFER *buffer,u32 *data); +int buffer_get_u64(BUFFER *buffer, u64 *data); + +int buffer_get_data(BUFFER *buffer,void *data,int requestedlen); +/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */ +STRING *buffer_get_ssh_string(BUFFER *buffer); +/* gets a string out of a SSH-1 mpint */ +STRING *buffer_get_mpint(BUFFER *buffer); +/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */ +int buffer_pass_bytes_end(BUFFER *buffer,int len); +int buffer_pass_bytes(BUFFER *buffer, int len); + +/* in base64.c */ +BUFFER *base64_to_bin(char *source); +char *bin_to_base64(unsigned char *source, int len); + +/* gzip.c */ +int compress_buffer(SSH_SESSION *session,BUFFER *buf); +int decompress_buffer(SSH_SESSION *session,BUFFER *buf); + +/* wrapper.c */ +int crypt_set_algorithms(SSH_SESSION *); +CRYPTO *crypto_new(); +void crypto_free(CRYPTO *crypto); +bignum bignum_new(); + +/* crc32.c */ +u32 ssh_crc32(char *buffer, int len); + +/* auth1.c */ +int ssh_userauth1_none(SSH_SESSION *session, char *username); +int ssh_userauth1_offer_pubkey(SSH_SESSION *session, char *username, + int type, STRING *pubkey); +int ssh_userauth1_password(SSH_SESSION *session, char *username, + char *password); +/* in misc.c */ +/* gets the user home dir. */ +char *ssh_get_user_home_dir(); +int ssh_file_readaccess_ok(char *file); + +/* macro for byte ordering */ +u64 ntohll(u64); +#define htonll(x) ntohll(x) + +/* channels1.c */ +CHANNEL *channel_open_session1(SSH_SESSION *session); +int channel_request_pty_size1(CHANNEL *channel, char *terminal,int cols, + int rows); +int channel_change_pty_size1(CHANNEL *channel, int cols, int rows); +int channel_request_shell1(CHANNEL *channel); +int channel_request_exec1(CHANNEL *channel, char *cmd); +void channel_handle1(SSH_SESSION *session,int type); +int channel_write1(CHANNEL *channel, void *data, int len); +#ifdef __cplusplus +} ; +#endif + +#endif /* _LIBSSH_PRIV_H */ diff --git a/include/libssh/server.h b/include/libssh/server.h new file mode 100644 index 00000000..90c280ee --- /dev/null +++ b/include/libssh/server.h @@ -0,0 +1,31 @@ +/* +Copyright 2004 Aris Adamantiadis + +This file is part of the SSH Library + +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 SERVER_H +#define SERVER_H +/* the client banner doesn't say hey! look i'm a client ! */ +#include "libssh/libssh.h" +#define SERVERBANNER CLIENTBANNER + +int bind_socket(); +int listen_socket(int s); +int accept_socket(int s); + +#endif diff --git a/include/libssh/sftp.h b/include/libssh/sftp.h new file mode 100644 index 00000000..22960e2c --- /dev/null +++ b/include/libssh/sftp.h @@ -0,0 +1,225 @@ +/* sftp headers */ +/* +Copyright 2003 Aris Adamantiadis + +This file is part of the SSH Library + +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 SFTP_H +#define SFTP_H +#include <libssh/libssh.h> +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct sftp_session_struct { + SSH_SESSION *session; + CHANNEL *channel; + int server_version; + struct request_queue *queue; + u32 id_counter; +} SFTP_SESSION ; + +typedef struct { + SFTP_SESSION *sftp; + u8 type; + BUFFER *payload; +} SFTP_PACKET; + +/* file handler */ +typedef struct sftp_file{ + SFTP_SESSION *sftp; + char *name; + u64 offset; + STRING *handle; + int eof; + int nonblocking; +} SFTP_FILE ; + +typedef struct sftp_dir { + SFTP_SESSION *sftp; + char *name; + STRING *handle; /* handle to directory */ + BUFFER *buffer; /* contains raw attributes from server which haven't been parsed */ + u32 count; /* counts the number of following attributes structures into buffer */ + int eof; /* end of directory listing */ +} SFTP_DIR; + +typedef struct { + SFTP_SESSION *sftp; + u8 packet_type; + BUFFER *payload; + u32 id; +} SFTP_MESSAGE; + +typedef struct request_queue{ + struct request_queue *next; + SFTP_MESSAGE *message; +} REQUEST_QUEUE; + +/* SSH_FXP_MESSAGE described into .7 page 26 */ +typedef struct { + u32 id; + u32 status; + STRING *error; + STRING *lang; + char *errormsg; + char *langmsg; +} STATUS_MESSAGE; + +/* don't worry much of these aren't really used */ +typedef struct { + char *name; + char *longname; /* some weird stuff */ + u32 flags; + u8 type; + u64 size; + u32 uid; + u32 gid; + char *owner; + char *group; + u32 permissions; + u64 atime64; + u32 atime; + u32 atime_nseconds; + u64 createtime; + u32 createtime_nseconds; + u64 mtime64; + u32 mtime; + u32 mtime_nseconds; + STRING *acl; + u32 extended_count; + STRING *extended_type; + STRING *extended_data; +} SFTP_ATTRIBUTES; + +#define LIBSFTP_VERSION 3 + +SFTP_SESSION *sftp_new(SSH_SESSION *session); +void sftp_free(SFTP_SESSION *sftp); +int sftp_init(SFTP_SESSION *sftp); +SFTP_DIR *sftp_opendir(SFTP_SESSION *session, char *path); +/* reads one file and attribute from opened directory. fails at end */ +SFTP_ATTRIBUTES *sftp_readdir(SFTP_SESSION *session, SFTP_DIR *dir); +/* returns 1 if the directory was EOF */ +int sftp_dir_eof(SFTP_DIR *dir); +SFTP_ATTRIBUTES *sftp_stat(SFTP_SESSION *session, char *path); +SFTP_ATTRIBUTES *sftp_lstat(SFTP_SESSION *session, char *path); +/* sftp_lstat stats a file but doesn't follow symlinks */ +SFTP_ATTRIBUTES *sftp_fstat(SFTP_FILE *file); +void sftp_attributes_free(SFTP_ATTRIBUTES *file); +int sftp_dir_close(SFTP_DIR *dir); +int sftp_file_close(SFTP_FILE *file); +/* access are the sames than the ones from ansi fopen() */ +SFTP_FILE *sftp_open(SFTP_SESSION *session, char *file, int access, SFTP_ATTRIBUTES *attr); +int sftp_read(SFTP_FILE *file, void *dest, int len); +int sftp_write(SFTP_FILE *file, void *source, int len); +void sftp_seek(SFTP_FILE *file, int new_offset); +unsigned long sftp_tell(SFTP_FILE *file); +void sftp_rewind(SFTP_FILE *file); +int sftp_rm(SFTP_SESSION *sftp, char *file); +int sftp_rmdir(SFTP_SESSION *sftp, char *directory); +int sftp_mkdir(SFTP_SESSION *sftp, char *directory, SFTP_ATTRIBUTES *attr); +int sftp_rename(SFTP_SESSION *sftp, char *original, char *newname); +int sftp_setstat(SFTP_SESSION *sftp, char *file, SFTP_ATTRIBUTES *attr); +char *sftp_canonicalize_path(SFTP_SESSION *sftp, char *path); + +/* SFTP commands and constants */ +#define SSH_FXP_INIT 1 +#define SSH_FXP_VERSION 2 +#define SSH_FXP_OPEN 3 +#define SSH_FXP_CLOSE 4 +#define SSH_FXP_READ 5 +#define SSH_FXP_WRITE 6 +#define SSH_FXP_LSTAT 7 +#define SSH_FXP_FSTAT 8 +#define SSH_FXP_SETSTAT 9 +#define SSH_FXP_FSETSTAT 10 +#define SSH_FXP_OPENDIR 11 +#define SSH_FXP_READDIR 12 +#define SSH_FXP_REMOVE 13 +#define SSH_FXP_MKDIR 14 +#define SSH_FXP_RMDIR 15 +#define SSH_FXP_REALPATH 16 +#define SSH_FXP_STAT 17 +#define SSH_FXP_RENAME 18 +#define SSH_FXP_READLINK 19 +#define SSH_FXP_SYMLINK 20 + +#define SSH_FXP_STATUS 101 +#define SSH_FXP_HANDLE 102 +#define SSH_FXP_DATA 103 +#define SSH_FXP_NAME 104 +#define SSH_FXP_ATTRS 105 + +#define SSH_FXP_EXTENDED 200 +#define SSH_FXP_EXTENDED_REPLY 201 + +/* attributes */ +/* sftp draft is completely braindead : version 3 and 4 have different flags for same constants */ +/* and even worst, version 4 has same flag for 2 different constants */ +/* follow up : i won't develop any sftp4 compliant library before having a clarification */ + +#define SSH_FILEXFER_ATTR_SIZE 0x00000001 +#define SSH_FILEXFER_ATTR_PERMISSIONS 0x00000004 +#define SSH_FILEXFER_ATTR_ACCESSTIME 0x00000008 +#define SSH_FILEXFER_ATTR_ACMODTIME 0x00000008 +#define SSH_FILEXFER_ATTR_CREATETIME 0x00000010 +#define SSH_FILEXFER_ATTR_MODIFYTIME 0x00000020 +#define SSH_FILEXFER_ATTR_ACL 0x00000040 +#define SSH_FILEXFER_ATTR_OWNERGROUP 0x00000080 +#define SSH_FILEXFER_ATTR_SUBSECOND_TIMES 0x00000100 +#define SSH_FILEXFER_ATTR_EXTENDED 0x80000000 +#define SSH_FILEXFER_ATTR_UIDGID 0x00000002 + +/* types */ +#define SSH_FILEXFER_TYPE_REGULAR 1 +#define SSH_FILEXFER_TYPE_DIRECTORY 2 +#define SSH_FILEXFER_TYPE_SYMLINK 3 +#define SSH_FILEXFER_TYPE_SPECIAL 4 +#define SSH_FILEXFER_TYPE_UNKNOWN 5 + +/* server responses */ +#define SSH_FX_OK 0 +#define SSH_FX_EOF 1 +#define SSH_FX_NO_SUCH_FILE 2 +#define SSH_FX_PERMISSION_DENIED 3 +#define SSH_FX_FAILURE 4 +#define SSH_FX_BAD_MESSAGE 5 +#define SSH_FX_NO_CONNECTION 6 +#define SSH_FX_CONNECTION_LOST 7 +#define SSH_FX_OP_UNSUPPORTED 8 +#define SSH_FX_INVALID_HANDLE 9 +#define SSH_FX_NO_SUCH_PATH 10 +#define SSH_FX_FILE_ALREADY_EXISTS 11 +#define SSH_FX_WRITE_PROTECT 12 +#define SSH_FX_NO_MEDIA 13 + +/* file flags */ +#define SSH_FXF_READ 0x01 +#define SSH_FXF_WRITE 0x02 +#define SSH_FXF_APPEND 0x04 +#define SSH_FXF_CREAT 0x08 +#define SSH_FXF_TRUNC 0x10 +#define SSH_FXF_EXCL 0x20 +#define SSH_FXF_TEXT 0x40 + +#ifdef __cplusplus +} ; +#endif + +#endif /* SFTP_H */ diff --git a/include/libssh/ssh1.h b/include/libssh/ssh1.h new file mode 100644 index 00000000..ce67f20b --- /dev/null +++ b/include/libssh/ssh1.h @@ -0,0 +1,82 @@ +#ifndef __SSH1_H +#define __SSH1_H + +#define SSH_MSG_NONE 0 /* no message */ +#define SSH_MSG_DISCONNECT 1 /* cause (string) */ +#define SSH_SMSG_PUBLIC_KEY 2 /* ck,msk,srvk,hostk */ +#define SSH_CMSG_SESSION_KEY 3 /* key (BIGNUM) */ +#define SSH_CMSG_USER 4 /* user (string) */ +#define SSH_CMSG_AUTH_RHOSTS 5 /* user (string) */ +#define SSH_CMSG_AUTH_RSA 6 /* modulus (BIGNUM) */ +#define SSH_SMSG_AUTH_RSA_CHALLENGE 7 /* int (BIGNUM) */ +#define SSH_CMSG_AUTH_RSA_RESPONSE 8 /* int (BIGNUM) */ +#define SSH_CMSG_AUTH_PASSWORD 9 /* pass (string) */ +#define SSH_CMSG_REQUEST_PTY 10 /* TERM, tty modes */ +#define SSH_CMSG_WINDOW_SIZE 11 /* row,col,xpix,ypix */ +#define SSH_CMSG_EXEC_SHELL 12 /* */ +#define SSH_CMSG_EXEC_CMD 13 /* cmd (string) */ +#define SSH_SMSG_SUCCESS 14 /* */ +#define SSH_SMSG_FAILURE 15 /* */ +#define SSH_CMSG_STDIN_DATA 16 /* data (string) */ +#define SSH_SMSG_STDOUT_DATA 17 /* data (string) */ +#define SSH_SMSG_STDERR_DATA 18 /* data (string) */ +#define SSH_CMSG_EOF 19 /* */ +#define SSH_SMSG_EXITSTATUS 20 /* status (int) */ +#define SSH_MSG_CHANNEL_OPEN_CONFIRMATION 21 /* channel (int) */ +#define SSH_MSG_CHANNEL_OPEN_FAILURE 22 /* channel (int) */ +#define SSH_MSG_CHANNEL_DATA 23 /* ch,data (int,str) */ +#define SSH_MSG_CHANNEL_CLOSE 24 /* channel (int) */ +#define SSH_MSG_CHANNEL_CLOSE_CONFIRMATION 25 /* channel (int) */ +/* SSH_CMSG_X11_REQUEST_FORWARDING 26 OBSOLETE */ +#define SSH_SMSG_X11_OPEN 27 /* channel (int) */ +#define SSH_CMSG_PORT_FORWARD_REQUEST 28 /* p,host,hp (i,s,i) */ +#define SSH_MSG_PORT_OPEN 29 /* ch,h,p (i,s,i) */ +#define SSH_CMSG_AGENT_REQUEST_FORWARDING 30 /* */ +#define SSH_SMSG_AGENT_OPEN 31 /* port (int) */ +#define SSH_MSG_IGNORE 32 /* string */ +#define SSH_CMSG_EXIT_CONFIRMATION 33 /* */ +#define SSH_CMSG_X11_REQUEST_FORWARDING 34 /* proto,data (s,s) */ +#define SSH_CMSG_AUTH_RHOSTS_RSA 35 /* user,mod (s,mpi) */ +#define SSH_MSG_DEBUG 36 /* string */ +#define SSH_CMSG_REQUEST_COMPRESSION 37 /* level 1-9 (int) */ +#define SSH_CMSG_MAX_PACKET_SIZE 38 /* size 4k-1024k (int) */ +#define SSH_CMSG_AUTH_TIS 39 /* we use this for s/key */ +#define SSH_SMSG_AUTH_TIS_CHALLENGE 40 /* challenge (string) */ +#define SSH_CMSG_AUTH_TIS_RESPONSE 41 /* response (string) */ +#define SSH_CMSG_AUTH_KERBEROS 42 /* (KTEXT) */ +#define SSH_SMSG_AUTH_KERBEROS_RESPONSE 43 /* (KTEXT) */ +#define SSH_CMSG_HAVE_KERBEROS_TGT 44 /* credentials (s) */ +#define SSH_CMSG_HAVE_AFS_TOKEN 65 /* token (s) */ + +/* protocol version 1.5 overloads some version 1.3 message types */ +#define SSH_MSG_CHANNEL_INPUT_EOF SSH_MSG_CHANNEL_CLOSE +#define SSH_MSG_CHANNEL_OUTPUT_CLOSE SSH_MSG_CHANNEL_CLOSE_CONFIRMATION + +/* + * Authentication methods. New types can be added, but old types should not + * be removed for compatibility. The maximum allowed value is 31. + */ +#define SSH_AUTH_RHOSTS 1 +#define SSH_AUTH_RSA 2 +#define SSH_AUTH_PASSWORD 3 +#define SSH_AUTH_RHOSTS_RSA 4 +#define SSH_AUTH_TIS 5 +#define SSH_AUTH_KERBEROS 6 +#define SSH_PASS_KERBEROS_TGT 7 + /* 8 to 15 are reserved */ +#define SSH_PASS_AFS_TOKEN 21 + +/* Protocol flags. These are bit masks. */ +#define SSH_PROTOFLAG_SCREEN_NUMBER 1 /* X11 forwarding includes screen */ +#define SSH_PROTOFLAG_HOST_IN_FWD_OPEN 2 /* forwarding opens contain host */ + +/* cipher flags. they are bit numbers */ +#define SSH_CIPHER_NONE 0 /* No encryption */ +#define SSH_CIPHER_IDEA 1 /* IDEA in CFB mode */ +#define SSH_CIPHER_DES 2 /* DES in CBC mode */ +#define SSH_CIPHER_3DES 3 /* Triple-DES in CBC mode */ +#define SSH_CIPHER_RC4 5 /* RC4 */ +#define SSH_CIPHER_BLOWFISH 6 + +#endif + diff --git a/include/libssh/ssh2.h b/include/libssh/ssh2.h new file mode 100644 index 00000000..e6dc04f5 --- /dev/null +++ b/include/libssh/ssh2.h @@ -0,0 +1,69 @@ +#ifndef __SSH2_H +#define __SSH2_H + +#define SSH2_MSG_DISCONNECT 1 +#define SSH2_MSG_IGNORE 2 +#define SSH2_MSG_UNIMPLEMENTED 3 +#define SSH2_MSG_DEBUG 4 +#define SSH2_MSG_SERVICE_REQUEST 5 +#define SSH2_MSG_SERVICE_ACCEPT 6 + +#define SSH2_MSG_KEXINIT 20 +#define SSH2_MSG_NEWKEYS 21 + +#define SSH2_MSG_KEXDH_INIT 30 +#define SSH2_MSG_KEXDH_REPLY 31 + +#define SSH2_MSG_KEX_DH_GEX_REQUEST_OLD 30 +#define SSH2_MSG_KEX_DH_GEX_GROUP 31 +#define SSH2_MSG_KEX_DH_GEX_INIT 32 +#define SSH2_MSG_KEX_DH_GEX_REPLY 33 +#define SSH2_MSG_KEX_DH_GEX_REQUEST 34 +#define SSH2_MSG_USERAUTH_REQUEST 50 +#define SSH2_MSG_USERAUTH_FAILURE 51 +#define SSH2_MSG_USERAUTH_SUCCESS 52 +#define SSH2_MSG_USERAUTH_BANNER 53 +#define SSH2_MSG_USERAUTH_PK_OK 60 +#define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ 60 +#define SSH2_MSG_USERAUTH_INFO_REQUEST 60 +#define SSH2_MSG_USERAUTH_INFO_RESPONSE 61 +#define SSH2_MSG_GLOBAL_REQUEST 80 +#define SSH2_MSG_REQUEST_SUCCESS 81 +#define SSH2_MSG_REQUEST_FAILURE 82 +#define SSH2_MSG_CHANNEL_OPEN 90 +#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION 91 +#define SSH2_MSG_CHANNEL_OPEN_FAILURE 92 +#define SSH2_MSG_CHANNEL_WINDOW_ADJUST 93 +#define SSH2_MSG_CHANNEL_DATA 94 +#define SSH2_MSG_CHANNEL_EXTENDED_DATA 95 +#define SSH2_MSG_CHANNEL_EOF 96 +#define SSH2_MSG_CHANNEL_CLOSE 97 +#define SSH2_MSG_CHANNEL_REQUEST 98 +#define SSH2_MSG_CHANNEL_SUCCESS 99 +#define SSH2_MSG_CHANNEL_FAILURE 100 + +#define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT 1 +#define SSH2_DISCONNECT_PROTOCOL_ERROR 2 +#define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED 3 +#define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED 4 +#define SSH2_DISCONNECT_RESERVED 4 +#define SSH2_DISCONNECT_MAC_ERROR 5 +#define SSH2_DISCONNECT_COMPRESSION_ERROR 6 +#define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE 7 +#define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED 8 +#define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE 9 +#define SSH2_DISCONNECT_CONNECTION_LOST 10 +#define SSH2_DISCONNECT_BY_APPLICATION 11 +#define SSH2_DISCONNECT_TOO_MANY_CONNECTIONS 12 +#define SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER 13 +#define SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE 14 +#define SSH2_DISCONNECT_ILLEGAL_USER_NAME 15 + +#define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED 1 +#define SSH2_OPEN_CONNECT_FAILED 2 +#define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE 3 +#define SSH2_OPEN_RESOURCE_SHORTAGE 4 + +#define SSH2_EXTENDED_DATA_STDERR 1 + +#endif |