mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
Change all occurences of STRING * to ssh_string
This commit is contained in:
@@ -71,16 +71,31 @@ typedef unsigned long long uint64_t;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SSH_SAFE_NAMESPACE
|
||||||
typedef struct ssh_string_struct STRING;
|
typedef struct ssh_string_struct STRING;
|
||||||
|
#endif
|
||||||
typedef struct ssh_buffer_struct BUFFER;
|
typedef struct ssh_buffer_struct BUFFER;
|
||||||
typedef struct ssh_public_key_struct PUBLIC_KEY;
|
typedef struct ssh_public_key_struct PUBLIC_KEY;
|
||||||
typedef struct ssh_private_key_struct PRIVATE_KEY;
|
typedef struct ssh_private_key_struct PRIVATE_KEY;
|
||||||
typedef struct ssh_options_struct SSH_OPTIONS;
|
|
||||||
typedef struct ssh_channel_struct CHANNEL;
|
typedef struct ssh_channel_struct CHANNEL;
|
||||||
typedef struct ssh_agent_struct AGENT;
|
typedef struct ssh_agent_struct AGENT;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
typedef struct ssh_options_struct SSH_OPTIONS;
|
||||||
typedef struct ssh_session SSH_SESSION;
|
typedef struct ssh_session SSH_SESSION;
|
||||||
typedef struct ssh_kbdint SSH_KBDINT;
|
typedef struct ssh_kbdint SSH_KBDINT;
|
||||||
|
|
||||||
|
typedef struct ssh_string_struct* ssh_string;
|
||||||
|
typedef struct ssh_buffer_struct* ssh_buffer;
|
||||||
|
typedef struct ssh_public_key_struct* ssh_public_key;
|
||||||
|
typedef struct ssh_private_key_struct* ssh_private_key;
|
||||||
|
typedef struct ssh_options_struct* ssh_options;
|
||||||
|
typedef struct ssh_channel_struct* ssh_channel;
|
||||||
|
typedef struct ssh_agent_struct* ssh_agentT;
|
||||||
|
typedef struct ssh_session* ssh_session;
|
||||||
|
typedef struct ssh_kbdint* ssh_kbdint;
|
||||||
|
|
||||||
|
|
||||||
/* integer values */
|
/* integer values */
|
||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
typedef uint16_t u16;
|
typedef uint16_t u16;
|
||||||
@@ -217,19 +232,19 @@ const char *ssh_copyright(void);
|
|||||||
|
|
||||||
/* You can use these functions, they won't change */
|
/* You can use these functions, they won't change */
|
||||||
/* string_from_char returns a newly allocated string from a char *ptr */
|
/* string_from_char returns a newly allocated string from a char *ptr */
|
||||||
STRING *string_from_char(const char *what);
|
ssh_string string_from_char(const char *what);
|
||||||
/* it returns the string len in host byte orders. str->size is big endian warning ! */
|
/* it returns the string len in host byte orders. str->size is big endian warning ! */
|
||||||
size_t string_len(STRING *str);
|
size_t string_len(ssh_string str);
|
||||||
STRING *string_new(size_t size);
|
ssh_string string_new(size_t size);
|
||||||
/* string_fill copies the data in the string. */
|
/* string_fill copies the data in the string. */
|
||||||
int string_fill(STRING *str, const void *data, size_t len);
|
int string_fill(ssh_string str, const void *data, size_t len);
|
||||||
/* returns a newly allocated char array with the str string and a final nul caracter */
|
/* returns a newly allocated char array with the str string and a final nul caracter */
|
||||||
char *string_to_char(STRING *str);
|
char *string_to_char(ssh_string str);
|
||||||
STRING *string_copy(STRING *str);
|
ssh_string string_copy(ssh_string str);
|
||||||
/* burns the data inside a string */
|
/* burns the data inside a string */
|
||||||
void string_burn(STRING *str);
|
void string_burn(ssh_string str);
|
||||||
void *string_data(STRING *str);
|
void *string_data(ssh_string str);
|
||||||
void string_free(STRING *str);
|
void string_free(ssh_string str);
|
||||||
|
|
||||||
/* useful for debug */
|
/* useful for debug */
|
||||||
char *ssh_get_hexa(const unsigned char *what, size_t len);
|
char *ssh_get_hexa(const unsigned char *what, size_t len);
|
||||||
@@ -238,7 +253,7 @@ int ssh_get_random(void *where,int len,int strong);
|
|||||||
|
|
||||||
/* this one can be called by the client to see the hash of the public key before accepting it */
|
/* 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, unsigned char **hash);
|
int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash);
|
||||||
STRING *ssh_get_pubkey(SSH_SESSION *session);
|
ssh_string ssh_get_pubkey(SSH_SESSION *session);
|
||||||
|
|
||||||
/* in connect.c */
|
/* in connect.c */
|
||||||
int ssh_fd_poll(SSH_SESSION *session,int *write, int *except);
|
int ssh_fd_poll(SSH_SESSION *session,int *write, int *except);
|
||||||
@@ -251,10 +266,10 @@ void publickey_free(PUBLIC_KEY *key);
|
|||||||
|
|
||||||
PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
PRIVATE_KEY *privatekey_from_file(SSH_SESSION *session, const char *filename,
|
||||||
int type, const char *passphrase);
|
int type, const char *passphrase);
|
||||||
STRING *publickey_to_string(PUBLIC_KEY *key);
|
ssh_string publickey_to_string(PUBLIC_KEY *key);
|
||||||
PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv);
|
PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv);
|
||||||
void privatekey_free(PRIVATE_KEY *prv);
|
void privatekey_free(PRIVATE_KEY *prv);
|
||||||
STRING *publickey_from_file(SSH_SESSION *session, const char *filename,
|
ssh_string publickey_from_file(SSH_SESSION *session, const char *filename,
|
||||||
int *type);
|
int *type);
|
||||||
int ssh_is_server_known(SSH_SESSION *session);
|
int ssh_is_server_known(SSH_SESSION *session);
|
||||||
int ssh_write_knownhost(SSH_SESSION *session);
|
int ssh_write_knownhost(SSH_SESSION *session);
|
||||||
@@ -359,8 +374,8 @@ int ssh_auth_list(SSH_SESSION *session);
|
|||||||
int ssh_userauth_list(SSH_SESSION *session, const char *username);
|
int ssh_userauth_list(SSH_SESSION *session, const char *username);
|
||||||
int ssh_userauth_none(SSH_SESSION *session, const char *username);
|
int ssh_userauth_none(SSH_SESSION *session, const char *username);
|
||||||
int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
|
int ssh_userauth_password(SSH_SESSION *session, const char *username, const char *password);
|
||||||
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, int type, STRING *publickey);
|
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username, int type, ssh_string publickey);
|
||||||
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, STRING *publickey, PRIVATE_KEY *privatekey);
|
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username, ssh_string publickey, PRIVATE_KEY *privatekey);
|
||||||
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
|
||||||
PUBLIC_KEY *publickey);
|
PUBLIC_KEY *publickey);
|
||||||
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase);
|
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase);
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ typedef struct signature_struct {
|
|||||||
gcry_sexp_t rsa_sign;
|
gcry_sexp_t rsa_sign;
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
DSA_SIG *dsa_sign;
|
DSA_SIG *dsa_sign;
|
||||||
STRING *rsa_sign;
|
ssh_string rsa_sign;
|
||||||
#endif
|
#endif
|
||||||
} SIGNATURE;
|
} SIGNATURE;
|
||||||
|
|
||||||
@@ -287,7 +287,7 @@ typedef struct ssh_crypto_struct {
|
|||||||
unsigned char decryptMAC[SHA_DIGEST_LEN];
|
unsigned char decryptMAC[SHA_DIGEST_LEN];
|
||||||
unsigned char hmacbuf[EVP_MAX_MD_SIZE];
|
unsigned char hmacbuf[EVP_MAX_MD_SIZE];
|
||||||
struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
|
struct crypto_struct *in_cipher, *out_cipher; /* the cipher structures/objects */
|
||||||
STRING *server_pubkey;
|
ssh_string server_pubkey;
|
||||||
const char *server_pubkey_type;
|
const char *server_pubkey_type;
|
||||||
int do_compress_out; /* idem */
|
int do_compress_out; /* idem */
|
||||||
int do_compress_in; /* don't set them, set the option instead */
|
int do_compress_in; /* don't set them, set the option instead */
|
||||||
@@ -355,7 +355,7 @@ struct ssh_session {
|
|||||||
/* socket status */
|
/* socket status */
|
||||||
int blocking; // functions should block
|
int blocking; // functions should block
|
||||||
|
|
||||||
STRING *banner; /* that's the issue banner from
|
ssh_string banner; /* that's the issue banner from
|
||||||
the server */
|
the server */
|
||||||
char *remotebanner; /* that's the SSH- banner from
|
char *remotebanner; /* that's the SSH- banner from
|
||||||
remote host. */
|
remote host. */
|
||||||
@@ -369,7 +369,7 @@ struct ssh_session {
|
|||||||
/* where it was before being interrupted */
|
/* where it was before being interrupted */
|
||||||
int packet_state;
|
int packet_state;
|
||||||
int dh_handshake_state;
|
int dh_handshake_state;
|
||||||
STRING *dh_server_signature; //information used by dh_handshake.
|
ssh_string dh_server_signature; //information used by dh_handshake.
|
||||||
|
|
||||||
KEX server_kex;
|
KEX server_kex;
|
||||||
KEX client_kex;
|
KEX client_kex;
|
||||||
@@ -449,7 +449,7 @@ struct ssh_channel_request {
|
|||||||
u32 height;
|
u32 height;
|
||||||
u32 pxwidth;
|
u32 pxwidth;
|
||||||
u32 pxheight;
|
u32 pxheight;
|
||||||
STRING *modes;
|
ssh_string modes;
|
||||||
|
|
||||||
/* env type request */
|
/* env type request */
|
||||||
char *var_name;
|
char *var_name;
|
||||||
@@ -504,7 +504,7 @@ struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session *session,
|
|||||||
struct ssh_public_key_struct *agent_get_first_ident(struct ssh_session *session,
|
struct ssh_public_key_struct *agent_get_first_ident(struct ssh_session *session,
|
||||||
char **comment);
|
char **comment);
|
||||||
|
|
||||||
STRING *agent_sign_data(struct ssh_session *session,
|
ssh_string agent_sign_data(struct ssh_session *session,
|
||||||
struct ssh_buffer_struct *data,
|
struct ssh_buffer_struct *data,
|
||||||
struct ssh_public_key_struct *pubkey);
|
struct ssh_public_key_struct *pubkey);
|
||||||
#endif
|
#endif
|
||||||
@@ -597,11 +597,11 @@ int dh_generate_y(SSH_SESSION *session);
|
|||||||
int ssh_crypto_init(void);
|
int ssh_crypto_init(void);
|
||||||
void ssh_crypto_finalize(void);
|
void ssh_crypto_finalize(void);
|
||||||
|
|
||||||
STRING *dh_get_e(SSH_SESSION *session);
|
ssh_string dh_get_e(SSH_SESSION *session);
|
||||||
STRING *dh_get_f(SSH_SESSION *session);
|
ssh_string dh_get_f(SSH_SESSION *session);
|
||||||
int dh_import_f(SSH_SESSION *session,STRING *f_string);
|
int dh_import_f(SSH_SESSION *session,ssh_string f_string);
|
||||||
int dh_import_e(SSH_SESSION *session, STRING *e_string);
|
int dh_import_e(SSH_SESSION *session, ssh_string e_string);
|
||||||
void dh_import_pubkey(SSH_SESSION *session,STRING *pubkey_string);
|
void dh_import_pubkey(SSH_SESSION *session,ssh_string pubkey_string);
|
||||||
int dh_build_k(SSH_SESSION *session);
|
int dh_build_k(SSH_SESSION *session);
|
||||||
int make_sessionid(SSH_SESSION *session);
|
int make_sessionid(SSH_SESSION *session);
|
||||||
/* add data for the final cookie */
|
/* add data for the final cookie */
|
||||||
@@ -609,9 +609,9 @@ int hashbufin_add_cookie(SSH_SESSION *session, unsigned char *cookie);
|
|||||||
int hashbufout_add_cookie(SSH_SESSION *session);
|
int hashbufout_add_cookie(SSH_SESSION *session);
|
||||||
int generate_session_keys(SSH_SESSION *session);
|
int generate_session_keys(SSH_SESSION *session);
|
||||||
/* returns 1 if server signature ok, 0 otherwise. The NEXT crypto is checked, not the current one */
|
/* 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);
|
int signature_verify(SSH_SESSION *session,ssh_string signature);
|
||||||
bignum make_string_bn(STRING *string);
|
bignum make_string_bn(ssh_string string);
|
||||||
STRING *make_bignum_string(bignum num);
|
ssh_string make_bignum_string(bignum num);
|
||||||
|
|
||||||
/* in crypt.c */
|
/* in crypt.c */
|
||||||
u32 packet_decrypt_len(SSH_SESSION *session,char *crypted);
|
u32 packet_decrypt_len(SSH_SESSION *session,char *crypted);
|
||||||
@@ -652,7 +652,7 @@ char *ssh_find_matching(const char *in_d, const char *what_d);
|
|||||||
|
|
||||||
PRIVATE_KEY *_privatekey_from_file(void *session, const char *filename,
|
PRIVATE_KEY *_privatekey_from_file(void *session, const char *filename,
|
||||||
int type);
|
int type);
|
||||||
STRING *try_publickey_from_file(SSH_SESSION *session,
|
ssh_string try_publickey_from_file(SSH_SESSION *session,
|
||||||
struct ssh_keys_struct keytab,
|
struct ssh_keys_struct keytab,
|
||||||
char **privkeyfile, int *type);
|
char **privkeyfile, int *type);
|
||||||
|
|
||||||
@@ -663,19 +663,19 @@ int ssh_type_from_name(const char *name);
|
|||||||
PRIVATE_KEY *privatekey_make_dss(SSH_SESSION *session, BUFFER *buffer);
|
PRIVATE_KEY *privatekey_make_dss(SSH_SESSION *session, BUFFER *buffer);
|
||||||
PRIVATE_KEY *privatekey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
|
PRIVATE_KEY *privatekey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
|
||||||
const char *type);
|
const char *type);
|
||||||
PRIVATE_KEY *privatekey_from_string(SSH_SESSION *session, STRING *privkey_s);
|
PRIVATE_KEY *privatekey_from_string(SSH_SESSION *session, ssh_string privkey_s);
|
||||||
|
|
||||||
PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer);
|
PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer);
|
||||||
PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer, int type);
|
PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer, int type);
|
||||||
PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, STRING *pubkey_s);
|
PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, ssh_string pubkey_s);
|
||||||
SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,PUBLIC_KEY *pubkey,int needed_type);
|
SIGNATURE *signature_from_string(SSH_SESSION *session, ssh_string signature,PUBLIC_KEY *pubkey,int needed_type);
|
||||||
void signature_free(SIGNATURE *sign);
|
void signature_free(SIGNATURE *sign);
|
||||||
STRING *ssh_do_sign_with_agent(struct ssh_session *session,
|
ssh_string ssh_do_sign_with_agent(struct ssh_session *session,
|
||||||
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey);
|
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey);
|
||||||
STRING *ssh_do_sign(SSH_SESSION *session,BUFFER *sigbuf,
|
ssh_string ssh_do_sign(SSH_SESSION *session,BUFFER *sigbuf,
|
||||||
PRIVATE_KEY *privatekey);
|
PRIVATE_KEY *privatekey);
|
||||||
STRING *ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey);
|
ssh_string ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey);
|
||||||
STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key);
|
ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, PUBLIC_KEY *key);
|
||||||
/* channel.c */
|
/* channel.c */
|
||||||
void channel_handle(SSH_SESSION *session, int type);
|
void channel_handle(SSH_SESSION *session, int type);
|
||||||
CHANNEL *channel_new(SSH_SESSION *session);
|
CHANNEL *channel_new(SSH_SESSION *session);
|
||||||
@@ -692,7 +692,7 @@ 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 */
|
/* buffer.c */
|
||||||
int buffer_add_ssh_string(BUFFER *buffer, STRING *string);
|
int buffer_add_ssh_string(BUFFER *buffer, ssh_string string);
|
||||||
int buffer_add_u8(BUFFER *buffer, u8 data);
|
int buffer_add_u8(BUFFER *buffer, u8 data);
|
||||||
int buffer_add_u32(BUFFER *buffer, u32 data);
|
int buffer_add_u32(BUFFER *buffer, u32 data);
|
||||||
int buffer_add_u64(BUFFER *buffer, u64 data);
|
int buffer_add_u64(BUFFER *buffer, u64 data);
|
||||||
@@ -713,9 +713,9 @@ int buffer_get_u64(BUFFER *buffer, u64 *data);
|
|||||||
|
|
||||||
u32 buffer_get_data(BUFFER *buffer, void *data, u32 requestedlen);
|
u32 buffer_get_data(BUFFER *buffer, void *data, u32 requestedlen);
|
||||||
/* buffer_get_ssh_string() is an exception. if the String read is too large or invalid, it will answer NULL. */
|
/* 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);
|
ssh_string buffer_get_ssh_string(BUFFER *buffer);
|
||||||
/* gets a string out of a SSH-1 mpint */
|
/* gets a string out of a SSH-1 mpint */
|
||||||
STRING *buffer_get_mpint(BUFFER *buffer);
|
ssh_string buffer_get_mpint(BUFFER *buffer);
|
||||||
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
|
/* buffer_pass_bytes acts as if len bytes have been read (used for padding) */
|
||||||
u32 buffer_pass_bytes_end(BUFFER *buffer, u32 len);
|
u32 buffer_pass_bytes_end(BUFFER *buffer, u32 len);
|
||||||
u32 buffer_pass_bytes(BUFFER *buffer, u32 len);
|
u32 buffer_pass_bytes(BUFFER *buffer, u32 len);
|
||||||
@@ -740,7 +740,7 @@ u32 ssh_crc32(const char *buf, u32 len);
|
|||||||
/* auth1.c */
|
/* auth1.c */
|
||||||
int ssh_userauth1_none(SSH_SESSION *session, const char *username);
|
int ssh_userauth1_none(SSH_SESSION *session, const char *username);
|
||||||
int ssh_userauth1_offer_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth1_offer_pubkey(SSH_SESSION *session, const char *username,
|
||||||
int type, STRING *pubkey);
|
int type, ssh_string pubkey);
|
||||||
int ssh_userauth1_password(SSH_SESSION *session, const char *username,
|
int ssh_userauth1_password(SSH_SESSION *session, const char *username,
|
||||||
const char *password);
|
const char *password);
|
||||||
/* in misc.c */
|
/* in misc.c */
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ typedef struct sftp_file{
|
|||||||
SFTP_SESSION *sftp;
|
SFTP_SESSION *sftp;
|
||||||
char *name;
|
char *name;
|
||||||
u64 offset;
|
u64 offset;
|
||||||
STRING *handle;
|
ssh_string handle;
|
||||||
int eof;
|
int eof;
|
||||||
int nonblocking;
|
int nonblocking;
|
||||||
} SFTP_FILE ;
|
} SFTP_FILE ;
|
||||||
@@ -89,7 +89,7 @@ typedef struct sftp_file{
|
|||||||
typedef struct sftp_dir {
|
typedef struct sftp_dir {
|
||||||
SFTP_SESSION *sftp;
|
SFTP_SESSION *sftp;
|
||||||
char *name;
|
char *name;
|
||||||
STRING *handle; /* handle to directory */
|
ssh_string handle; /* handle to directory */
|
||||||
BUFFER *buffer; /* contains raw attributes from server which haven't been parsed */
|
BUFFER *buffer; /* contains raw attributes from server which haven't been parsed */
|
||||||
u32 count; /* counts the number of following attributes structures into buffer */
|
u32 count; /* counts the number of following attributes structures into buffer */
|
||||||
int eof; /* end of directory listing */
|
int eof; /* end of directory listing */
|
||||||
@@ -110,12 +110,12 @@ typedef struct sftp_client_message{
|
|||||||
char *filename; /* can be "path" */
|
char *filename; /* can be "path" */
|
||||||
u32 flags;
|
u32 flags;
|
||||||
struct sftp_attributes *attr;
|
struct sftp_attributes *attr;
|
||||||
STRING *handle;
|
ssh_string handle;
|
||||||
u64 offset;
|
u64 offset;
|
||||||
u32 len;
|
u32 len;
|
||||||
int attr_num;
|
int attr_num;
|
||||||
BUFFER *attrbuf; /* used by sftp_reply_attrs */
|
BUFFER *attrbuf; /* used by sftp_reply_attrs */
|
||||||
STRING *data; /* can be newpath of rename() */
|
ssh_string data; /* can be newpath of rename() */
|
||||||
} SFTP_CLIENT_MESSAGE;
|
} SFTP_CLIENT_MESSAGE;
|
||||||
|
|
||||||
typedef struct request_queue{
|
typedef struct request_queue{
|
||||||
@@ -127,8 +127,8 @@ typedef struct request_queue{
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
u32 id;
|
u32 id;
|
||||||
u32 status;
|
u32 status;
|
||||||
STRING *error;
|
ssh_string error;
|
||||||
STRING *lang;
|
ssh_string lang;
|
||||||
char *errormsg;
|
char *errormsg;
|
||||||
char *langmsg;
|
char *langmsg;
|
||||||
} STATUS_MESSAGE;
|
} STATUS_MESSAGE;
|
||||||
@@ -153,10 +153,10 @@ typedef struct sftp_attributes{
|
|||||||
u64 mtime64;
|
u64 mtime64;
|
||||||
u32 mtime;
|
u32 mtime;
|
||||||
u32 mtime_nseconds;
|
u32 mtime_nseconds;
|
||||||
STRING *acl;
|
ssh_string acl;
|
||||||
u32 extended_count;
|
u32 extended_count;
|
||||||
STRING *extended_type;
|
ssh_string extended_type;
|
||||||
STRING *extended_data;
|
ssh_string extended_data;
|
||||||
} SFTP_ATTRIBUTES;
|
} SFTP_ATTRIBUTES;
|
||||||
|
|
||||||
#define LIBSFTP_VERSION 3
|
#define LIBSFTP_VERSION 3
|
||||||
@@ -647,10 +647,10 @@ SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp);
|
|||||||
void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg);
|
void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg);
|
||||||
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
|
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
|
||||||
SFTP_ATTRIBUTES *attr);
|
SFTP_ATTRIBUTES *attr);
|
||||||
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle);
|
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, ssh_string handle);
|
||||||
STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info);
|
ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info);
|
||||||
int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);
|
int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr);
|
||||||
void *sftp_handle(SFTP_SESSION *sftp, STRING *handle);
|
void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle);
|
||||||
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, const char *message);
|
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status, const char *message);
|
||||||
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
|
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
|
||||||
const char *longname, SFTP_ATTRIBUTES *attr);
|
const char *longname, SFTP_ATTRIBUTES *attr);
|
||||||
|
|||||||
@@ -394,7 +394,7 @@ struct ssh_public_key_struct *agent_get_next_ident(struct ssh_session *session,
|
|||||||
return pubkey;
|
return pubkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *agent_sign_data(struct ssh_session *session,
|
ssh_string agent_sign_data(struct ssh_session *session,
|
||||||
struct ssh_buffer_struct *data,
|
struct ssh_buffer_struct *data,
|
||||||
struct ssh_public_key_struct *pubkey) {
|
struct ssh_public_key_struct *pubkey) {
|
||||||
struct ssh_string_struct *blob = NULL;
|
struct ssh_string_struct *blob = NULL;
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ static int ask_userauth(SSH_SESSION *session) {
|
|||||||
|
|
||||||
static int wait_auth_status(SSH_SESSION *session, int kbdint) {
|
static int wait_auth_status(SSH_SESSION *session, int kbdint) {
|
||||||
char *auth_methods = NULL;
|
char *auth_methods = NULL;
|
||||||
STRING *auth;
|
ssh_string auth;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
int cont = 1;
|
int cont = 1;
|
||||||
u8 partial = 0;
|
u8 partial = 0;
|
||||||
@@ -139,7 +139,7 @@ static int wait_auth_status(SSH_SESSION *session, int kbdint) {
|
|||||||
break;
|
break;
|
||||||
case SSH2_MSG_USERAUTH_BANNER:
|
case SSH2_MSG_USERAUTH_BANNER:
|
||||||
{
|
{
|
||||||
STRING *banner;
|
ssh_string banner;
|
||||||
|
|
||||||
banner = buffer_get_ssh_string(session->in_buffer);
|
banner = buffer_get_ssh_string(session->in_buffer);
|
||||||
if (banner == NULL) {
|
if (banner == NULL) {
|
||||||
@@ -201,9 +201,9 @@ int ssh_userauth_list(SSH_SESSION *session, const char *username) {
|
|||||||
* SSH_AUTH_SUCCESS: Authentication success
|
* SSH_AUTH_SUCCESS: Authentication success
|
||||||
*/
|
*/
|
||||||
int ssh_userauth_none(SSH_SESSION *session, const char *username) {
|
int ssh_userauth_none(SSH_SESSION *session, const char *username) {
|
||||||
STRING *user = NULL;
|
ssh_string user = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -305,11 +305,11 @@ error:
|
|||||||
* @see ssh_userauth_pubkey()
|
* @see ssh_userauth_pubkey()
|
||||||
*/
|
*/
|
||||||
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth_offer_pubkey(SSH_SESSION *session, const char *username,
|
||||||
int type, STRING *publickey) {
|
int type, ssh_string publickey) {
|
||||||
STRING *user = NULL;
|
ssh_string user = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
STRING *algo = NULL;
|
ssh_string algo = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -418,12 +418,12 @@ error:
|
|||||||
* @see ssh_userauth_offer_pubkey()
|
* @see ssh_userauth_offer_pubkey()
|
||||||
*/
|
*/
|
||||||
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth_pubkey(SSH_SESSION *session, const char *username,
|
||||||
STRING *publickey, PRIVATE_KEY *privatekey) {
|
ssh_string publickey, PRIVATE_KEY *privatekey) {
|
||||||
STRING *user = NULL;
|
ssh_string user = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
STRING *algo = NULL;
|
ssh_string algo = NULL;
|
||||||
STRING *sign = NULL;
|
ssh_string sign = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -538,12 +538,12 @@ error:
|
|||||||
*/
|
*/
|
||||||
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
|
int ssh_userauth_agent_pubkey(SSH_SESSION *session, const char *username,
|
||||||
PUBLIC_KEY *publickey) {
|
PUBLIC_KEY *publickey) {
|
||||||
STRING *user = NULL;
|
ssh_string user = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
STRING *algo = NULL;
|
ssh_string algo = NULL;
|
||||||
STRING *key = NULL;
|
ssh_string key = NULL;
|
||||||
STRING *sign = NULL;
|
ssh_string sign = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -663,10 +663,10 @@ error:
|
|||||||
*/
|
*/
|
||||||
int ssh_userauth_password(SSH_SESSION *session, const char *username,
|
int ssh_userauth_password(SSH_SESSION *session, const char *username,
|
||||||
const char *password) {
|
const char *password) {
|
||||||
STRING *user = NULL;
|
ssh_string user = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
STRING *pwd = NULL;
|
ssh_string pwd = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -796,7 +796,7 @@ static struct ssh_keys_struct keytab[] = {
|
|||||||
*/
|
*/
|
||||||
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
|
int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) {
|
||||||
struct ssh_public_key_struct *publickey;
|
struct ssh_public_key_struct *publickey;
|
||||||
STRING *pubkey;
|
ssh_string pubkey;
|
||||||
PRIVATE_KEY *privkey;
|
PRIVATE_KEY *privkey;
|
||||||
char *privkeyfile = NULL;
|
char *privkeyfile = NULL;
|
||||||
char *id = NULL;
|
char *id = NULL;
|
||||||
@@ -1075,10 +1075,10 @@ static void kbdint_clean(struct ssh_kbdint *kbd) {
|
|||||||
* of the draft */
|
* of the draft */
|
||||||
static int kbdauth_init(SSH_SESSION *session, const char *user,
|
static int kbdauth_init(SSH_SESSION *session, const char *user,
|
||||||
const char *submethods) {
|
const char *submethods) {
|
||||||
STRING *usr = NULL;
|
ssh_string usr = NULL;
|
||||||
STRING *sub = NULL;
|
ssh_string sub = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -1134,9 +1134,9 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int kbdauth_info_get(SSH_SESSION *session) {
|
static int kbdauth_info_get(SSH_SESSION *session) {
|
||||||
STRING *name; /* name of the "asking" window showed to client */
|
ssh_string name; /* name of the "asking" window showed to client */
|
||||||
STRING *instruction;
|
ssh_string instruction;
|
||||||
STRING *tmp;
|
ssh_string tmp;
|
||||||
u32 nprompts;
|
u32 nprompts;
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
@@ -1251,7 +1251,7 @@ static int kbdauth_info_get(SSH_SESSION *session) {
|
|||||||
|
|
||||||
/* sends challenge back to the server */
|
/* sends challenge back to the server */
|
||||||
static int kbdauth_send(SSH_SESSION *session) {
|
static int kbdauth_send(SSH_SESSION *session) {
|
||||||
STRING *answer = NULL;
|
ssh_string answer = NULL;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
u32 i;
|
u32 i;
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ u32 ssh_channel_new_id(SSH_SESSION *session) {
|
|||||||
static int channel_open(CHANNEL *channel, const char *type_c, int window,
|
static int channel_open(CHANNEL *channel, const char *type_c, int window,
|
||||||
int maxpacket, BUFFER *payload) {
|
int maxpacket, BUFFER *payload) {
|
||||||
SSH_SESSION *session = channel->session;
|
SSH_SESSION *session = channel->session;
|
||||||
STRING *type = NULL;
|
ssh_string type = NULL;
|
||||||
u32 tmp = 0;
|
u32 tmp = 0;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -196,7 +196,7 @@ static int channel_open(CHANNEL *channel, const char *type_c, int window,
|
|||||||
return 0;
|
return 0;
|
||||||
case SSH2_MSG_CHANNEL_OPEN_FAILURE:
|
case SSH2_MSG_CHANNEL_OPEN_FAILURE:
|
||||||
{
|
{
|
||||||
STRING *error_s;
|
ssh_string error_s;
|
||||||
char *error;
|
char *error;
|
||||||
u32 code;
|
u32 code;
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ static void channel_rcv_change_window(SSH_SESSION *session) {
|
|||||||
/* is_stderr is set to 1 if the data are extended, ie stderr */
|
/* is_stderr is set to 1 if the data are extended, ie stderr */
|
||||||
static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
|
static void channel_rcv_data(SSH_SESSION *session,int is_stderr) {
|
||||||
CHANNEL *channel;
|
CHANNEL *channel;
|
||||||
STRING *str;
|
ssh_string str;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -469,7 +469,7 @@ static void channel_rcv_close(SSH_SESSION *session) {
|
|||||||
|
|
||||||
static void channel_rcv_request(SSH_SESSION *session) {
|
static void channel_rcv_request(SSH_SESSION *session) {
|
||||||
CHANNEL *channel;
|
CHANNEL *channel;
|
||||||
STRING *request_s;
|
ssh_string request_s;
|
||||||
char *request;
|
char *request;
|
||||||
u32 status;
|
u32 status;
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ static void channel_rcv_request(SSH_SESSION *session) {
|
|||||||
|
|
||||||
if (strcmp(request, "exit-signal") == 0) {
|
if (strcmp(request, "exit-signal") == 0) {
|
||||||
const char *core = "(core dumped)";
|
const char *core = "(core dumped)";
|
||||||
STRING *signal_s;
|
ssh_string signal_s;
|
||||||
char *signal;
|
char *signal;
|
||||||
u8 i;
|
u8 i;
|
||||||
|
|
||||||
@@ -674,7 +674,7 @@ int channel_open_forward(CHANNEL *channel, const char *remotehost,
|
|||||||
int remoteport, const char *sourcehost, int localport) {
|
int remoteport, const char *sourcehost, int localport) {
|
||||||
SSH_SESSION *session = channel->session;
|
SSH_SESSION *session = channel->session;
|
||||||
BUFFER *payload = NULL;
|
BUFFER *payload = NULL;
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -1007,7 +1007,7 @@ void channel_set_blocking(CHANNEL *channel, int blocking) {
|
|||||||
static int channel_request(CHANNEL *channel, const char *request,
|
static int channel_request(CHANNEL *channel, const char *request,
|
||||||
BUFFER *buffer, int reply) {
|
BUFFER *buffer, int reply) {
|
||||||
SSH_SESSION *session = channel->session;
|
SSH_SESSION *session = channel->session;
|
||||||
STRING *req = NULL;
|
ssh_string req = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -1085,7 +1085,7 @@ error:
|
|||||||
int channel_request_pty_size(CHANNEL *channel, const char *terminal,
|
int channel_request_pty_size(CHANNEL *channel, const char *terminal,
|
||||||
int col, int row) {
|
int col, int row) {
|
||||||
SSH_SESSION *session = channel->session;
|
SSH_SESSION *session = channel->session;
|
||||||
STRING *term = NULL;
|
ssh_string term = NULL;
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
@@ -1216,7 +1216,7 @@ int channel_request_shell(CHANNEL *channel) {
|
|||||||
*/
|
*/
|
||||||
int channel_request_subsystem(CHANNEL *channel, const char *sys) {
|
int channel_request_subsystem(CHANNEL *channel, const char *sys) {
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
STRING *subsystem = NULL;
|
ssh_string subsystem = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
buffer = buffer_new();
|
buffer = buffer_new();
|
||||||
@@ -1260,7 +1260,7 @@ int channel_request_sftp( CHANNEL *channel){
|
|||||||
* */
|
* */
|
||||||
int channel_request_env(CHANNEL *channel, const char *name, const char *value) {
|
int channel_request_env(CHANNEL *channel, const char *name, const char *value) {
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
buffer = buffer_new();
|
buffer = buffer_new();
|
||||||
@@ -1311,7 +1311,7 @@ error:
|
|||||||
*/
|
*/
|
||||||
int channel_request_exec(CHANNEL *channel, const char *cmd) {
|
int channel_request_exec(CHANNEL *channel, const char *cmd) {
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
STRING *command = NULL;
|
ssh_string command = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
#ifdef HAVE_SSH1
|
#ifdef HAVE_SSH1
|
||||||
|
|||||||
@@ -190,10 +190,10 @@ int ssh_send_banner(SSH_SESSION *session, int server) {
|
|||||||
#define DH_STATE_NEWKEYS_SENT 4
|
#define DH_STATE_NEWKEYS_SENT 4
|
||||||
#define DH_STATE_FINISHED 5
|
#define DH_STATE_FINISHED 5
|
||||||
static int dh_handshake(SSH_SESSION *session) {
|
static int dh_handshake(SSH_SESSION *session) {
|
||||||
STRING *e = NULL;
|
ssh_string e = NULL;
|
||||||
STRING *f = NULL;
|
ssh_string f = NULL;
|
||||||
STRING *pubkey = NULL;
|
ssh_string pubkey = NULL;
|
||||||
STRING *signature = NULL;
|
ssh_string signature = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -400,7 +400,7 @@ error:
|
|||||||
* @return 0 on success, < 0 on error.
|
* @return 0 on success, < 0 on error.
|
||||||
*/
|
*/
|
||||||
int ssh_service_request(SSH_SESSION *session, const char *service) {
|
int ssh_service_request(SSH_SESSION *session, const char *service) {
|
||||||
STRING *service_s = NULL;
|
ssh_string service_s = NULL;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
|
|
||||||
@@ -621,7 +621,7 @@ char *ssh_get_issue_banner(SSH_SESSION *session) {
|
|||||||
* @param session The SSH session to disconnect.
|
* @param session The SSH session to disconnect.
|
||||||
*/
|
*/
|
||||||
void ssh_disconnect(SSH_SESSION *session) {
|
void ssh_disconnect(SSH_SESSION *session) {
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
|
|
||||||
if (session == NULL) {
|
if (session == NULL) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
32
libssh/dh.c
32
libssh/dh.c
@@ -324,8 +324,8 @@ int dh_generate_f(SSH_SESSION *session) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *make_bignum_string(bignum num) {
|
ssh_string make_bignum_string(bignum num) {
|
||||||
STRING *ptr = NULL;
|
ssh_string ptr = NULL;
|
||||||
int pad = 0;
|
int pad = 0;
|
||||||
unsigned int len = bignum_num_bytes(num);
|
unsigned int len = bignum_num_bytes(num);
|
||||||
unsigned int bits = bignum_num_bits(num);
|
unsigned int bits = bignum_num_bits(num);
|
||||||
@@ -358,7 +358,7 @@ STRING *make_bignum_string(bignum num) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bignum make_string_bn(STRING *string){
|
bignum make_string_bn(ssh_string string){
|
||||||
bignum bn = NULL;
|
bignum bn = NULL;
|
||||||
unsigned int len = string_len(string);
|
unsigned int len = string_len(string);
|
||||||
|
|
||||||
@@ -376,20 +376,20 @@ bignum make_string_bn(STRING *string){
|
|||||||
return bn;
|
return bn;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *dh_get_e(SSH_SESSION *session) {
|
ssh_string dh_get_e(SSH_SESSION *session) {
|
||||||
return make_bignum_string(session->next_crypto->e);
|
return make_bignum_string(session->next_crypto->e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* used by server */
|
/* used by server */
|
||||||
STRING *dh_get_f(SSH_SESSION *session) {
|
ssh_string dh_get_f(SSH_SESSION *session) {
|
||||||
return make_bignum_string(session->next_crypto->f);
|
return make_bignum_string(session->next_crypto->f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dh_import_pubkey(SSH_SESSION *session, STRING *pubkey_string) {
|
void dh_import_pubkey(SSH_SESSION *session, ssh_string pubkey_string) {
|
||||||
session->next_crypto->server_pubkey = pubkey_string;
|
session->next_crypto->server_pubkey = pubkey_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dh_import_f(SSH_SESSION *session, STRING *f_string) {
|
int dh_import_f(SSH_SESSION *session, ssh_string f_string) {
|
||||||
session->next_crypto->f = make_string_bn(f_string);
|
session->next_crypto->f = make_string_bn(f_string);
|
||||||
if (session->next_crypto->f == NULL) {
|
if (session->next_crypto->f == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -403,7 +403,7 @@ int dh_import_f(SSH_SESSION *session, STRING *f_string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* used by the server implementation */
|
/* used by the server implementation */
|
||||||
int dh_import_e(SSH_SESSION *session, STRING *e_string) {
|
int dh_import_e(SSH_SESSION *session, ssh_string e_string) {
|
||||||
session->next_crypto->e = make_string_bn(e_string);
|
session->next_crypto->e = make_string_bn(e_string);
|
||||||
if (session->next_crypto->e == NULL) {
|
if (session->next_crypto->e == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -465,7 +465,7 @@ int dh_build_k(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static void sha_add(STRING *str,SHACTX ctx){
|
static void sha_add(ssh_string str,SHACTX ctx){
|
||||||
sha1_update(ctx,str,string_len(str)+4);
|
sha1_update(ctx,str,string_len(str)+4);
|
||||||
#ifdef DEBUG_CRYPTO
|
#ifdef DEBUG_CRYPTO
|
||||||
ssh_print_hexa("partial hashed sessionid",str,string_len(str)+4);
|
ssh_print_hexa("partial hashed sessionid",str,string_len(str)+4);
|
||||||
@@ -475,8 +475,8 @@ static void sha_add(STRING *str,SHACTX ctx){
|
|||||||
|
|
||||||
int make_sessionid(SSH_SESSION *session) {
|
int make_sessionid(SSH_SESSION *session) {
|
||||||
SHACTX ctx;
|
SHACTX ctx;
|
||||||
STRING *num = NULL;
|
ssh_string num = NULL;
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
BUFFER *server_hash = NULL;
|
BUFFER *server_hash = NULL;
|
||||||
BUFFER *client_hash = NULL;
|
BUFFER *client_hash = NULL;
|
||||||
BUFFER *buf = NULL;
|
BUFFER *buf = NULL;
|
||||||
@@ -665,7 +665,7 @@ int hashbufin_add_cookie(SSH_SESSION *session, unsigned char *cookie) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int generate_one_key(STRING *k,
|
static int generate_one_key(ssh_string k,
|
||||||
unsigned char session_id[SHA_DIGEST_LEN],
|
unsigned char session_id[SHA_DIGEST_LEN],
|
||||||
unsigned char output[SHA_DIGEST_LEN],
|
unsigned char output[SHA_DIGEST_LEN],
|
||||||
char letter) {
|
char letter) {
|
||||||
@@ -686,7 +686,7 @@ static int generate_one_key(STRING *k,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int generate_session_keys(SSH_SESSION *session) {
|
int generate_session_keys(SSH_SESSION *session) {
|
||||||
STRING *k_string = NULL;
|
ssh_string k_string = NULL;
|
||||||
SHACTX ctx = NULL;
|
SHACTX ctx = NULL;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
@@ -816,7 +816,7 @@ error:
|
|||||||
* @see ssh_print_hexa()
|
* @see ssh_print_hexa()
|
||||||
*/
|
*/
|
||||||
int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) {
|
int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) {
|
||||||
STRING *pubkey;
|
ssh_string pubkey;
|
||||||
MD5CTX ctx;
|
MD5CTX ctx;
|
||||||
unsigned char *h;
|
unsigned char *h;
|
||||||
|
|
||||||
@@ -847,7 +847,7 @@ int ssh_get_pubkey_hash(SSH_SESSION *session, unsigned char **hash) {
|
|||||||
return MD5_DIGEST_LEN;
|
return MD5_DIGEST_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *ssh_get_pubkey(SSH_SESSION *session){
|
ssh_string ssh_get_pubkey(SSH_SESSION *session){
|
||||||
return string_copy(session->current_crypto->server_pubkey);
|
return string_copy(session->current_crypto->server_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -970,7 +970,7 @@ static int sig_verify(SSH_SESSION *session, PUBLIC_KEY *pubkey,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int signature_verify(SSH_SESSION *session, STRING *signature) {
|
int signature_verify(SSH_SESSION *session, ssh_string signature) {
|
||||||
PUBLIC_KEY *pubkey = NULL;
|
PUBLIC_KEY *pubkey = NULL;
|
||||||
SIGNATURE *sign = NULL;
|
SIGNATURE *sign = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|||||||
34
libssh/kex.c
34
libssh/kex.c
@@ -233,7 +233,7 @@ char *ssh_find_matching(const char *in_d, const char *what_d){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ssh_get_kex(SSH_SESSION *session, int server_kex) {
|
int ssh_get_kex(SSH_SESSION *session, int server_kex) {
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
char *strings[10];
|
char *strings[10];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ int set_kex(SSH_SESSION *session){
|
|||||||
/* this function only sends the predefined set of kex methods */
|
/* this function only sends the predefined set of kex methods */
|
||||||
int ssh_send_kex(SSH_SESSION *session, int server_kex) {
|
int ssh_send_kex(SSH_SESSION *session, int server_kex) {
|
||||||
KEX *kex = (server_kex ? &session->server_kex : &session->client_kex);
|
KEX *kex = (server_kex ? &session->server_kex : &session->client_kex);
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -444,10 +444,10 @@ int verify_existing_algo(int algo, const char *name){
|
|||||||
|
|
||||||
/* makes a STRING contating 3 strings : ssh-rsa1,e and n */
|
/* makes a STRING contating 3 strings : ssh-rsa1,e and n */
|
||||||
/* this is a public key in openssh's format */
|
/* this is a public key in openssh's format */
|
||||||
static STRING *make_rsa1_string(STRING *e, STRING *n){
|
static ssh_string make_rsa1_string(ssh_string e, ssh_string n){
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
STRING *rsa = NULL;
|
ssh_string rsa = NULL;
|
||||||
STRING *ret = NULL;
|
ssh_string ret = NULL;
|
||||||
|
|
||||||
buffer = buffer_new();
|
buffer = buffer_new();
|
||||||
rsa = string_from_char("ssh-rsa1");
|
rsa = string_from_char("ssh-rsa1");
|
||||||
@@ -475,8 +475,8 @@ error:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int build_session_id1(SSH_SESSION *session, STRING *servern,
|
static int build_session_id1(SSH_SESSION *session, ssh_string servern,
|
||||||
STRING *hostn) {
|
ssh_string hostn) {
|
||||||
MD5CTX md5 = NULL;
|
MD5CTX md5 = NULL;
|
||||||
|
|
||||||
md5 = md5_init();
|
md5 = md5_init();
|
||||||
@@ -529,12 +529,12 @@ static int modulus_smaller(PUBLIC_KEY *k1, PUBLIC_KEY *k2){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ABS(A) ( (A)<0 ? -(A):(A) )
|
#define ABS(A) ( (A)<0 ? -(A):(A) )
|
||||||
static STRING *encrypt_session_key(SSH_SESSION *session, PUBLIC_KEY *srvkey,
|
static ssh_string encrypt_session_key(SSH_SESSION *session, PUBLIC_KEY *srvkey,
|
||||||
PUBLIC_KEY *hostkey, int slen, int hlen) {
|
PUBLIC_KEY *hostkey, int slen, int hlen) {
|
||||||
unsigned char buffer[32] = {0};
|
unsigned char buffer[32] = {0};
|
||||||
int i;
|
int i;
|
||||||
STRING *data1 = NULL;
|
ssh_string data1 = NULL;
|
||||||
STRING *data2 = NULL;
|
ssh_string data2 = NULL;
|
||||||
|
|
||||||
/* first, generate a session key */
|
/* first, generate a session key */
|
||||||
ssh_get_random(session->next_crypto->encryptkey, 32, 1);
|
ssh_get_random(session->next_crypto->encryptkey, 32, 1);
|
||||||
@@ -607,13 +607,13 @@ static STRING *encrypt_session_key(SSH_SESSION *session, PUBLIC_KEY *srvkey,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int ssh_get_kex1(SSH_SESSION *session) {
|
int ssh_get_kex1(SSH_SESSION *session) {
|
||||||
STRING *server_exp = NULL;
|
ssh_string server_exp = NULL;
|
||||||
STRING *server_mod = NULL;
|
ssh_string server_mod = NULL;
|
||||||
STRING *host_exp = NULL;
|
ssh_string host_exp = NULL;
|
||||||
STRING *host_mod = NULL;
|
ssh_string host_mod = NULL;
|
||||||
STRING *serverkey = NULL;
|
ssh_string serverkey = NULL;
|
||||||
STRING *hostkey = NULL;
|
ssh_string hostkey = NULL;
|
||||||
STRING *enc_session = NULL;
|
ssh_string enc_session = NULL;
|
||||||
PUBLIC_KEY *srv = NULL;
|
PUBLIC_KEY *srv = NULL;
|
||||||
PUBLIC_KEY *host = NULL;
|
PUBLIC_KEY *host = NULL;
|
||||||
u32 server_bits;
|
u32 server_bits;
|
||||||
|
|||||||
@@ -120,8 +120,8 @@ static u32 asn1_get_len(BUFFER *buffer) {
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static STRING *asn1_get_int(BUFFER *buffer) {
|
static ssh_string asn1_get_int(BUFFER *buffer) {
|
||||||
STRING *str;
|
ssh_string str;
|
||||||
unsigned char type;
|
unsigned char type;
|
||||||
u32 size;
|
u32 size;
|
||||||
|
|
||||||
@@ -443,15 +443,15 @@ static BUFFER *privatekey_file_to_buffer(FILE *fp, int type,
|
|||||||
|
|
||||||
static int read_rsa_privatekey(FILE *fp, gcry_sexp_t *r,
|
static int read_rsa_privatekey(FILE *fp, gcry_sexp_t *r,
|
||||||
ssh_auth_callback cb, void *userdata, const char *desc) {
|
ssh_auth_callback cb, void *userdata, const char *desc) {
|
||||||
STRING *n = NULL;
|
ssh_string n = NULL;
|
||||||
STRING *e = NULL;
|
ssh_string e = NULL;
|
||||||
STRING *d = NULL;
|
ssh_string d = NULL;
|
||||||
STRING *p = NULL;
|
ssh_string p = NULL;
|
||||||
STRING *q = NULL;
|
ssh_string q = NULL;
|
||||||
STRING *unused1 = NULL;
|
ssh_string unused1 = NULL;
|
||||||
STRING *unused2 = NULL;
|
ssh_string unused2 = NULL;
|
||||||
STRING *u = NULL;
|
ssh_string u = NULL;
|
||||||
STRING *v = NULL;
|
ssh_string v = NULL;
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
|
|
||||||
@@ -516,12 +516,12 @@ error:
|
|||||||
static int read_dsa_privatekey(FILE *fp, gcry_sexp_t *r, ssh_auth_callback cb,
|
static int read_dsa_privatekey(FILE *fp, gcry_sexp_t *r, ssh_auth_callback cb,
|
||||||
void *userdata, const char *desc) {
|
void *userdata, const char *desc) {
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
STRING *p = NULL;
|
ssh_string p = NULL;
|
||||||
STRING *q = NULL;
|
ssh_string q = NULL;
|
||||||
STRING *g = NULL;
|
ssh_string g = NULL;
|
||||||
STRING *y = NULL;
|
ssh_string y = NULL;
|
||||||
STRING *x = NULL;
|
ssh_string x = NULL;
|
||||||
STRING *v = NULL;
|
ssh_string v = NULL;
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
|
|
||||||
buffer = privatekey_file_to_buffer(fp, TYPE_DSS, cb, userdata, desc);
|
buffer = privatekey_file_to_buffer(fp, TYPE_DSS, cb, userdata, desc);
|
||||||
@@ -853,11 +853,11 @@ void privatekey_free(PRIVATE_KEY *prv) {
|
|||||||
* \see string_free()
|
* \see string_free()
|
||||||
* \see publickey_from_privatekey()
|
* \see publickey_from_privatekey()
|
||||||
*/
|
*/
|
||||||
STRING *publickey_from_file(SSH_SESSION *session, const char *filename,
|
ssh_string publickey_from_file(SSH_SESSION *session, const char *filename,
|
||||||
int *type) {
|
int *type) {
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
char buf[4096] = {0};
|
char buf[4096] = {0};
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
int key_type;
|
int key_type;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
@@ -922,7 +922,7 @@ STRING *publickey_from_file(SSH_SESSION *session, const char *filename,
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct keytab,
|
ssh_string try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct keytab,
|
||||||
char **privkeyfile, int *type) {
|
char **privkeyfile, int *type) {
|
||||||
static char *home = NULL;
|
static char *home = NULL;
|
||||||
|
|
||||||
@@ -931,7 +931,7 @@ STRING *try_publickey_from_file(SSH_SESSION *session, struct ssh_keys_struct key
|
|||||||
const char *priv;
|
const char *priv;
|
||||||
const char *pub;
|
const char *pub;
|
||||||
char *new;
|
char *new;
|
||||||
STRING *pubkey;
|
ssh_string pubkey;
|
||||||
|
|
||||||
if (home == NULL) {
|
if (home == NULL) {
|
||||||
home = ssh_get_user_home_dir();
|
home = ssh_get_user_home_dir();
|
||||||
@@ -1137,7 +1137,7 @@ static char **ssh_get_knownhost_line(SSH_SESSION *session, FILE **file,
|
|||||||
* \return -1 on error
|
* \return -1 on error
|
||||||
*/
|
*/
|
||||||
static int check_public_key(SSH_SESSION *session, char **tokens) {
|
static int check_public_key(SSH_SESSION *session, char **tokens) {
|
||||||
STRING *pubkey = session->current_crypto->server_pubkey;
|
ssh_string pubkey = session->current_crypto->server_pubkey;
|
||||||
BUFFER *pubkey_buffer;
|
BUFFER *pubkey_buffer;
|
||||||
char *pubkey_64;
|
char *pubkey_64;
|
||||||
|
|
||||||
@@ -1145,7 +1145,7 @@ static int check_public_key(SSH_SESSION *session, char **tokens) {
|
|||||||
if (alldigits(tokens[1])) {
|
if (alldigits(tokens[1])) {
|
||||||
/* openssh rsa1 format */
|
/* openssh rsa1 format */
|
||||||
bignum tmpbn;
|
bignum tmpbn;
|
||||||
STRING *tmpstring;
|
ssh_string tmpstring;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -1442,7 +1442,7 @@ int ssh_is_server_known(SSH_SESSION *session) {
|
|||||||
* \return 0 on success, -1 on error
|
* \return 0 on success, -1 on error
|
||||||
*/
|
*/
|
||||||
int ssh_write_knownhost(SSH_SESSION *session) {
|
int ssh_write_knownhost(SSH_SESSION *session) {
|
||||||
STRING *pubkey = session->current_crypto->server_pubkey;
|
ssh_string pubkey = session->current_crypto->server_pubkey;
|
||||||
unsigned char *pubkey_64;
|
unsigned char *pubkey_64;
|
||||||
char buffer[4096] = {0};
|
char buffer[4096] = {0};
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|||||||
@@ -66,10 +66,10 @@ int ssh_type_from_name(const char *name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer) {
|
PUBLIC_KEY *publickey_make_dss(SSH_SESSION *session, BUFFER *buffer) {
|
||||||
STRING *p = NULL;
|
ssh_string p = NULL;
|
||||||
STRING *q = NULL;
|
ssh_string q = NULL;
|
||||||
STRING *g = NULL;
|
ssh_string g = NULL;
|
||||||
STRING *pubkey = NULL;
|
ssh_string pubkey = NULL;
|
||||||
PUBLIC_KEY *key = NULL;
|
PUBLIC_KEY *key = NULL;
|
||||||
|
|
||||||
key = malloc(sizeof(PUBLIC_KEY));
|
key = malloc(sizeof(PUBLIC_KEY));
|
||||||
@@ -153,8 +153,8 @@ error:
|
|||||||
|
|
||||||
PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
|
PUBLIC_KEY *publickey_make_rsa(SSH_SESSION *session, BUFFER *buffer,
|
||||||
int type) {
|
int type) {
|
||||||
STRING *e = NULL;
|
ssh_string e = NULL;
|
||||||
STRING *n = NULL;
|
ssh_string n = NULL;
|
||||||
PUBLIC_KEY *key = NULL;
|
PUBLIC_KEY *key = NULL;
|
||||||
|
|
||||||
key = malloc(sizeof(PUBLIC_KEY));
|
key = malloc(sizeof(PUBLIC_KEY));
|
||||||
@@ -245,9 +245,9 @@ void publickey_free(PUBLIC_KEY *key) {
|
|||||||
SAFE_FREE(key);
|
SAFE_FREE(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, STRING *pubkey_s) {
|
PUBLIC_KEY *publickey_from_string(SSH_SESSION *session, ssh_string pubkey_s) {
|
||||||
BUFFER *tmpbuf = NULL;
|
BUFFER *tmpbuf = NULL;
|
||||||
STRING *type_s = NULL;
|
ssh_string type_s = NULL;
|
||||||
char *type_c = NULL;
|
char *type_c = NULL;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
@@ -302,12 +302,12 @@ PUBLIC_KEY *publickey_from_privatekey(PRIVATE_KEY *prv) {
|
|||||||
gcry_sexp_t sexp;
|
gcry_sexp_t sexp;
|
||||||
const char *tmp = NULL;
|
const char *tmp = NULL;
|
||||||
size_t size;
|
size_t size;
|
||||||
STRING *p = NULL;
|
ssh_string p = NULL;
|
||||||
STRING *q = NULL;
|
ssh_string q = NULL;
|
||||||
STRING *g = NULL;
|
ssh_string g = NULL;
|
||||||
STRING *y = NULL;
|
ssh_string y = NULL;
|
||||||
STRING *e = NULL;
|
ssh_string e = NULL;
|
||||||
STRING *n = NULL;
|
ssh_string n = NULL;
|
||||||
#endif /* HAVE_LIBGCRYPT */
|
#endif /* HAVE_LIBGCRYPT */
|
||||||
|
|
||||||
key = malloc(sizeof(PUBLIC_KEY));
|
key = malloc(sizeof(PUBLIC_KEY));
|
||||||
@@ -482,10 +482,10 @@ static int dsa_public_to_string(gcry_sexp_t key, BUFFER *buffer) {
|
|||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
static int dsa_public_to_string(DSA *key, BUFFER *buffer) {
|
static int dsa_public_to_string(DSA *key, BUFFER *buffer) {
|
||||||
#endif
|
#endif
|
||||||
STRING *p = NULL;
|
ssh_string p = NULL;
|
||||||
STRING *q = NULL;
|
ssh_string q = NULL;
|
||||||
STRING *g = NULL;
|
ssh_string g = NULL;
|
||||||
STRING *n = NULL;
|
ssh_string n = NULL;
|
||||||
|
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
@@ -588,8 +588,8 @@ static int rsa_public_to_string(gcry_sexp_t key, BUFFER *buffer) {
|
|||||||
static int rsa_public_to_string(RSA *key, BUFFER *buffer) {
|
static int rsa_public_to_string(RSA *key, BUFFER *buffer) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STRING *e = NULL;
|
ssh_string e = NULL;
|
||||||
STRING *n = NULL;
|
ssh_string n = NULL;
|
||||||
|
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
@@ -655,9 +655,9 @@ error:
|
|||||||
* \returns a SSH String containing the public key
|
* \returns a SSH String containing the public key
|
||||||
* \see string_free()
|
* \see string_free()
|
||||||
*/
|
*/
|
||||||
STRING *publickey_to_string(PUBLIC_KEY *key) {
|
ssh_string publickey_to_string(PUBLIC_KEY *key) {
|
||||||
STRING *type = NULL;
|
ssh_string type = NULL;
|
||||||
STRING *ret = NULL;
|
ssh_string ret = NULL;
|
||||||
BUFFER *buf = NULL;
|
BUFFER *buf = NULL;
|
||||||
|
|
||||||
buf = buffer_new();
|
buf = buffer_new();
|
||||||
@@ -702,12 +702,12 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Signature decoding functions */
|
/* Signature decoding functions */
|
||||||
static STRING *signature_to_string(SIGNATURE *sign) {
|
static ssh_string signature_to_string(SIGNATURE *sign) {
|
||||||
unsigned char buffer[40] = {0};
|
unsigned char buffer[40] = {0};
|
||||||
BUFFER *tmpbuf = NULL;
|
BUFFER *tmpbuf = NULL;
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
STRING *tmp = NULL;
|
ssh_string tmp = NULL;
|
||||||
STRING *rs = NULL;
|
ssh_string rs = NULL;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
const char *r = NULL;
|
const char *r = NULL;
|
||||||
@@ -715,8 +715,8 @@ static STRING *signature_to_string(SIGNATURE *sign) {
|
|||||||
gcry_sexp_t sexp;
|
gcry_sexp_t sexp;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
STRING *r = NULL;
|
ssh_string r = NULL;
|
||||||
STRING *s = NULL;
|
ssh_string s = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tmpbuf = buffer_new();
|
tmpbuf = buffer_new();
|
||||||
@@ -846,13 +846,13 @@ static STRING *signature_to_string(SIGNATURE *sign) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO : split this function in two so it becomes smaller */
|
/* TODO : split this function in two so it becomes smaller */
|
||||||
SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,
|
SIGNATURE *signature_from_string(SSH_SESSION *session, ssh_string signature,
|
||||||
PUBLIC_KEY *pubkey, int needed_type) {
|
PUBLIC_KEY *pubkey, int needed_type) {
|
||||||
SIGNATURE *sign = NULL;
|
SIGNATURE *sign = NULL;
|
||||||
BUFFER *tmpbuf = NULL;
|
BUFFER *tmpbuf = NULL;
|
||||||
STRING *rs = NULL;
|
ssh_string rs = NULL;
|
||||||
STRING *type_s = NULL;
|
ssh_string type_s = NULL;
|
||||||
STRING *e = NULL;
|
ssh_string e = NULL;
|
||||||
char *type_c = NULL;
|
char *type_c = NULL;
|
||||||
int type;
|
int type;
|
||||||
int len;
|
int len;
|
||||||
@@ -861,8 +861,8 @@ SIGNATURE *signature_from_string(SSH_SESSION *session, STRING *signature,
|
|||||||
gcry_sexp_t sig;
|
gcry_sexp_t sig;
|
||||||
#elif defined HAVE_LIBCRYPTO
|
#elif defined HAVE_LIBCRYPTO
|
||||||
DSA_SIG *sig = NULL;
|
DSA_SIG *sig = NULL;
|
||||||
STRING *r = NULL;
|
ssh_string r = NULL;
|
||||||
STRING *s = NULL;
|
ssh_string s = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sign = malloc(sizeof(SIGNATURE));
|
sign = malloc(sizeof(SIGNATURE));
|
||||||
@@ -1070,8 +1070,8 @@ void signature_free(SIGNATURE *sign) {
|
|||||||
* I think now, maybe it's a bad idea to name it has it should have be
|
* I think now, maybe it's a bad idea to name it has it should have be
|
||||||
* named in libcrypto
|
* named in libcrypto
|
||||||
*/
|
*/
|
||||||
static STRING *RSA_do_sign(const unsigned char *payload, int len, RSA *privkey) {
|
static ssh_string RSA_do_sign(const unsigned char *payload, int len, RSA *privkey) {
|
||||||
STRING *sign = NULL;
|
ssh_string sign = NULL;
|
||||||
unsigned char *buffer = NULL;
|
unsigned char *buffer = NULL;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
|
|
||||||
@@ -1099,7 +1099,7 @@ static STRING *RSA_do_sign(const unsigned char *payload, int len, RSA *privkey)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
STRING *ssh_do_sign_with_agent(struct ssh_session *session,
|
ssh_string ssh_do_sign_with_agent(struct ssh_session *session,
|
||||||
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey) {
|
struct ssh_buffer_struct *buf, struct ssh_public_key_struct *publickey) {
|
||||||
struct ssh_buffer_struct *sigbuf = NULL;
|
struct ssh_buffer_struct *sigbuf = NULL;
|
||||||
struct ssh_string_struct *signature = NULL;
|
struct ssh_string_struct *signature = NULL;
|
||||||
@@ -1150,13 +1150,13 @@ STRING *ssh_do_sign_with_agent(struct ssh_session *session,
|
|||||||
/*
|
/*
|
||||||
* This function signs the session id (known as H) as a string then
|
* This function signs the session id (known as H) as a string then
|
||||||
* the content of sigbuf */
|
* the content of sigbuf */
|
||||||
STRING *ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf,
|
ssh_string ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf,
|
||||||
PRIVATE_KEY *privatekey) {
|
PRIVATE_KEY *privatekey) {
|
||||||
CRYPTO *crypto = session->current_crypto ? session->current_crypto :
|
CRYPTO *crypto = session->current_crypto ? session->current_crypto :
|
||||||
session->next_crypto;
|
session->next_crypto;
|
||||||
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
||||||
STRING *session_str = NULL;
|
ssh_string session_str = NULL;
|
||||||
STRING *signature = NULL;
|
ssh_string signature = NULL;
|
||||||
SIGNATURE *sign = NULL;
|
SIGNATURE *sign = NULL;
|
||||||
SHACTX ctx = NULL;
|
SHACTX ctx = NULL;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
@@ -1249,8 +1249,8 @@ STRING *ssh_do_sign(SSH_SESSION *session, BUFFER *sigbuf,
|
|||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key) {
|
ssh_string ssh_encrypt_rsa1(SSH_SESSION *session, ssh_string data, PUBLIC_KEY *key) {
|
||||||
STRING *str = NULL;
|
ssh_string str = NULL;
|
||||||
size_t len = string_len(data);
|
size_t len = string_len(data);
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
@@ -1315,11 +1315,11 @@ STRING *ssh_encrypt_rsa1(SSH_SESSION *session, STRING *data, PUBLIC_KEY *key) {
|
|||||||
|
|
||||||
|
|
||||||
/* this function signs the session id */
|
/* this function signs the session id */
|
||||||
STRING *ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey) {
|
ssh_string ssh_sign_session_id(SSH_SESSION *session, PRIVATE_KEY *privatekey) {
|
||||||
CRYPTO *crypto=session->current_crypto ? session->current_crypto :
|
CRYPTO *crypto=session->current_crypto ? session->current_crypto :
|
||||||
session->next_crypto;
|
session->next_crypto;
|
||||||
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
unsigned char hash[SHA_DIGEST_LEN + 1] = {0};
|
||||||
STRING *signature = NULL;
|
ssh_string signature = NULL;
|
||||||
SIGNATURE *sign = NULL;
|
SIGNATURE *sign = NULL;
|
||||||
SHACTX ctx = NULL;
|
SHACTX ctx = NULL;
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ static SSH_MESSAGE *message_new(SSH_SESSION *session){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SSH_MESSAGE *handle_service_request(SSH_SESSION *session) {
|
static SSH_MESSAGE *handle_service_request(SSH_SESSION *session) {
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
char *service_c = NULL;
|
char *service_c = NULL;
|
||||||
SSH_MESSAGE *msg=NULL;
|
SSH_MESSAGE *msg=NULL;
|
||||||
|
|
||||||
@@ -131,9 +131,9 @@ static int handle_unimplemented(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){
|
static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){
|
||||||
STRING *user = NULL;
|
ssh_string user = NULL;
|
||||||
STRING *service = NULL;
|
ssh_string service = NULL;
|
||||||
STRING *method = NULL;
|
ssh_string method = NULL;
|
||||||
SSH_MESSAGE *msg = NULL;
|
SSH_MESSAGE *msg = NULL;
|
||||||
char *service_c = NULL;
|
char *service_c = NULL;
|
||||||
char *method_c = NULL;
|
char *method_c = NULL;
|
||||||
@@ -192,7 +192,7 @@ static SSH_MESSAGE *handle_userauth_request(SSH_SESSION *session){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(method_c, "password") == 0) {
|
if (strcmp(method_c, "password") == 0) {
|
||||||
STRING *pass = NULL;
|
ssh_string pass = NULL;
|
||||||
u8 tmp;
|
u8 tmp;
|
||||||
|
|
||||||
msg->auth_request.method = SSH_AUTH_PASSWORD;
|
msg->auth_request.method = SSH_AUTH_PASSWORD;
|
||||||
@@ -259,7 +259,7 @@ int ssh_message_auth_set_methods(SSH_MESSAGE *msg, int methods) {
|
|||||||
static int ssh_message_auth_reply_default(SSH_MESSAGE *msg,int partial) {
|
static int ssh_message_auth_reply_default(SSH_MESSAGE *msg,int partial) {
|
||||||
SSH_SESSION *session = msg->session;
|
SSH_SESSION *session = msg->session;
|
||||||
char methods_c[128] = {0};
|
char methods_c[128] = {0};
|
||||||
STRING *methods = NULL;
|
ssh_string methods = NULL;
|
||||||
int rc = SSH_ERROR;
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
@@ -335,7 +335,7 @@ int ssh_message_auth_reply_success(SSH_MESSAGE *msg, int partial) {
|
|||||||
|
|
||||||
static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session) {
|
static SSH_MESSAGE *handle_channel_request_open(SSH_SESSION *session) {
|
||||||
SSH_MESSAGE *msg = NULL;
|
SSH_MESSAGE *msg = NULL;
|
||||||
STRING *type = NULL;
|
ssh_string type = NULL;
|
||||||
char *type_c = NULL;
|
char *type_c = NULL;
|
||||||
u32 sender, window, packet;
|
u32 sender, window, packet;
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ error:
|
|||||||
|
|
||||||
static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) {
|
static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) {
|
||||||
SSH_MESSAGE *msg = NULL;
|
SSH_MESSAGE *msg = NULL;
|
||||||
STRING *type = NULL;
|
ssh_string type = NULL;
|
||||||
char *type_c = NULL;
|
char *type_c = NULL;
|
||||||
u32 channel;
|
u32 channel;
|
||||||
u8 want_reply;
|
u8 want_reply;
|
||||||
@@ -515,7 +515,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) {
|
|||||||
msg->channel_request.want_reply = want_reply;
|
msg->channel_request.want_reply = want_reply;
|
||||||
|
|
||||||
if (strcmp(type_c, "pty-req") == 0) {
|
if (strcmp(type_c, "pty-req") == 0) {
|
||||||
STRING *term = NULL;
|
ssh_string term = NULL;
|
||||||
char *term_c = NULL;
|
char *term_c = NULL;
|
||||||
SAFE_FREE(type_c);
|
SAFE_FREE(type_c);
|
||||||
|
|
||||||
@@ -553,7 +553,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(type_c, "subsystem") == 0) {
|
if (strcmp(type_c, "subsystem") == 0) {
|
||||||
STRING *subsys = NULL;
|
ssh_string subsys = NULL;
|
||||||
char *subsys_c = NULL;
|
char *subsys_c = NULL;
|
||||||
|
|
||||||
SAFE_FREE(type_c);
|
SAFE_FREE(type_c);
|
||||||
@@ -584,7 +584,7 @@ static SSH_MESSAGE *handle_channel_request(SSH_SESSION *session) {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (strcmp(type_c, "exec") == 0) {
|
if (strcmp(type_c, "exec") == 0) {
|
||||||
STRING *cmd = NULL;
|
ssh_string cmd = NULL;
|
||||||
|
|
||||||
SAFE_FREE(type_c);
|
SAFE_FREE(type_c);
|
||||||
|
|
||||||
|
|||||||
@@ -592,7 +592,7 @@ int packet_send(SSH_SESSION *session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void packet_parse(SSH_SESSION *session) {
|
void packet_parse(SSH_SESSION *session) {
|
||||||
STRING *error_s = NULL;
|
ssh_string error_s = NULL;
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
u32 type = session->in_packet.type;
|
u32 type = session->in_packet.type;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
|||||||
@@ -325,10 +325,10 @@ static int server_set_kex(SSH_SESSION * session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int dh_handshake_server(SSH_SESSION *session) {
|
static int dh_handshake_server(SSH_SESSION *session) {
|
||||||
STRING *e;
|
ssh_string e;
|
||||||
STRING *f;
|
ssh_string f;
|
||||||
STRING *pubkey;
|
ssh_string pubkey;
|
||||||
STRING *sign;
|
ssh_string sign;
|
||||||
PUBLIC_KEY *pub;
|
PUBLIC_KEY *pub;
|
||||||
PRIVATE_KEY *prv;
|
PRIVATE_KEY *prv;
|
||||||
|
|
||||||
|
|||||||
@@ -419,8 +419,8 @@ void sftp_packet_free(SFTP_PACKET *packet) {
|
|||||||
int sftp_init(SFTP_SESSION *sftp) {
|
int sftp_init(SFTP_SESSION *sftp) {
|
||||||
SFTP_PACKET *packet = NULL;
|
SFTP_PACKET *packet = NULL;
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
STRING *ext_name_s = NULL;
|
ssh_string ext_name_s = NULL;
|
||||||
STRING *ext_data_s = NULL;
|
ssh_string ext_data_s = NULL;
|
||||||
char *ext_name = NULL;
|
char *ext_name = NULL;
|
||||||
char *ext_data = NULL;
|
char *ext_data = NULL;
|
||||||
u32 version = htonl(LIBSFTP_VERSION);
|
u32 version = htonl(LIBSFTP_VERSION);
|
||||||
@@ -672,7 +672,7 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){
|
|||||||
SFTP_FILE *file = NULL;
|
SFTP_FILE *file = NULL;
|
||||||
SFTP_DIR *dir = NULL;
|
SFTP_DIR *dir = NULL;
|
||||||
STATUS_MESSAGE *status;
|
STATUS_MESSAGE *status;
|
||||||
STRING *path_s;
|
ssh_string path_s;
|
||||||
BUFFER *payload;
|
BUFFER *payload;
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
@@ -760,8 +760,8 @@ SFTP_DIR *sftp_opendir(SFTP_SESSION *sftp, const char *path){
|
|||||||
static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, BUFFER *buf,
|
static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, BUFFER *buf,
|
||||||
int expectnames) {
|
int expectnames) {
|
||||||
SFTP_ATTRIBUTES *attr;
|
SFTP_ATTRIBUTES *attr;
|
||||||
STRING *owner = NULL;
|
ssh_string owner = NULL;
|
||||||
STRING *group = NULL;
|
ssh_string group = NULL;
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
|
|
||||||
@@ -935,8 +935,8 @@ static SFTP_ATTRIBUTES *sftp_parse_attr_4(SFTP_SESSION *sftp, BUFFER *buf,
|
|||||||
so that number of pairs equals extended_count */
|
so that number of pairs equals extended_count */
|
||||||
static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, BUFFER *buf,
|
static SFTP_ATTRIBUTES *sftp_parse_attr_3(SFTP_SESSION *sftp, BUFFER *buf,
|
||||||
int expectname) {
|
int expectname) {
|
||||||
STRING *longname = NULL;
|
ssh_string longname = NULL;
|
||||||
STRING *name = NULL;
|
ssh_string name = NULL;
|
||||||
SFTP_ATTRIBUTES *attr;
|
SFTP_ATTRIBUTES *attr;
|
||||||
u32 flags = 0;
|
u32 flags = 0;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
@@ -1263,7 +1263,7 @@ void sftp_attributes_free(SFTP_ATTRIBUTES *file){
|
|||||||
SAFE_FREE(file);
|
SAFE_FREE(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sftp_handle_close(SFTP_SESSION *sftp, STRING *handle) {
|
static int sftp_handle_close(SFTP_SESSION *sftp, ssh_string handle) {
|
||||||
STATUS_MESSAGE *status;
|
STATUS_MESSAGE *status;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
BUFFER *buffer = NULL;
|
BUFFER *buffer = NULL;
|
||||||
@@ -1366,7 +1366,7 @@ SFTP_FILE *sftp_open(SFTP_SESSION *sftp, const char *file, int flags,
|
|||||||
STATUS_MESSAGE *status;
|
STATUS_MESSAGE *status;
|
||||||
SFTP_ATTRIBUTES attr;
|
SFTP_ATTRIBUTES attr;
|
||||||
SFTP_FILE *handle;
|
SFTP_FILE *handle;
|
||||||
STRING *filename;
|
ssh_string filename;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
u32 sftp_flags = 0;
|
u32 sftp_flags = 0;
|
||||||
u32 id;
|
u32 id;
|
||||||
@@ -1463,7 +1463,7 @@ ssize_t sftp_read(SFTP_FILE *handle, void *buf, size_t count) {
|
|||||||
SFTP_SESSION *sftp = handle->sftp;
|
SFTP_SESSION *sftp = handle->sftp;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STATUS_MESSAGE *status;
|
STATUS_MESSAGE *status;
|
||||||
STRING *datastring;
|
ssh_string datastring;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
@@ -1587,7 +1587,7 @@ int sftp_async_read(SFTP_FILE *file, void *data, u32 size, u32 id){
|
|||||||
SFTP_SESSION *sftp = file->sftp;
|
SFTP_SESSION *sftp = file->sftp;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STATUS_MESSAGE *status;
|
STATUS_MESSAGE *status;
|
||||||
STRING *datastring;
|
ssh_string datastring;
|
||||||
int err = SSH_OK;
|
int err = SSH_OK;
|
||||||
u32 len;
|
u32 len;
|
||||||
|
|
||||||
@@ -1677,7 +1677,7 @@ ssize_t sftp_write(SFTP_FILE *file, const void *buf, size_t count) {
|
|||||||
SFTP_SESSION *sftp = file->sftp;
|
SFTP_SESSION *sftp = file->sftp;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STATUS_MESSAGE *status;
|
STATUS_MESSAGE *status;
|
||||||
STRING *datastring;
|
ssh_string datastring;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
u32 id;
|
u32 id;
|
||||||
int len;
|
int len;
|
||||||
@@ -1794,7 +1794,7 @@ int sftp_rm(SFTP_SESSION *sftp, const char *file) {
|
|||||||
int sftp_unlink(SFTP_SESSION *sftp, const char *file) {
|
int sftp_unlink(SFTP_SESSION *sftp, const char *file) {
|
||||||
STATUS_MESSAGE *status = NULL;
|
STATUS_MESSAGE *status = NULL;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STRING *filename;
|
ssh_string filename;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
@@ -1863,7 +1863,7 @@ int sftp_unlink(SFTP_SESSION *sftp, const char *file) {
|
|||||||
int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) {
|
int sftp_rmdir(SFTP_SESSION *sftp, const char *directory) {
|
||||||
STATUS_MESSAGE *status = NULL;
|
STATUS_MESSAGE *status = NULL;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STRING *filename;
|
ssh_string filename;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
@@ -1933,7 +1933,7 @@ int sftp_mkdir(SFTP_SESSION *sftp, const char *directory, mode_t mode) {
|
|||||||
SFTP_ATTRIBUTES *errno_attr = NULL;
|
SFTP_ATTRIBUTES *errno_attr = NULL;
|
||||||
SFTP_ATTRIBUTES attr;
|
SFTP_ATTRIBUTES attr;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
STRING *path;
|
ssh_string path;
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
buffer = buffer_new();
|
buffer = buffer_new();
|
||||||
@@ -2020,8 +2020,8 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) {
|
|||||||
STATUS_MESSAGE *status = NULL;
|
STATUS_MESSAGE *status = NULL;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
STRING *oldpath;
|
ssh_string oldpath;
|
||||||
STRING *newpath;
|
ssh_string newpath;
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
buffer = buffer_new();
|
buffer = buffer_new();
|
||||||
@@ -2103,7 +2103,7 @@ int sftp_rename(SFTP_SESSION *sftp, const char *original, const char *newname) {
|
|||||||
int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) {
|
int sftp_setstat(SFTP_SESSION *sftp, const char *file, SFTP_ATTRIBUTES *attr) {
|
||||||
u32 id = sftp_get_new_id(sftp);
|
u32 id = sftp_get_new_id(sftp);
|
||||||
BUFFER *buffer = buffer_new();
|
BUFFER *buffer = buffer_new();
|
||||||
STRING *path = string_from_char(file);
|
ssh_string path = string_from_char(file);
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STATUS_MESSAGE *status = NULL;
|
STATUS_MESSAGE *status = NULL;
|
||||||
|
|
||||||
@@ -2216,8 +2216,8 @@ int sftp_utimes(SFTP_SESSION *sftp, const char *file,
|
|||||||
char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) {
|
char *sftp_canonicalize_path(SFTP_SESSION *sftp, const char *path) {
|
||||||
STATUS_MESSAGE *status = NULL;
|
STATUS_MESSAGE *status = NULL;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STRING *name = NULL;
|
ssh_string name = NULL;
|
||||||
STRING *pathstr;
|
ssh_string pathstr;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
char *cname;
|
char *cname;
|
||||||
u32 ignored;
|
u32 ignored;
|
||||||
@@ -2291,7 +2291,7 @@ static SFTP_ATTRIBUTES *sftp_xstat(SFTP_SESSION *sftp, const char *path,
|
|||||||
int param) {
|
int param) {
|
||||||
STATUS_MESSAGE *status = NULL;
|
STATUS_MESSAGE *status = NULL;
|
||||||
SFTP_MESSAGE *msg = NULL;
|
SFTP_MESSAGE *msg = NULL;
|
||||||
STRING *pathstr;
|
ssh_string pathstr;
|
||||||
BUFFER *buffer;
|
BUFFER *buffer;
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ SFTP_CLIENT_MESSAGE *sftp_get_client_message(SFTP_SESSION *sftp) {
|
|||||||
SFTP_PACKET *packet;
|
SFTP_PACKET *packet;
|
||||||
SFTP_CLIENT_MESSAGE *msg;
|
SFTP_CLIENT_MESSAGE *msg;
|
||||||
BUFFER *payload;
|
BUFFER *payload;
|
||||||
STRING *tmp;
|
ssh_string tmp;
|
||||||
|
|
||||||
msg = malloc(sizeof (SFTP_CLIENT_MESSAGE));
|
msg = malloc(sizeof (SFTP_CLIENT_MESSAGE));
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
@@ -229,7 +229,7 @@ void sftp_client_message_free(SFTP_CLIENT_MESSAGE *msg) {
|
|||||||
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
|
int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
|
||||||
SFTP_ATTRIBUTES *attr) {
|
SFTP_ATTRIBUTES *attr) {
|
||||||
BUFFER *out;
|
BUFFER *out;
|
||||||
STRING *file;
|
ssh_string file;
|
||||||
|
|
||||||
out = buffer_new();
|
out = buffer_new();
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
@@ -258,7 +258,7 @@ int sftp_reply_name(SFTP_CLIENT_MESSAGE *msg, const char *name,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, STRING *handle){
|
int sftp_reply_handle(SFTP_CLIENT_MESSAGE *msg, ssh_string handle){
|
||||||
BUFFER *out;
|
BUFFER *out;
|
||||||
|
|
||||||
out = buffer_new();
|
out = buffer_new();
|
||||||
@@ -298,7 +298,7 @@ int sftp_reply_attr(SFTP_CLIENT_MESSAGE *msg, SFTP_ATTRIBUTES *attr) {
|
|||||||
|
|
||||||
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
|
int sftp_reply_names_add(SFTP_CLIENT_MESSAGE *msg, const char *file,
|
||||||
const char *longname, SFTP_ATTRIBUTES *attr) {
|
const char *longname, SFTP_ATTRIBUTES *attr) {
|
||||||
STRING *name;
|
ssh_string name;
|
||||||
|
|
||||||
name = string_from_char(file);
|
name = string_from_char(file);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
@@ -365,7 +365,7 @@ int sftp_reply_names(SFTP_CLIENT_MESSAGE *msg) {
|
|||||||
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status,
|
int sftp_reply_status(SFTP_CLIENT_MESSAGE *msg, u32 status,
|
||||||
const char *message) {
|
const char *message) {
|
||||||
BUFFER *out;
|
BUFFER *out;
|
||||||
STRING *s;
|
ssh_string s;
|
||||||
|
|
||||||
out = buffer_new();
|
out = buffer_new();
|
||||||
if (out == NULL) {
|
if (out == NULL) {
|
||||||
@@ -420,8 +420,8 @@ int sftp_reply_data(SFTP_CLIENT_MESSAGE *msg, const void *data, int len) {
|
|||||||
* the handle. Care is given that a corrupted handle won't give a
|
* the handle. Care is given that a corrupted handle won't give a
|
||||||
* valid info (or worse).
|
* valid info (or worse).
|
||||||
*/
|
*/
|
||||||
STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
|
ssh_string sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
|
||||||
STRING *ret;
|
ssh_string ret;
|
||||||
u32 val;
|
u32 val;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -455,7 +455,7 @@ STRING *sftp_handle_alloc(SFTP_SESSION *sftp, void *info) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *sftp_handle(SFTP_SESSION *sftp, STRING *handle){
|
void *sftp_handle(SFTP_SESSION *sftp, ssh_string handle){
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
if (sftp->handles == NULL) {
|
if (sftp->handles == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user