Global Namespace

Overview

// namespaces

namespace ssh;

// typedefs

typedef int (*ssh_thread_callback)(void **lock);
typedef unsigned long (*ssh_thread_id_callback)(void);

typedef int (*ssh_auth_gssapi_mic_callback)(
    ssh_session session,
    const char *user,
    const char *principal,
    void *userdata
    );

typedef int (*ssh_auth_none_callback)(
    ssh_session session,
    const char *user,
    void *userdata
    );

typedef int (*ssh_auth_password_callback)(
    ssh_session session,
    const char *user,
    const char *password,
    void *userdata
    );

typedef int (*ssh_auth_pubkey_callback)(
    ssh_session session,
    const char *user,
    struct ssh_key_struct *pubkey,
    char signature_state,
    void *userdata
    );

typedef int (*ssh_callback_data)(
    const void *data,
    size_t len,
    void *user
    );

typedef void (*ssh_callback_int)(
    int code,
    void *user
    );

typedef void (*ssh_callback_int_int)(
    int code,
    int errno_code,
    void *user
    );

typedef void (*ssh_channel_auth_agent_req_callback)(
    ssh_session session,
    ssh_channel channel,
    void *userdata
    );

typedef int (*ssh_channel_callback_data)(
    ssh_channel channel,
    int code,
    void *data,
    size_t len,
    void *user
    );

typedef int (*ssh_channel_callback_int)(
    ssh_channel channel,
    int code,
    void *user
    );

typedef void (*ssh_channel_close_callback)(
    ssh_session session,
    ssh_channel channel,
    void *userdata
    );

typedef int (*ssh_channel_data_callback)(
    ssh_session session,
    ssh_channel channel,
    void *data,
    uint32_t len,
    int is_stderr,
    void *userdata
    );

typedef int (*ssh_channel_env_request_callback)(
    ssh_session session,
    ssh_channel channel,
    const char *env_name,
    const char *env_value,
    void *userdata
    );

typedef void (*ssh_channel_eof_callback)(
    ssh_session session,
    ssh_channel channel,
    void *userdata
    );

typedef int (*ssh_channel_exec_request_callback)(
    ssh_session session,
    ssh_channel channel,
    const char *command,
    void *userdata
    );

typedef void (*ssh_channel_exit_signal_callback)(
    ssh_session session,
    ssh_channel channel,
    const char *signal,
    int core,
    const char *errmsg,
    const char *lang,
    void *userdata
    );

typedef void (*ssh_channel_exit_status_callback)(
    ssh_session session,
    ssh_channel channel,
    int exit_status,
    void *userdata
    );

typedef ssh_channel (*ssh_channel_open_request_session_callback)(
    ssh_session session,
    void *userdata
    );

typedef ssh_channel (*ssh_channel_open_request_x11_callback)(
    ssh_session session,
    const char *originator_address,
    int originator_port,
    void *userdata
    );

typedef int (*ssh_channel_pty_request_callback)(
    ssh_session session,
    ssh_channel channel,
    const char *term,
    int width,
    int height,
    int pxwidth,
    int pwheight,
    void *userdata
    );

typedef int (*ssh_channel_pty_window_change_callback)(
    ssh_session session,
    ssh_channel channel,
    int width,
    int height,
    int pxwidth,
    int pwheight,
    void *userdata
    );

typedef int (*ssh_channel_shell_request_callback)(
    ssh_session session,
    ssh_channel channel,
    void *userdata
    );

typedef void (*ssh_channel_signal_callback)(
    ssh_session session,
    ssh_channel channel,
    const char *signal,
    void *userdata
    );

typedef int (*ssh_channel_subsystem_request_callback)(
    ssh_session session,
    ssh_channel channel,
    const char *subsystem,
    void *userdata
    );

typedef void (*ssh_channel_x11_req_callback)(
    ssh_session session,
    ssh_channel channel,
    int single_connection,
    const char *auth_protocol,
    const char *auth_cookie,
    uint32_t screen_number,
    void *userdata
    );

typedef void (*ssh_global_request_callback)(
    ssh_session session,
    ssh_message message,
    void *userdata
    );

typedef int (*ssh_gssapi_accept_sec_ctx_callback)(
    ssh_session session,
    ssh_string input_token,
    ssh_string *output_token,
    void *userdata
    );

typedef ssh_string (*ssh_gssapi_select_oid_callback)(
    ssh_session session,
    const char *user,
    int n_oid,
    ssh_string *oids,
    void *userdata
    );

typedef int (*ssh_gssapi_verify_mic_callback)(
    ssh_session session,
    ssh_string mic,
    void *mic_buffer,
    size_t mic_buffer_size,
    void *userdata
    );

typedef void (*ssh_log_callback)(
    ssh_session session,
    int priority,
    const char *message,
    void *userdata
    );

typedef void (*ssh_logging_callback)(
    int priority,
    const char *function,
    const char *buffer,
    void *userdata
    );

typedef int (*ssh_message_callback)(
    ssh_session,
    ssh_message message,
    void *user
    );

typedef int (*ssh_packet_callback)(
    ssh_session session,
    uint8_t type,
    ssh_buffer packet,
    void *user
    );

typedef int (*ssh_service_request_callback)(
    ssh_session session,
    const char *service,
    void *userdata
    );

typedef void (*ssh_status_callback)(
    ssh_session session,
    float status,
    void *userdata
    );

typedef unsigned char ssh_curve25519_privkey[32];
typedef unsigned char ssh_curve25519_pubkey[32];
typedef uint8_t ed25519_privkey[64];
typedef uint8_t ed25519_pubkey[32];
typedef uint8_t ed25519_signature[64];
typedef int socket_t;

typedef int (*ssh_auth_callback)(
    const char *prompt,
    char *buf,
    size_t len,
    int echo,
    int verify,
    void *userdata
    );

typedef int (*ssh_event_callback)(
    socket_t fd,
    int revents,
    void *userdata
    );

typedef void* ssh_gssapi_creds;
typedef unsigned long int nfds_t;

typedef int (*ssh_poll_callback)(
    ssh_poll_handle p,
    socket_t fd,
    int revents,
    void *userdata
    );

typedef void (*ssh_bind_incoming_connection_callback)(
    ssh_bind sshbind,
    void *userdata
    );

typedef int (*ssh_termination_function)(void *user);
typedef struct ssh_mac_ctx_struct* ssh_mac_ctx;

typedef int (*poll_fn)(
    ssh_pollfd_t *,
    nfds_t,
    int
    );

// enums

enum {
    SSH_LOG_NOLOG     =0,
    SSH_LOG_WARNING,
    SSH_LOG_PROTOCOL,
    SSH_LOG_PACKET,
    SSH_LOG_FUNCTIONS,
};

enum {
    SSH_SCP_WRITE,
    SSH_SCP_READ,
    SSH_SCP_RECURSIVE =0x10,
};

enum sftp_longname_field_e;
enum ssh_agent_state_e;
enum ssh_auth_auto_state_e;
enum ssh_auth_e;
enum ssh_auth_service_state_e;
enum ssh_auth_state_e;
enum ssh_bind_options_e;
enum ssh_channel_request_state_e;
enum ssh_channel_requests_e;
enum ssh_channel_state_e;
enum ssh_channel_type_e;
enum ssh_config_opcode_e;
enum ssh_des_e;
enum ssh_dh_state_e;
enum ssh_error_types_e;
enum ssh_global_requests_e;
enum ssh_gssapi_state_e;
enum ssh_hmac_e;
enum ssh_kex_types_e;
enum ssh_key_exchange_e;
enum ssh_keycmp_e;
enum ssh_keytypes_e;
enum ssh_mac_e;
enum ssh_options_e;
enum ssh_packet_state_e;
enum ssh_pcap_direction;
enum ssh_pending_call_e;
enum ssh_publickey_hash_type;
enum ssh_publickey_state_e;
enum ssh_requests_e;
enum ssh_scp_request_types;
enum ssh_scp_states;
enum ssh_server_known_e;
enum ssh_session_state_e;
enum ssh_socket_states_e;

// structs

struct PACKET;
struct blf_ctx;
struct crypto_sign_ed25519_ref_fe25519;
struct crypto_sign_ed25519_ref_ge25519;
struct crypto_sign_ed25519_ref_sc25519;
struct crypto_sign_ed25519_ref_shortsc25519;
struct error_struct;
struct ge25519_aff;
struct ge25519_p1p1;
struct ge25519_p2;
struct pcap_hdr_s;
struct pcaprec_hdr_s;
struct pem_get_password_struct;
struct sftp_attributes_struct;
struct sftp_client_message_struct;
struct sftp_dir_struct;
struct sftp_ext_struct;
struct sftp_file_struct;
struct sftp_message_struct;
struct sftp_packet_struct;
struct sftp_request_queue_struct;
struct sftp_session_struct;
struct sftp_status_message_struct;
struct sftp_statvfs_struct;
struct ssh_agent_state_struct;
struct ssh_agent_struct;
struct ssh_auth_auto_state_struct;
struct ssh_auth_request;
struct ssh_bind_callbacks_struct;
struct ssh_bind_struct;
struct ssh_buffer_struct;
struct ssh_callbacks_struct;
struct ssh_channel_callbacks_struct;
struct ssh_channel_read_termination_struct;
struct ssh_channel_request;
struct ssh_channel_request_open;
struct ssh_channel_struct;
struct ssh_cipher_struct;
struct ssh_common_struct;
struct ssh_config_keyword_table_s;
struct ssh_counter_struct;
struct ssh_crypto_struct;
struct ssh_event_fd_wrapper;
struct ssh_event_struct;
struct ssh_global_request;
struct ssh_gssapi_struct;
struct ssh_hmac_struct;
struct ssh_iterator;
struct ssh_kbdint_struct;
struct ssh_kex_struct;
struct ssh_key_struct;
struct ssh_list;
struct ssh_message_struct;
struct ssh_packet_callbacks_struct;
struct ssh_pcap_context_struct;
struct ssh_pcap_file_struct;
struct ssh_poll_ctx_struct;
struct ssh_poll_handle_struct;
struct ssh_pollfd_t;
struct ssh_private_key_struct;
struct ssh_public_key_struct;
struct ssh_scp_struct;
struct ssh_server_callbacks_struct;
struct ssh_service_request;
struct ssh_session_struct;
struct ssh_signature_struct;
struct ssh_socket_callbacks_struct;
struct ssh_socket_struct;
struct ssh_string_struct;
struct ssh_threads_callbacks_struct;
struct ssh_timestamp;

// global variables

const crypto_sign_ed25519_ref_ge25519 crypto_sign_ed25519_ref_ge25519_base;
static char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                          "abcdefghijklmnopqrstuvwxyz"                          "0123456789+/";
static struct ssh_config_keyword_table_s ssh_config_keyword_table[] = {   { "host", SOC_HOST },   { "hostname", SOC_HOSTNAME },   { "port", SOC_PORT },   { "user", SOC_USERNAME },   { "identityfile", SOC_IDENTITY },   { "ciphers", SOC_CIPHERS },   { "compression", SOC_COMPRESSION },   { "connecttimeout", SOC_TIMEOUT },   { "protocol", SOC_PROTOCOL },   { "stricthostkeychecking", SOC_STRICTHOSTKEYCHECK },   { "userknownhostsfile", SOC_KNOWNHOSTS },   { "proxycommand", SOC_PROXYCOMMAND },   { "gssapiserveridentity", SOC_GSSAPISERVERIDENTITY },   { "gssapiserveridentity", SOC_GSSAPICLIENTIDENTITY },   { "gssapidelegatecredentials", SOC_GSSAPIDELEGATECREDENTIALS },   { NULL, SOC_UNSUPPORTED } };
static uint32_t crc_table[];
static bignum g;
static unsigned long g_int = 2;
static bignum p_group1;
static bignum p_group14;
static unsigned char p_group14_value[] = {         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,         0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,         0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,         0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,         0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,         0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,         0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,         0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,         0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11,         0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE4, 0x5B, 0x3D,         0xC2, 0x00, 0x7C, 0xB8, 0xA1, 0x63, 0xBF, 0x05, 0x98, 0xDA, 0x48, 0x36,         0x1C, 0x55, 0xD3, 0x9A, 0x69, 0x16, 0x3F, 0xA8, 0xFD, 0x24, 0xCF, 0x5F,         0x83, 0x65, 0x5D, 0x23, 0xDC, 0xA3, 0xAD, 0x96, 0x1C, 0x62, 0xF3, 0x56,         0x20, 0x85, 0x52, 0xBB, 0x9E, 0xD5, 0x29, 0x07, 0x70, 0x96, 0x96, 0x6D,         0x67, 0x0C, 0x35, 0x4E, 0x4A, 0xBC, 0x98, 0x04, 0xF1, 0x74, 0x6C, 0x08,         0xCA, 0x18, 0x21, 0x7C, 0x32, 0x90, 0x5E, 0x46, 0x2E, 0x36, 0xCE, 0x3B,         0xE3, 0x9E, 0x77, 0x2C, 0x18, 0x0E, 0x86, 0x03, 0x9B, 0x27, 0x83, 0xA2,         0xEC, 0x07, 0xA2, 0x8F, 0xB5, 0xC5, 0x5D, 0xF0, 0x6F, 0x4C, 0x52, 0xC9,         0xDE, 0x2B, 0xCB, 0xF6, 0x95, 0x58, 0x17, 0x18, 0x39, 0x95, 0x49, 0x7C,         0xEA, 0x95, 0x6A, 0xE5, 0x15, 0xD2, 0x26, 0x18, 0x98, 0xFA, 0x05, 0x10,         0x15, 0x72, 0x8E, 0x5A, 0x8A, 0xAC, 0xAA, 0x68, 0xFF, 0xFF, 0xFF, 0xFF,         0xFF, 0xFF, 0xFF, 0xFF};
static unsigned char p_group1_value[] = {         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0x0F, 0xDA, 0xA2,         0x21, 0x68, 0xC2, 0x34, 0xC4, 0xC6, 0x62, 0x8B, 0x80, 0xDC, 0x1C, 0xD1,         0x29, 0x02, 0x4E, 0x08, 0x8A, 0x67, 0xCC, 0x74, 0x02, 0x0B, 0xBE, 0xA6,         0x3B, 0x13, 0x9B, 0x22, 0x51, 0x4A, 0x08, 0x79, 0x8E, 0x34, 0x04, 0xDD,         0xEF, 0x95, 0x19, 0xB3, 0xCD, 0x3A, 0x43, 0x1B, 0x30, 0x2B, 0x0A, 0x6D,         0xF2, 0x5F, 0x14, 0x37, 0x4F, 0xE1, 0x35, 0x6D, 0x6D, 0x51, 0xC2, 0x45,         0xE4, 0x85, 0xB5, 0x76, 0x62, 0x5E, 0x7E, 0xC6, 0xF4, 0x4C, 0x42, 0xE9,         0xA6, 0x37, 0xED, 0x6B, 0x0B, 0xFF, 0x5C, 0xB6, 0xF4, 0x06, 0xB7, 0xED,         0xEE, 0x38, 0x6B, 0xFB, 0x5A, 0x89, 0x9F, 0xA5, 0xAE, 0x9F, 0x24, 0x11,         0x7C, 0x4B, 0x1F, 0xE6, 0x49, 0x28, 0x66, 0x51, 0xEC, 0xE6, 0x53, 0x81,         0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
static int ssh_crypto_initialized;
static const unsigned char base[32] = {9};
static const unsigned int minusp[32] = {  19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 };
const ge25519 ge25519_base = {     {{0x1A, 0xD5, 0x25, 0x8F, 0x60, 0x2D, 0x56, 0xC9,       0xB2, 0xA7, 0x25, 0x95, 0x60, 0xC7, 0x2C, 0x69,       0x5C, 0xDC, 0xD6, 0xFD, 0x31, 0xE2, 0xA4, 0xC0,       0xFE, 0x53, 0x6E, 0xCD, 0xD3, 0x36, 0x69, 0x21}},     {{0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,       0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,       0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66,       0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66}},     {{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},     {{0xA3, 0xDD, 0xB7, 0xA5, 0xB3, 0x8A, 0xDE, 0x6D,       0xF5, 0x52, 0x51, 0x77, 0x80, 0x9F, 0xF0, 0x20,       0x7D, 0xE3, 0xAB, 0x64, 0x8E, 0x4E, 0xEA, 0x66,       0x65, 0x76, 0x8B, 0xD7, 0x0F, 0x5F, 0x87, 0x67}} };
static const ge25519_aff ge25519_base_multiples_affine[425];
static const fe25519 ge25519_ec2d = {     {0x59, 0xF1, 0xB2, 0x26, 0x94, 0x9B, 0xD6, 0xEB,      0x56, 0xB1, 0x83, 0x82, 0x9A, 0x14, 0xE0, 0x00,      0x30, 0xD1, 0xF3, 0xEE, 0xF2, 0x80, 0x8E, 0x19,      0xE7, 0xFC, 0xDF, 0x56, 0xDC, 0xD9, 0x06, 0x24} };
static const fe25519 ge25519_ecd = {     {0xA3, 0x78, 0x59, 0x13, 0xCA, 0x4D, 0xEB, 0x75,      0xAB, 0xD8, 0x41, 0x41, 0x4D, 0x0A, 0x70, 0x00,      0x98, 0xE8, 0x79, 0x77, 0x79, 0x40, 0xC7, 0x8C,      0x73, 0xFE, 0x6F, 0x2B, 0xEE, 0x6C, 0x03, 0x52} };
static const fe25519 ge25519_sqrtm1 = {     {0xB0, 0xA0, 0x0E, 0x4A, 0x27, 0x1B, 0xEE, 0xC4,      0x78, 0xE4, 0x2F, 0xAD, 0x06, 0x18, 0x43, 0x2F,      0xA7, 0xD7, 0xFB, 0x3D, 0x99, 0x00, 0x4D, 0x2B,      0x0B, 0xDF, 0xC1, 0x4F, 0x80, 0x24, 0x83, 0x2B} };
static const uint32_t m[32] = {     0xED, 0xD3, 0xF5, 0x5C, 0x1A, 0x63, 0x12, 0x58,     0xD6, 0x9C, 0xF7, 0xA2, 0xDE, 0xF9, 0xDE, 0x14,     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 };
static const uint32_t mu[33] = {     0x1B, 0x13, 0x2C, 0x0A, 0xA3, 0xE5, 0x9C, 0xED,     0xA7, 0x29, 0x63, 0x08, 0x5D, 0x21, 0x06, 0x21,     0xEB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,     0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F };
static const char* default_methods[] = {     ""   ""  "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" ,    "ssh-ed25519,ssh-rsa,ssh-dss" ,   AES BLOWFISH DES,   AES BLOWFISH DES,   "hmac-sha2-256,hmac-sha2-512,hmac-sha1",   "hmac-sha2-256,hmac-sha2-512,hmac-sha1",   "none",   "none",   "",   "",   NULL };
static const char* ssh_kex_descriptions[] = {   "kex algos",   "server host key algo",   "encryption client->server",   "encryption server->client",   "mac algo client->server",   "mac algo server->client",   "compression algo client->server",   "compression algo server->client",   "languages client->server",   "languages server->client",   NULL };
static const char* supported_methods[] = {     ""   ""  "diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" ,    "ssh-ed25519,ssh-rsa,ssh-dss" ,   AES BLOWFISH DES_SUPPORTED,   AES BLOWFISH DES_SUPPORTED,   "hmac-sha2-256,hmac-sha2-512,hmac-sha1",   "hmac-sha2-256,hmac-sha2-512,hmac-sha1",    "none" ,    "none" ,   "",   "",   NULL };
LIBSSH_THREAD ssh_logging_callback ssh_log_cb;
LIBSSH_THREAD int ssh_log_level;
LIBSSH_THREAD void* ssh_log_userdata;
static ssh_packet_callback default_packet_handlers[];
static poll_fn ssh_poll_emu;
static int sockets_initialized = 0;
static void** libcrypto_mutexes;
static struct ssh_threads_callbacks_struct ssh_threads_noop = {     "threads_noop",     threads_noop,     threads_noop,     threads_noop,     threads_noop,     threads_id_noop };
static struct ssh_threads_callbacks_struct* user_callbacks =&ssh_threads_noop;
static struct ssh_hmac_struct ssh_hmac_tab[] = {   { "hmac-sha1",     SSH_HMAC_SHA1 },   { "hmac-sha2-256", SSH_HMAC_SHA256 },   { "hmac-sha2-384", SSH_HMAC_SHA384 },   { "hmac-sha2-512", SSH_HMAC_SHA512 },   { "hmac-md5",      SSH_HMAC_MD5 },   { NULL,            0} };

// global functions

void
agent_close(struct ssh_agent_struct* agent);

void
agent_free(struct ssh_agent_struct* agent);

int
agent_is_running(struct ssh_session_struct* session);

struct ssh_agent_struct*
agent_new(struct ssh_session_struct* session);

ssh_key
ssh_agent_get_first_ident(
    struct ssh_session_struct* session,
    char** comment
);

int
ssh_agent_get_ident_count(struct ssh_session_struct* session);

ssh_key
ssh_agent_get_next_ident(
    struct ssh_session_struct* session,
    char** comment
);

ssh_string
ssh_agent_sign_data(
    ssh_session session,
    const ssh_key pubkey,
    struct ssh_buffer_struct* data
);

ssh_string
make_bignum_string(bignum num);

bignum
make_string_bn(ssh_string string);

void
make_string_bn_inplace(
    ssh_string string,
    bignum bnout
);

void
ssh_print_bignum(
    const char* which,
    bignum num
);

struct ssh_poll_handle_struct*
ssh_bind_get_poll(struct ssh_bind_struct* sshbind);

void
blf_cbc_decrypt(
    blf_ctx*,
    uint8_t*,
    uint8_t*,
    uint32_t
);

void
blf_cbc_encrypt(
    blf_ctx*,
    uint8_t*,
    uint8_t*,
    uint32_t
);

void
blf_dec(
    blf_ctx*,
    uint32_t*,
    uint16_t
);

void
blf_ecb_decrypt(
    blf_ctx*,
    uint8_t*,
    uint32_t
);

void
blf_ecb_encrypt(
    blf_ctx*,
    uint8_t*,
    uint32_t
);

void
blf_enc(
    blf_ctx*,
    uint32_t*,
    uint16_t
);

void
blf_key(
    blf_ctx*,
    const uint8_t*,
    uint16_t
);

void
Blowfish_decipher(
    blf_ctx*,
    uint32_t*,
    uint32_t*
);

void
Blowfish_encipher(
    blf_ctx*,
    uint32_t*,
    uint32_t*
);

void
Blowfish_expand0state(
    blf_ctx*,
    const uint8_t*,
    uint16_t
);

void
Blowfish_expandstate(
    blf_ctx*,
    const uint8_t*,
    uint16_t,
    const uint8_t*,
    uint16_t
);

void
Blowfish_initstate(blf_ctx*);

uint32_t
Blowfish_stream2word(
    const uint8_t*,
    uint16_t,
    uint16_t*
);

int
buffer_add_buffer(
    ssh_buffer buffer,
    ssh_buffer source
);

int
buffer_add_ssh_string(
    ssh_buffer buffer,
    ssh_string string
);

int
buffer_add_u16(
    ssh_buffer buffer,
    uint16_t data
);

int
buffer_add_u32(
    ssh_buffer buffer,
    uint32_t data
);

int
buffer_add_u64(
    ssh_buffer buffer,
    uint64_t data
);

int
buffer_add_u8(
    ssh_buffer buffer,
    uint8_t data
);

uint32_t
buffer_get_data(
    ssh_buffer buffer,
    void* data,
    uint32_t requestedlen
);

ssh_string
buffer_get_mpint(ssh_buffer buffer);

void*
buffer_get_rest(ssh_buffer buffer);

uint32_t
buffer_get_rest_len(ssh_buffer buffer);

ssh_string
buffer_get_ssh_string(ssh_buffer buffer);

int
buffer_get_u32(
    ssh_buffer buffer,
    uint32_t* data
);

int
buffer_get_u64(
    ssh_buffer buffer,
    uint64_t* data
);

int
buffer_get_u8(
    ssh_buffer buffer,
    uint8_t* data
);

uint32_t
buffer_pass_bytes(
    ssh_buffer buffer,
    uint32_t len
);

uint32_t
buffer_pass_bytes_end(
    ssh_buffer buffer,
    uint32_t len
);

int
buffer_prepend_data(
    ssh_buffer buffer,
    const void* data,
    uint32_t len
);

int
ssh_buffer_add_data(
    ssh_buffer buffer,
    const void* data,
    uint32_t len
);

LIBSSH_API void
ssh_buffer_free(ssh_buffer buffer);

LIBSSH_API void*
ssh_buffer_get_begin(ssh_buffer buffer);

LIBSSH_API uint32_t
ssh_buffer_get_len(ssh_buffer buffer);

LIBSSH_API ssh_buffer
ssh_buffer_new(void);

int
ssh_buffer_reinit(ssh_buffer buffer);

void
ssh_buffer_set_secure(ssh_buffer buffer);

int
ssh_buffer_validate_length(
    struct ssh_buffer_struct* buffer,
    size_t len
);

LIBSSH_API int
ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct* cb);

LIBSSH_API struct ssh_threads_callbacks_struct*
ssh_threads_get_pthread(void);

LIBSSH_API struct ssh_threads_callbacks_struct*
ssh_threads_get_noop(void);

LIBSSH_API int
ssh_set_log_callback(ssh_logging_callback cb);

LIBSSH_API ssh_logging_callback
ssh_get_log_callback(void);

LIBSSH_API int
ssh_set_callbacks(
    ssh_session session,
    ssh_callbacks cb
);

LIBSSH_API int
ssh_set_channel_callbacks(
    ssh_channel channel,
    ssh_channel_callbacks cb
);

LIBSSH_API int
ssh_set_server_callbacks(
    ssh_session session,
    ssh_server_callbacks cb
);

ssh_channel
ssh_channel_new(ssh_session session);

uint32_t
ssh_crc32(
    const char* buf,
    uint32_t len
);

int
crypto_scalarmult(
    unsigned char* q,
    const unsigned char* n,
    const unsigned char* p
);

int
crypto_scalarmult_base(
    unsigned char* q,
    const unsigned char* n
);

int
ssh_client_curve25519_init(ssh_session session);

int
ssh_client_curve25519_reply(
    ssh_session session,
    ssh_buffer packet
);

int
ssh_server_curve25519_init(
    ssh_session session,
    ssh_buffer packet
);

int
dh_build_k(ssh_session session);

int
dh_generate_e(ssh_session session);

int
dh_generate_f(ssh_session session);

int
dh_generate_x(ssh_session session);

int
dh_generate_y(ssh_session session);

ssh_string
dh_get_e(ssh_session session);

ssh_string
dh_get_f(ssh_session session);

int
dh_import_e(
    ssh_session session,
    ssh_string e_string
);

int
dh_import_f(
    ssh_session session,
    ssh_string f_string
);

void
dh_import_pubkey(
    ssh_session session,
    ssh_string pubkey_string
);

int
generate_session_keys(ssh_session session);

int
hashbufin_add_cookie(
    ssh_session session,
    unsigned char* cookie
);

int
hashbufout_add_cookie(ssh_session session);

int
make_sessionid(ssh_session session);

int
ssh_client_dh_init(ssh_session session);

int
ssh_client_dh_reply(
    ssh_session session,
    ssh_buffer packet
);

void
ssh_crypto_finalize(void);

int
ssh_crypto_init(void);

int
ssh_client_ecdh_init(ssh_session session);

int
ssh_client_ecdh_reply(
    ssh_session session,
    ssh_buffer packet
);

int
ssh_server_ecdh_init(
    ssh_session session,
    ssh_buffer packet
);

int
crypto_sign_ed25519(
    unsigned char* sm,
    unsigned long long* smlen,
    const unsigned char* m,
    unsigned long long mlen,
    const ed25519_privkey sk
);

int
crypto_sign_ed25519_keypair(
    ed25519_pubkey pk,
    ed25519_privkey sk
);

int
crypto_sign_ed25519_open(
    unsigned char* m,
    unsigned long long* mlen,
    const unsigned char* sm,
    unsigned long long smlen,
    const ed25519_pubkey pk
);

void
crypto_sign_ed25519_ref_fe25519_add(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x,
    const crypto_sign_ed25519_ref_fe25519* y
);

void
crypto_sign_ed25519_ref_fe25519_cmov(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x,
    unsigned char b
);

void
crypto_sign_ed25519_ref_fe25519_freeze(crypto_sign_ed25519_ref_fe25519* r);

unsigned char
crypto_sign_ed25519_ref_fe25519_getparity(const crypto_sign_ed25519_ref_fe25519* x);

void
crypto_sign_ed25519_ref_fe25519_invert(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x
);

int
crypto_sign_ed25519_ref_fe25519_iseq_vartime(
    const crypto_sign_ed25519_ref_fe25519* x,
    const crypto_sign_ed25519_ref_fe25519* y
);

int
crypto_sign_ed25519_ref_fe25519_iszero(const crypto_sign_ed25519_ref_fe25519* x);

void
crypto_sign_ed25519_ref_fe25519_mul(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x,
    const crypto_sign_ed25519_ref_fe25519* y
);

void
crypto_sign_ed25519_ref_fe25519_neg(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x
);

void
crypto_sign_ed25519_ref_fe25519_pack(
    unsigned char r[32],
    const crypto_sign_ed25519_ref_fe25519* x
);

void
crypto_sign_ed25519_ref_fe25519_pow2523(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x
);

void
crypto_sign_ed25519_ref_fe25519_setone(crypto_sign_ed25519_ref_fe25519* r);

void
crypto_sign_ed25519_ref_fe25519_setzero(crypto_sign_ed25519_ref_fe25519* r);

void
crypto_sign_ed25519_ref_fe25519_square(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x
);

void
crypto_sign_ed25519_ref_fe25519_sub(
    crypto_sign_ed25519_ref_fe25519* r,
    const crypto_sign_ed25519_ref_fe25519* x,
    const crypto_sign_ed25519_ref_fe25519* y
);

void
crypto_sign_ed25519_ref_fe25519_unpack(
    crypto_sign_ed25519_ref_fe25519* r,
    const unsigned char x[32]
);

void
crypto_sign_ed25519_ref_double_scalarmult_vartime(
    crypto_sign_ed25519_ref_ge25519* r,
    const crypto_sign_ed25519_ref_ge25519* p1,
    const crypto_sign_ed25519_ref_sc25519* s1,
    const crypto_sign_ed25519_ref_ge25519* p2,
    const crypto_sign_ed25519_ref_sc25519* s2
);

int
crypto_sign_ed25519_ref_isneutral_vartime(const crypto_sign_ed25519_ref_ge25519* p);

void
crypto_sign_ed25519_ref_pack(
    unsigned char r[32],
    const crypto_sign_ed25519_ref_ge25519* p
);

void
crypto_sign_ed25519_ref_scalarmult_base(
    crypto_sign_ed25519_ref_ge25519* r,
    const crypto_sign_ed25519_ref_sc25519* s
);

int
crypto_sign_ed25519_ref_unpackneg_vartime(
    crypto_sign_ed25519_ref_ge25519* r,
    const unsigned char p[32]
);

int
ssh_gssapi_auth_mic(ssh_session session);

int
ssh_gssapi_handle_userauth(
    ssh_session session,
    const char* user,
    uint32_t n_oid,
    ssh_string* oids
);

SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response);

int
set_client_kex(ssh_session session);

char**
space_tokenize(const char* chain);

char*
ssh_find_matching(
    const char* in_d,
    const char* what_d
);

int
ssh_get_kex1(ssh_session session);

const char*
ssh_kex_get_description(uint32_t algo);

const char*
ssh_kex_get_supported_method(uint32_t algo);

int
ssh_kex_select_methods(ssh_session session);

void
ssh_list_kex(struct ssh_kex_struct* kex);

SSH_PACKET_CALLBACK(ssh_packet_kexinit);

int
ssh_send_kex(
    ssh_session session,
    int server_kex
);

int
verify_existing_algo(
    int algo,
    const char* name
);

ssh_public_key
publickey_from_string(
    ssh_session session,
    ssh_string pubkey_s
);

int
ssh_type_from_name(const char* name);

const char*
ssh_type_to_char(int type);

SSH_DEPRECATED LIBSSH_API void
buffer_free(ssh_buffer buffer);

SSH_DEPRECATED LIBSSH_API void*
buffer_get(ssh_buffer buffer);

SSH_DEPRECATED LIBSSH_API uint32_t
buffer_get_len(ssh_buffer buffer);

SSH_DEPRECATED LIBSSH_API ssh_buffer
buffer_new(void);

SSH_DEPRECATED LIBSSH_API ssh_channel
channel_accept_x11(
    ssh_channel channel,
    int timeout_ms
);

SSH_DEPRECATED LIBSSH_API int
channel_change_pty_size(
    ssh_channel channel,
    int cols,
    int rows
);

SSH_DEPRECATED LIBSSH_API int
channel_close(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API ssh_channel
channel_forward_accept(
    ssh_session session,
    int timeout_ms
);

SSH_DEPRECATED LIBSSH_API int
channel_forward_cancel(
    ssh_session session,
    const char* address,
    int port
);

SSH_DEPRECATED LIBSSH_API int
channel_forward_listen(
    ssh_session session,
    const char* address,
    int port,
    int* bound_port
);

SSH_DEPRECATED LIBSSH_API void
channel_free(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_get_exit_status(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API ssh_session
channel_get_session(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_is_closed(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_is_eof(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_is_open(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API ssh_channel
channel_new(ssh_session session);

SSH_DEPRECATED LIBSSH_API int
channel_open_forward(
    ssh_channel channel,
    const char* remotehost,
    int remoteport,
    const char* sourcehost,
    int localport
);

SSH_DEPRECATED LIBSSH_API int
channel_open_session(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_poll(
    ssh_channel channel,
    int is_stderr
);

SSH_DEPRECATED LIBSSH_API int
channel_read(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr
);

SSH_DEPRECATED LIBSSH_API int
channel_read_buffer(
    ssh_channel channel,
    ssh_buffer buffer,
    uint32_t count,
    int is_stderr
);

SSH_DEPRECATED LIBSSH_API int
channel_read_nonblocking(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr
);

SSH_DEPRECATED LIBSSH_API int
channel_request_env(
    ssh_channel channel,
    const char* name,
    const char* value
);

SSH_DEPRECATED LIBSSH_API int
channel_request_exec(
    ssh_channel channel,
    const char* cmd
);

SSH_DEPRECATED LIBSSH_API int
channel_request_pty(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_request_pty_size(
    ssh_channel channel,
    const char* term,
    int cols,
    int rows
);

SSH_DEPRECATED LIBSSH_API int
channel_request_send_signal(
    ssh_channel channel,
    const char* signum
);

SSH_DEPRECATED LIBSSH_API int
channel_request_sftp(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_request_shell(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API int
channel_request_subsystem(
    ssh_channel channel,
    const char* subsystem
);

SSH_DEPRECATED LIBSSH_API int
channel_request_x11(
    ssh_channel channel,
    int single_connection,
    const char* protocol,
    const char* cookie,
    int screen_number
);

SSH_DEPRECATED LIBSSH_API int
channel_select(
    ssh_channel* readchans,
    ssh_channel* writechans,
    ssh_channel* exceptchans,
    struct timeval* timeout
);

SSH_DEPRECATED LIBSSH_API int
channel_send_eof(ssh_channel channel);

SSH_DEPRECATED LIBSSH_API void
channel_set_blocking(
    ssh_channel channel,
    int blocking
);

SSH_DEPRECATED LIBSSH_API int
channel_write(
    ssh_channel channel,
    const void* data,
    uint32_t len
);

LIBSSH_API void
privatekey_free(ssh_private_key prv);

LIBSSH_API ssh_private_key
privatekey_from_file(
    ssh_session session,
    const char* filename,
    int type,
    const char* passphrase
);

LIBSSH_API void
publickey_free(ssh_public_key key);

LIBSSH_API ssh_string
publickey_from_file(
    ssh_session session,
    const char* filename,
    int* type
);

LIBSSH_API ssh_public_key
publickey_from_privatekey(ssh_private_key prv);

LIBSSH_API ssh_string
publickey_to_string(ssh_public_key key);

LIBSSH_API int
ssh_auth_list(ssh_session session);

LIBSSH_API ssh_string
ssh_get_pubkey(ssh_session session);

LIBSSH_API ssh_message
ssh_message_retrieve(
    ssh_session session,
    uint32_t packettype
);

LIBSSH_API enum ssh_keytypes_e
ssh_privatekey_type(ssh_private_key privatekey);

LIBSSH_API int
ssh_publickey_to_file(
    ssh_session session,
    const char* file,
    ssh_string pubkey,
    int type
);

LIBSSH_API int
ssh_try_publickey_from_file(
    ssh_session session,
    const char* keyfile,
    ssh_string* publickey,
    int* type
);

LIBSSH_API int
ssh_userauth_autopubkey(
    ssh_session session,
    const char* passphrase
);

LIBSSH_API int
ssh_userauth_offer_pubkey(
    ssh_session session,
    const char* username,
    int type,
    ssh_string publickey
);

LIBSSH_API int
ssh_userauth_privatekey_file(
    ssh_session session,
    const char* username,
    const char* filename,
    const char* passphrase
);

LIBSSH_API int
ssh_userauth_pubkey(
    ssh_session session,
    const char* username,
    ssh_string publickey,
    ssh_private_key privatekey
);

SSH_DEPRECATED LIBSSH_API void
string_burn(ssh_string str);

SSH_DEPRECATED LIBSSH_API ssh_string
string_copy(ssh_string str);

SSH_DEPRECATED LIBSSH_API void*
string_data(ssh_string str);

SSH_DEPRECATED LIBSSH_API int
string_fill(
    ssh_string str,
    const void* data,
    size_t len
);

SSH_DEPRECATED LIBSSH_API void
string_free(ssh_string str);

SSH_DEPRECATED LIBSSH_API ssh_string
string_from_char(const char* what);

SSH_DEPRECATED LIBSSH_API size_t
string_len(ssh_string str);

SSH_DEPRECATED LIBSSH_API ssh_string
string_new(size_t size);

SSH_DEPRECATED LIBSSH_API char*
string_to_char(ssh_string str);

struct ssh_cipher_struct*
ssh_get_ciphertab(void);

char*
ssh_basename(const char* path);

int
ssh_blocking_flush(
    ssh_session session,
    int timeout
);

ssh_channel
ssh_channel_accept_forward(
    ssh_session session,
    int timeout_ms,
    int* destination_port
);

ssh_channel
ssh_channel_accept_x11(
    ssh_channel channel,
    int timeout_ms
);

int
ssh_channel_cancel_forward(
    ssh_session session,
    const char* address,
    int port
);

int
ssh_channel_change_pty_size(
    ssh_channel channel,
    int cols,
    int rows
);

int
ssh_channel_close(ssh_channel channel);

void
ssh_channel_free(ssh_channel channel);

int
ssh_channel_get_exit_status(ssh_channel channel);

ssh_session
ssh_channel_get_session(ssh_channel channel);

int
ssh_channel_is_closed(ssh_channel channel);

int
ssh_channel_is_eof(ssh_channel channel);

int
ssh_channel_is_open(ssh_channel channel);

int
ssh_channel_listen_forward(
    ssh_session session,
    const char* address,
    int port,
    int* bound_port
);

int
ssh_channel_open_auth_agent(ssh_channel channel);

int
ssh_channel_open_forward(
    ssh_channel channel,
    const char* remotehost,
    int remoteport,
    const char* sourcehost,
    int localport
);

int
ssh_channel_open_session(ssh_channel channel);

int
ssh_channel_open_x11(
    ssh_channel channel,
    const char* orig_addr,
    int orig_port
);

int
ssh_channel_poll(
    ssh_channel channel,
    int is_stderr
);

int
ssh_channel_poll_timeout(
    ssh_channel channel,
    int timeout,
    int is_stderr
);

int
ssh_channel_read(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr
);

int
ssh_channel_read_nonblocking(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr
);

int
ssh_channel_read_timeout(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr,
    int timeout_ms
);

int
ssh_channel_request_env(
    ssh_channel channel,
    const char* name,
    const char* value
);

int
ssh_channel_request_exec(
    ssh_channel channel,
    const char* cmd
);

int
ssh_channel_request_pty(ssh_channel channel);

int
ssh_channel_request_pty_size(
    ssh_channel channel,
    const char* term,
    int cols,
    int rows
);

int
ssh_channel_request_send_signal(
    ssh_channel channel,
    const char* signum
);

int
ssh_channel_request_shell(ssh_channel channel);

int
ssh_channel_request_subsystem(
    ssh_channel channel,
    const char* subsystem
);

int
ssh_channel_request_x11(
    ssh_channel channel,
    int single_connection,
    const char* protocol,
    const char* cookie,
    int screen_number
);

int
ssh_channel_select(
    ssh_channel* readchans,
    ssh_channel* writechans,
    ssh_channel* exceptchans,
    struct timeval* timeout
);

int
ssh_channel_send_eof(ssh_channel channel);

void
ssh_channel_set_blocking(
    ssh_channel channel,
    int blocking
);

void
ssh_channel_set_counter(
    ssh_channel channel,
    ssh_counter counter
);

int
ssh_channel_write(
    ssh_channel channel,
    const void* data,
    uint32_t len
);

void
ssh_clean_pubkey_hash(unsigned char** hash);

int
ssh_connect(ssh_session session);

char*
ssh_dirname(const char* path);

void
ssh_disconnect(ssh_session session);

int
ssh_event_add_fd(
    ssh_event event,
    socket_t fd,
    short events,
    ssh_event_callback cb,
    void* userdata
);

int
ssh_event_add_session(
    ssh_event event,
    ssh_session session
);

int
ssh_event_dopoll(
    ssh_event event,
    int timeout
);

void
ssh_event_free(ssh_event event);

ssh_event
ssh_event_new(void);

int
ssh_event_remove_fd(
    ssh_event event,
    socket_t fd
);

int
ssh_event_remove_session(
    ssh_event event,
    ssh_session session
);

int
ssh_finalize(void);

void
ssh_free(ssh_session session);

const char*
ssh_get_cipher_in(ssh_session session);

const char*
ssh_get_cipher_out(ssh_session session);

const char*
ssh_get_clientbanner(ssh_session session);

const char*
ssh_get_disconnect_message(ssh_session session);

const char*
ssh_get_error(void* error);

int
ssh_get_error_code(void* error);

socket_t
ssh_get_fd(ssh_session session);

char*
ssh_get_hexa(
    const unsigned char* what,
    size_t len
);

const char*
ssh_get_hmac_in(ssh_session session);

const char*
ssh_get_hmac_out(ssh_session session);

char*
ssh_get_issue_banner(ssh_session session);

const char*
ssh_get_kex_algo(ssh_session session);

int
ssh_get_log_level(void);

void*
ssh_get_log_userdata(void);

int
ssh_get_openssh_version(ssh_session session);

int
ssh_get_poll_flags(ssh_session session);

int
ssh_get_pubkey_hash(
    ssh_session session,
    unsigned char** hash
);

int
ssh_get_publickey(
    ssh_session session,
    ssh_key* key
);

int
ssh_get_publickey_hash(
    const ssh_key key,
    enum ssh_publickey_hash_type type,
    unsigned char** hash,
    size_t* hlen
);

int
ssh_get_random(
    void* where,
    int len,
    int strong
);

const char*
ssh_get_serverbanner(ssh_session session);

int
ssh_get_status(ssh_session session);

int
ssh_get_version(ssh_session session);

int
ssh_getpass(
    const char* prompt,
    char* buf,
    size_t len,
    int echo,
    int verify
);

void
ssh_gssapi_set_creds(
    ssh_session session,
    const ssh_gssapi_creds creds
);

int
ssh_init(void);

int
ssh_is_blocking(ssh_session session);

int
ssh_is_connected(ssh_session session);

int
ssh_is_server_known(ssh_session session);

int
ssh_key_cmp(
    const ssh_key k1,
    const ssh_key k2,
    enum ssh_keycmp_e what
);

void
ssh_key_free(ssh_key key);

int
ssh_key_is_private(const ssh_key k);

int
ssh_key_is_public(const ssh_key k);

ssh_key
ssh_key_new(void);

enum ssh_keytypes_e
ssh_key_type(const ssh_key key);

enum ssh_keytypes_e
ssh_key_type_from_name(const char* name);

const char*
ssh_key_type_to_char(enum ssh_keytypes_e type);

void
ssh_message_free(ssh_message msg);

ssh_message
ssh_message_get(ssh_session session);

int
ssh_message_subtype(ssh_message msg);

int
ssh_message_type(ssh_message msg);

int
ssh_mkdir(
    const char* pathname,
    mode_t mode
);

ssh_session
ssh_new(void);

int
ssh_options_copy(
    ssh_session src,
    ssh_session* dest
);

int
ssh_options_get(
    ssh_session session,
    enum ssh_options_e type,
    char** value
);

int
ssh_options_get_port(
    ssh_session session,
    unsigned int* port_target
);

int
ssh_options_getopt(
    ssh_session session,
    int* argcptr,
    char** argv
);

int
ssh_options_parse_config(
    ssh_session session,
    const char* filename
);

int
ssh_options_set(
    ssh_session session,
    enum ssh_options_e type,
    const void* value
);

int
ssh_pcap_file_close(ssh_pcap_file pcap);

void
ssh_pcap_file_free(ssh_pcap_file pcap);

ssh_pcap_file
ssh_pcap_file_new(void);

int
ssh_pcap_file_open(
    ssh_pcap_file pcap,
    const char* filename
);

int
ssh_pki_export_privkey_file(
    const ssh_key privkey,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data,
    const char* filename
);

int
ssh_pki_export_privkey_to_pubkey(
    const ssh_key privkey,
    ssh_key* pkey
);

int
ssh_pki_export_pubkey_base64(
    const ssh_key key,
    char** b64_key
);

int
ssh_pki_generate(
    enum ssh_keytypes_e type,
    int parameter,
    ssh_key* pkey
);

int
ssh_pki_import_privkey_base64(
    const char* b64_key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data,
    ssh_key* pkey
);

int
ssh_pki_import_privkey_file(
    const char* filename,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data,
    ssh_key* pkey
);

int
ssh_pki_import_pubkey_base64(
    const char* b64_key,
    enum ssh_keytypes_e type,
    ssh_key* pkey
);

int
ssh_pki_import_pubkey_file(
    const char* filename,
    ssh_key* pkey
);

const char*
ssh_pki_key_ecdsa_name(const ssh_key key);

void
ssh_print_hexa(
    const char* descr,
    const unsigned char* what,
    size_t len
);

int
ssh_scp_accept_request(ssh_scp scp);

int
ssh_scp_close(ssh_scp scp);

int
ssh_scp_deny_request(
    ssh_scp scp,
    const char* reason
);

void
ssh_scp_free(ssh_scp scp);

int
ssh_scp_init(ssh_scp scp);

int
ssh_scp_leave_directory(ssh_scp scp);

ssh_scp
ssh_scp_new(
    ssh_session session,
    int mode,
    const char* location
);

int
ssh_scp_pull_request(ssh_scp scp);

int
ssh_scp_push_directory(
    ssh_scp scp,
    const char* dirname,
    int mode
);

int
ssh_scp_push_file(
    ssh_scp scp,
    const char* filename,
    size_t size,
    int perms
);

int
ssh_scp_push_file64(
    ssh_scp scp,
    const char* filename,
    uint64_t size,
    int perms
);

int
ssh_scp_read(
    ssh_scp scp,
    void* buffer,
    size_t size
);

const char*
ssh_scp_request_get_filename(ssh_scp scp);

int
ssh_scp_request_get_permissions(ssh_scp scp);

size_t
ssh_scp_request_get_size(ssh_scp scp);

uint64_t
ssh_scp_request_get_size64(ssh_scp scp);

const char*
ssh_scp_request_get_warning(ssh_scp scp);

int
ssh_scp_write(
    ssh_scp scp,
    const void* buffer,
    size_t len
);

int
ssh_select(
    ssh_channel* channels,
    ssh_channel* outchannels,
    socket_t maxfd,
    fd_set* readfds,
    struct timeval* timeout
);

int
ssh_send_debug(
    ssh_session session,
    const char* message,
    int always_display
);

int
ssh_send_ignore(
    ssh_session session,
    const char* data
);

int
ssh_service_request(
    ssh_session session,
    const char* service
);

int
ssh_set_agent_channel(
    ssh_session session,
    ssh_channel channel
);

int
ssh_set_agent_socket(
    ssh_session session,
    socket_t fd
);

void
ssh_set_blocking(
    ssh_session session,
    int blocking
);

void
ssh_set_counters(
    ssh_session session,
    ssh_counter scounter,
    ssh_counter rcounter
);

void
ssh_set_fd_except(ssh_session session);

void
ssh_set_fd_toread(ssh_session session);

void
ssh_set_fd_towrite(ssh_session session);

int
ssh_set_log_level(int level);

int
ssh_set_log_userdata(void* data);

int
ssh_set_pcap_file(
    ssh_session session,
    ssh_pcap_file pcapfile
);

void
ssh_silent_disconnect(ssh_session session);

void
ssh_string_burn(ssh_string str);

ssh_string
ssh_string_copy(ssh_string str);

void*
ssh_string_data(ssh_string str);

int
ssh_string_fill(
    ssh_string str,
    const void* data,
    size_t len
);

void
ssh_string_free(ssh_string str);

void
ssh_string_free_char(char* s);

ssh_string
ssh_string_from_char(const char* what);

const char*
ssh_string_get_char(ssh_string str);

size_t
ssh_string_len(ssh_string str);

ssh_string
ssh_string_new(size_t size);

char*
ssh_string_to_char(ssh_string str);

int
ssh_userauth_agent(
    ssh_session session,
    const char* username
);

int
ssh_userauth_gssapi(ssh_session session);

int
ssh_userauth_kbdint(
    ssh_session session,
    const char* user,
    const char* submethods
);

const char*
ssh_userauth_kbdint_getanswer(
    ssh_session session,
    unsigned int i
);

const char*
ssh_userauth_kbdint_getinstruction(ssh_session session);

const char*
ssh_userauth_kbdint_getname(ssh_session session);

int
ssh_userauth_kbdint_getnanswers(ssh_session session);

int
ssh_userauth_kbdint_getnprompts(ssh_session session);

const char*
ssh_userauth_kbdint_getprompt(
    ssh_session session,
    unsigned int i,
    char* echo
);

int
ssh_userauth_kbdint_setanswer(
    ssh_session session,
    unsigned int i,
    const char* answer
);

int
ssh_userauth_list(
    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_publickey(
    ssh_session session,
    const char* username,
    const ssh_key privkey
);

int
ssh_userauth_publickey_auto(
    ssh_session session,
    const char* username,
    const char* passphrase
);

int
ssh_userauth_try_publickey(
    ssh_session session,
    const char* username,
    const ssh_key pubkey
);

const char*
ssh_version(int req_version);

int
ssh_write_knownhost(ssh_session session);

char*
ssh_path_expand_tilde(const char* d);

int
ssh_timeout_update(
    struct ssh_timestamp* ts,
    int timeout
);

int
ssh_config_parse_file(
    ssh_session session,
    const char* filename
);

int
packet_decrypt(
    ssh_session session,
    void* packet,
    unsigned int len
);

uint32_t
packet_decrypt_len(
    ssh_session session,
    char* crypted
);

unsigned char*
packet_encrypt(
    ssh_session session,
    void* packet,
    unsigned int len
);

int
packet_hmac_verify(
    ssh_session session,
    ssh_buffer buffer,
    unsigned char* mac,
    enum ssh_hmac_e type
);

int
packet_send(ssh_session session);

SSH_PACKET_CALLBACK(ssh_packet_unimplemented);
SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
SSH_PACKET_CALLBACK(ssh_packet_dh_reply);
SSH_PACKET_CALLBACK(ssh_packet_newkeys);
SSH_PACKET_CALLBACK(ssh_packet_service_accept);

int
ssh_packet_parse_type(ssh_session session);

void
ssh_packet_process(
    ssh_session session,
    uint8_t type
);

void
ssh_packet_register_socket_callback(
    ssh_session session,
    struct ssh_socket_struct* s
);

int
ssh_packet_send_unimplemented(
    ssh_session session,
    uint32_t seqnum
);

void
ssh_packet_set_callbacks(
    ssh_session session,
    ssh_packet_callbacks callbacks
);

void
ssh_packet_set_default_callbacks(ssh_session session);

int
ssh_packet_socket_callback(
    const void* data,
    size_t len,
    void* user
);

void
ssh_pcap_context_free(ssh_pcap_context ctx);

ssh_pcap_context
ssh_pcap_context_new(ssh_session session);

void
ssh_pcap_context_set_file(
    ssh_pcap_context,
    ssh_pcap_file
);

int
ssh_pcap_context_write(
    ssh_pcap_context,
    enum ssh_pcap_direction direction,
    void* data,
    uint32_t len,
    uint32_t origlen
);

int
ssh_pcap_file_write_packet(
    ssh_pcap_file pcap,
    ssh_buffer packet,
    uint32_t original_len
);

void
ssh_key_clean(ssh_key key);

void
_ssh_pki_log(
    const char* function,
    const char* format,
    ...
);

int
bcrypt_pbkdf(
    const char* pass,
    size_t passlen,
    const uint8_t* salt,
    size_t saltlen,
    uint8_t* key,
    size_t keylen,
    unsigned int rounds
);

ssh_signature
pki_do_sign(
    const ssh_key privkey,
    const unsigned char* hash,
    size_t hlen
);

ssh_signature
pki_do_sign_sessionid(
    const ssh_key key,
    const unsigned char* hash,
    size_t hlen
);

int
pki_ed25519_key_cmp(
    const ssh_key k1,
    const ssh_key k2,
    enum ssh_keycmp_e what
);

int
pki_ed25519_key_dup(
    ssh_key new,
    const ssh_key key
);

int
pki_ed25519_public_key_to_blob(
    ssh_buffer buffer,
    ssh_key key
);

int
pki_ed25519_sig_from_blob(
    ssh_signature sig,
    ssh_string sig_blob
);

ssh_string
pki_ed25519_sig_to_blob(ssh_signature sig);

int
pki_ed25519_sign(
    const ssh_key privkey,
    ssh_signature sig,
    const unsigned char* hash,
    size_t hlen
);

int
pki_ed25519_verify(
    const ssh_key pubkey,
    ssh_signature sig,
    const unsigned char* hash,
    size_t hlen
);

int
pki_export_pubkey_rsa1(
    const ssh_key key,
    const char* host,
    char* rsa1,
    size_t rsa1_len
);

int
pki_key_compare(
    const ssh_key k1,
    const ssh_key k2,
    enum ssh_keycmp_e what
);

ssh_key
pki_key_dup(
    const ssh_key key,
    int demote
);

void int
pki_key_ecdsa_nid_from_name(const char* name);

const char*
pki_key_ecdsa_nid_to_name(int nid);

int
pki_key_generate_dss(
    ssh_key key,
    int parameter
);

int
pki_key_generate_ecdsa(
    ssh_key key,
    int parameter
);

int
pki_key_generate_ed25519(ssh_key key);

int
pki_key_generate_rsa(
    ssh_key key,
    int parameter
);

ssh_key
pki_private_key_from_base64(
    const char* b64_key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

ssh_string
pki_private_key_to_pem(
    const ssh_key key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

int
pki_pubkey_build_dss(
    ssh_key key,
    ssh_string p,
    ssh_string q,
    ssh_string g,
    ssh_string pubkey
);

int
pki_pubkey_build_ecdsa(
    ssh_key key,
    int nid,
    ssh_string e
);

int
pki_pubkey_build_rsa(
    ssh_key key,
    ssh_string e,
    ssh_string n
);

ssh_string
pki_publickey_to_blob(const ssh_key key);

ssh_signature
pki_signature_from_blob(
    const ssh_key pubkey,
    const ssh_string sig_blob,
    enum ssh_keytypes_e type
);

ssh_string
pki_signature_to_blob(const ssh_signature sign);

int
pki_signature_verify(
    ssh_session session,
    const ssh_signature sig,
    const ssh_key key,
    const unsigned char* hash,
    size_t hlen
);

ssh_string
ssh_pki_openssh_privkey_export(
    const ssh_key privkey,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

ssh_key
ssh_pki_openssh_privkey_import(
    const char* text_key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

void
ssh_poll_add_events(
    ssh_poll_handle p,
    short events
);

int
ssh_poll_ctx_add(
    ssh_poll_ctx ctx,
    ssh_poll_handle p
);

int
ssh_poll_ctx_add_socket(
    ssh_poll_ctx ctx,
    struct ssh_socket_struct* s
);

int
ssh_poll_ctx_dopoll(
    ssh_poll_ctx ctx,
    int timeout
);

void
ssh_poll_ctx_free(ssh_poll_ctx ctx);

ssh_poll_ctx
ssh_poll_ctx_new(size_t chunk_size);

void
ssh_poll_ctx_remove(
    ssh_poll_ctx ctx,
    ssh_poll_handle p
);

void
ssh_poll_free(ssh_poll_handle p);

ssh_poll_ctx
ssh_poll_get_ctx(ssh_poll_handle p);

short
ssh_poll_get_events(ssh_poll_handle p);

socket_t
ssh_poll_get_fd(ssh_poll_handle p);

ssh_poll_handle
ssh_poll_new(
    socket_t fd,
    short events,
    ssh_poll_callback cb,
    void* userdata
);

void
ssh_poll_remove_events(
    ssh_poll_handle p,
    short events
);

void
ssh_poll_set_callback(
    ssh_poll_handle p,
    ssh_poll_callback cb,
    void* userdata
);

void
ssh_poll_set_events(
    ssh_poll_handle p,
    short events
);

void
ssh_poll_set_fd(
    ssh_poll_handle p,
    socket_t fd
);

void
_ssh_set_error(
    void* error,
    int code,
    const char* function,
    const char* descr,
    ...
);

ssh_buffer
base64_to_bin(const char* source);

unsigned char*
bin_to_base64(
    const unsigned char* source,
    int len
);

int
compress_buffer(
    ssh_session session,
    ssh_buffer buf
);

int
decompress_buffer(
    ssh_session session,
    ssh_buffer buf,
    size_t maxlen
);

int
match_hostname(
    const char* host,
    const char* pattern,
    unsigned int len
);

socket_t
ssh_connect_host(
    ssh_session session,
    const char* host,
    const char* bind_addr,
    int port,
    long timeout,
    long usec
);

socket_t
ssh_connect_host_nonblocking(
    ssh_session session,
    const char* host,
    const char* bind_addr,
    int port
);

void
ssh_log_common(
    struct ssh_common_struct* common,
    int verbosity,
    const char* function,
    const char* format,
    ...
);

int
ssh_send_banner(
    ssh_session session,
    int is_server
);

void
crypto_sign_ed25519_ref_sc25519_2interleave2(
    unsigned char r[127],
    const crypto_sign_ed25519_ref_sc25519* s1,
    const crypto_sign_ed25519_ref_sc25519* s2
);

void
crypto_sign_ed25519_ref_sc25519_add(
    crypto_sign_ed25519_ref_sc25519* r,
    const crypto_sign_ed25519_ref_sc25519* x,
    const crypto_sign_ed25519_ref_sc25519* y
);

void
crypto_sign_ed25519_ref_sc25519_from32bytes(
    crypto_sign_ed25519_ref_sc25519* r,
    const unsigned char x[32]
);

void
crypto_sign_ed25519_ref_sc25519_from64bytes(
    crypto_sign_ed25519_ref_sc25519* r,
    const unsigned char x[64]
);

void
crypto_sign_ed25519_ref_sc25519_from_shortsc(
    crypto_sign_ed25519_ref_sc25519* r,
    const crypto_sign_ed25519_ref_shortsc25519* x
);

int
crypto_sign_ed25519_ref_sc25519_isshort_vartime(const crypto_sign_ed25519_ref_sc25519* x);

int
crypto_sign_ed25519_ref_sc25519_iszero_vartime(const crypto_sign_ed25519_ref_sc25519* x);

int
crypto_sign_ed25519_ref_sc25519_lt_vartime(
    const crypto_sign_ed25519_ref_sc25519* x,
    const crypto_sign_ed25519_ref_sc25519* y
);

void
crypto_sign_ed25519_ref_sc25519_mul(
    crypto_sign_ed25519_ref_sc25519* r,
    const crypto_sign_ed25519_ref_sc25519* x,
    const crypto_sign_ed25519_ref_sc25519* y
);

void
crypto_sign_ed25519_ref_sc25519_mul_shortsc(
    crypto_sign_ed25519_ref_sc25519* r,
    const crypto_sign_ed25519_ref_sc25519* x,
    const crypto_sign_ed25519_ref_shortsc25519* y
);

void
crypto_sign_ed25519_ref_sc25519_sub_nored(
    crypto_sign_ed25519_ref_sc25519* r,
    const crypto_sign_ed25519_ref_sc25519* x,
    const crypto_sign_ed25519_ref_sc25519* y
);

void
crypto_sign_ed25519_ref_sc25519_to32bytes(
    unsigned char r[32],
    const crypto_sign_ed25519_ref_sc25519* x
);

void
crypto_sign_ed25519_ref_sc25519_window3(
    signed char r[85],
    const crypto_sign_ed25519_ref_sc25519* s
);

void
crypto_sign_ed25519_ref_sc25519_window5(
    signed char r[51],
    const crypto_sign_ed25519_ref_sc25519* s
);

void
crypto_sign_ed25519_ref_shortsc25519_from16bytes(
    crypto_sign_ed25519_ref_shortsc25519* r,
    const unsigned char x[16]
);

int
ssh_scp_integer_mode(const char* mode);

int
ssh_scp_read_string(
    ssh_scp scp,
    char* buffer,
    size_t len
);

char*
ssh_scp_string_mode(int mode);

LIBSSH_API int
ssh_bind_accept(
    ssh_bind ssh_bind_o,
    ssh_session session
);

LIBSSH_API int
ssh_bind_accept_fd(
    ssh_bind ssh_bind_o,
    ssh_session session,
    socket_t fd
);

LIBSSH_API void
ssh_bind_fd_toaccept(ssh_bind ssh_bind_o);

LIBSSH_API void
ssh_bind_free(ssh_bind ssh_bind_o);

LIBSSH_API socket_t
ssh_bind_get_fd(ssh_bind ssh_bind_o);

LIBSSH_API int
ssh_bind_listen(ssh_bind ssh_bind_o);

LIBSSH_API ssh_bind
ssh_bind_new(void);

LIBSSH_API int
ssh_bind_options_set(
    ssh_bind sshbind,
    enum ssh_bind_options_e type,
    const void* value
);

LIBSSH_API void
ssh_bind_set_blocking(
    ssh_bind ssh_bind_o,
    int blocking
);

LIBSSH_API int
ssh_bind_set_callbacks(
    ssh_bind sshbind,
    ssh_bind_callbacks callbacks,
    void* userdata
);

LIBSSH_API void
ssh_bind_set_fd(
    ssh_bind ssh_bind_o,
    socket_t fd
);

LIBSSH_API int
ssh_channel_open_reverse_forward(
    ssh_channel channel,
    const char* remotehost,
    int remoteport,
    const char* sourcehost,
    int localport
);

LIBSSH_API int
ssh_channel_open_x11(
    ssh_channel channel,
    const char* orig_addr,
    int orig_port
);

LIBSSH_API int
ssh_channel_request_send_exit_signal(
    ssh_channel channel,
    const char* signum,
    int core,
    const char* errmsg,
    const char* lang
);

LIBSSH_API int
ssh_channel_request_send_exit_status(
    ssh_channel channel,
    int exit_status
);

LIBSSH_API int
ssh_channel_write_stderr(
    ssh_channel channel,
    const void* data,
    uint32_t len
);

LIBSSH_API ssh_gssapi_creds
ssh_gssapi_get_creds(ssh_session session);

LIBSSH_API int
ssh_handle_key_exchange(ssh_session session);

LIBSSH_API const char*
ssh_message_auth_password(ssh_message msg);

LIBSSH_API ssh_key
ssh_message_auth_pubkey(ssh_message msg);

LIBSSH_API const char*
ssh_message_auth_user(ssh_message msg);

LIBSSH_API int
ssh_message_reply_default(ssh_message msg);

LIBSSH_API void
ssh_set_auth_methods(
    ssh_session session,
    int auth_methods
);

LIBSSH_API void
ssh_set_message_callback(
    ssh_session session,
    int(*)(ssh_session session, ssh_message msg, void*data) ssh_bind_message_callback,
    void* data
);

int
sftp_async_read(
    sftp_file file,
    void* data,
    uint32_t len,
    uint32_t id
);

int
sftp_async_read_begin(
    sftp_file file,
    uint32_t len
);

void
sftp_attributes_free(sftp_attributes file);

char*
sftp_canonicalize_path(
    sftp_session sftp,
    const char* path
);

int
sftp_chmod(
    sftp_session sftp,
    const char* file,
    mode_t mode
);

int
sftp_chown(
    sftp_session sftp,
    const char* file,
    uid_t owner,
    gid_t group
);

int
sftp_close(sftp_file file);

int
sftp_closedir(sftp_dir dir);

int
sftp_dir_eof(sftp_dir dir);

int
sftp_extension_supported(
    sftp_session sftp,
    const char* name,
    const char* data
);

unsigned int
sftp_extensions_get_count(sftp_session sftp);

const char*
sftp_extensions_get_data(
    sftp_session sftp,
    unsigned int indexn
);

const char*
sftp_extensions_get_name(
    sftp_session sftp,
    unsigned int indexn
);

void
sftp_file_set_blocking(sftp_file handle);

void
sftp_file_set_nonblocking(sftp_file handle);

void
sftp_free(sftp_session sftp);

sftp_attributes
sftp_fstat(sftp_file file);

sftp_statvfs_t
sftp_fstatvfs(sftp_file file);

int
sftp_get_error(sftp_session sftp);

int
sftp_init(sftp_session sftp);

sftp_attributes
sftp_lstat(
    sftp_session session,
    const char* path
);

int
sftp_mkdir(
    sftp_session sftp,
    const char* directory,
    mode_t mode
);

sftp_session
sftp_new(ssh_session session);

sftp_session
sftp_new_channel(
    ssh_session session,
    ssh_channel channel
);

sftp_file
sftp_open(
    sftp_session session,
    const char* file,
    int accesstype,
    mode_t mode
);

sftp_dir
sftp_opendir(
    sftp_session session,
    const char* path
);

ssize_t
sftp_read(
    sftp_file file,
    void* buf,
    size_t count
);

sftp_attributes
sftp_readdir(
    sftp_session session,
    sftp_dir dir
);

char*
sftp_readlink(
    sftp_session sftp,
    const char* path
);

int
sftp_rename(
    sftp_session sftp,
    const char* original,
    const char* newname
);

void
sftp_rewind(sftp_file file);

int
sftp_rmdir(
    sftp_session sftp,
    const char* directory
);

int
sftp_seek(
    sftp_file file,
    uint32_t new_offset
);

int
sftp_seek64(
    sftp_file file,
    uint64_t new_offset
);

int
sftp_server_init(sftp_session sftp);

sftp_session
sftp_server_new(
    ssh_session session,
    ssh_channel chan
);

int
sftp_server_version(sftp_session sftp);

int
sftp_setstat(
    sftp_session sftp,
    const char* file,
    sftp_attributes attr
);

sftp_attributes
sftp_stat(
    sftp_session session,
    const char* path
);

sftp_statvfs_t
sftp_statvfs(
    sftp_session sftp,
    const char* path
);

void
sftp_statvfs_free(sftp_statvfs_t statvfs_o);

int
sftp_symlink(
    sftp_session sftp,
    const char* target,
    const char* dest
);

unsigned long
sftp_tell(sftp_file file);

uint64_t
sftp_tell64(sftp_file file);

int
sftp_unlink(
    sftp_session sftp,
    const char* file
);

int
sftp_utimes(
    sftp_session sftp,
    const char* file,
    const struct timeval* times
);

ssize_t
sftp_write(
    sftp_file file,
    const void* buf,
    size_t count
);

void
ssh_execute_command(
    const char* command,
    socket_t in,
    socket_t out
);

int
ssh_socket_buffered_write_bytes(ssh_socket s);

void
ssh_socket_cleanup(void);

void
ssh_socket_close(ssh_socket s);

int
ssh_socket_connect(
    ssh_socket s,
    const char* host,
    int port,
    const char* bind_addr
);

int
ssh_socket_connect_proxycommand(
    ssh_socket s,
    const char* command
);

int
ssh_socket_data_available(ssh_socket s);

int
ssh_socket_data_writable(ssh_socket s);

int
ssh_socket_fd_isset(
    ssh_socket s,
    fd_set* set
);

void
ssh_socket_fd_set(
    ssh_socket s,
    fd_set* set,
    socket_t* max_fd
);

void
ssh_socket_free(ssh_socket s);

socket_t
ssh_socket_get_fd_in(ssh_socket s);

int
ssh_socket_get_poll_flags(ssh_socket s);

struct ssh_poll_handle_struct*
ssh_socket_get_poll_handle_in(ssh_socket s);

struct ssh_poll_handle_struct*
ssh_socket_get_poll_handle_out(ssh_socket s);

int
ssh_socket_get_status(ssh_socket s);

int
ssh_socket_init(void);

int
ssh_socket_is_open(ssh_socket s);

ssh_socket
ssh_socket_new(ssh_session session);

int
ssh_socket_nonblocking_flush(ssh_socket s);

int
ssh_socket_pollcallback(
    struct ssh_poll_handle_struct* p,
    socket_t fd,
    int revents,
    void* v_s
);

void
ssh_socket_reset(ssh_socket s);

int
ssh_socket_set_blocking(socket_t fd);

void
ssh_socket_set_callbacks(
    ssh_socket s,
    ssh_socket_callbacks callbacks
);

void
ssh_socket_set_except(ssh_socket s);

void
ssh_socket_set_fd(
    ssh_socket s,
    socket_t fd
);

void
ssh_socket_set_fd_in(
    ssh_socket s,
    socket_t fd
);

void
ssh_socket_set_fd_out(
    ssh_socket s,
    socket_t fd
);

int
ssh_socket_set_nonblocking(socket_t fd);

void
ssh_socket_set_read_wontblock(ssh_socket s);

void
ssh_socket_set_write_wontblock(ssh_socket s);

int
ssh_socket_unix(
    ssh_socket s,
    const char* path
);

int
ssh_socket_write(
    ssh_socket s,
    const void* buffer,
    int len
);

int
crypt_set_algorithms(
    ssh_session session,
    enum ssh_des_e des_type
);

int
crypt_set_algorithms_server(ssh_session session);

void
crypto_free(struct ssh_crypto_struct* crypto);

struct ssh_crypto_struct*
crypto_new(void);

void
evp(
    int nid,
    unsigned char* digest,
    int len,
    unsigned char* hash,
    unsigned int* hlen
);

void
evp_final(
    EVPCTX ctx,
    unsigned char* md,
    unsigned int* mdlen
);

EVPCTX
evp_init(int nid);

void
evp_update(
    EVPCTX ctx,
    const void* data,
    unsigned long len
);

size_t
hmac_digest_len(enum ssh_hmac_e type);

void
hmac_final(
    HMACCTX ctx,
    unsigned char* hashmacbuf,
    unsigned int* len
);

HMACCTX
hmac_init(
    const void* key,
    int len,
    enum ssh_hmac_e type
);

void
hmac_update(
    HMACCTX c,
    const void* data,
    unsigned long len
);

void
md5_final(
    unsigned char* md,
    MD5CTX c
);

MD5CTX
md5_init(void);

void
md5_update(
    MD5CTX c,
    const void* data,
    unsigned long len
);

void
sha1(
    unsigned char* digest,
    int len,
    unsigned char* hash
);

void
sha1_final(
    unsigned char* md,
    SHACTX c
);

SHACTX
sha1_init(void);

void
sha1_update(
    SHACTX c,
    const void* data,
    unsigned long len
);

void
sha256(
    unsigned char* digest,
    int len,
    unsigned char* hash
);

void
sha256_final(
    unsigned char* md,
    SHA256CTX c
);

SHA256CTX
sha256_init(void);

void
sha256_update(
    SHA256CTX c,
    const void* data,
    unsigned long len
);

void
sha384(
    unsigned char* digest,
    int len,
    unsigned char* hash
);

void
sha384_final(
    unsigned char* md,
    SHA384CTX c
);

SHA384CTX
sha384_init(void);

void
sha384_update(
    SHA384CTX c,
    const void* data,
    unsigned long len
);

void
sha512(
    unsigned char* digest,
    int len,
    unsigned char* hash
);

void
sha512_final(
    unsigned char* md,
    SHA512CTX c
);

SHA512CTX
sha512_init(void);

void
sha512_update(
    SHA512CTX c,
    const void* data,
    unsigned long len
);

void
ssh_cipher_clear(struct ssh_cipher_struct* cipher);

struct ssh_hmac_struct*
ssh_get_hmactab(void);

const char*
ssh_hmac_type_to_string(enum ssh_hmac_e hmac_type);

ssh_mac_ctx
ssh_mac_ctx_init(enum ssh_mac_e type);

void
ssh_mac_final(
    unsigned char* md,
    ssh_mac_ctx ctx
);

void
ssh_mac_update(
    ssh_mac_ctx ctx,
    const void* data,
    unsigned long len
);

void
ssh_reseed(void);

void
agent_close(struct ssh_agent_struct* agent);

static
int
agent_connect(ssh_session session);

void
agent_free(ssh_agent agent);

static
uint32_t
agent_get_u32(const void* vp);

int
agent_is_running(ssh_session session);

ssh_agent
agent_new(struct ssh_session_struct* session);

static
void
agent_put_u32(
    void* vp,
    uint32_t v
);

static
void
agent_set_channel(
    struct ssh_agent_struct* agent,
    ssh_channel channel
);

static
int
agent_talk(
    struct ssh_session_struct* session,
    struct ssh_buffer_struct* request,
    struct ssh_buffer_struct* reply
);

static
size_t
atomicio(
    struct ssh_agent_struct* agent,
    void* buf,
    size_t n,
    int do_read
);

ssh_key
ssh_agent_get_first_ident(
    struct ssh_session_struct* session,
    char** comment
);

int
ssh_agent_get_ident_count(struct ssh_session_struct* session);

ssh_key
ssh_agent_get_next_ident(
    struct ssh_session_struct* session,
    char** comment
);

ssh_string
ssh_agent_sign_data(
    ssh_session session,
    const ssh_key pubkey,
    struct ssh_buffer_struct* data
);

int
ssh_set_agent_channel(
    ssh_session session,
    ssh_channel channel
);

int
ssh_set_agent_socket(
    ssh_session session,
    socket_t fd
);

void
ssh_agent_state_free(void* data);

static
int
ssh_auth_response_termination(void* user);

void
ssh_kbdint_clean(ssh_kbdint kbd);

void
ssh_kbdint_free(ssh_kbdint kbd);

ssh_kbdint
ssh_kbdint_new(void);

SSH_PACKET_CALLBACK(ssh_packet_userauth_banner);
SSH_PACKET_CALLBACK(ssh_packet_userauth_failure);
SSH_PACKET_CALLBACK(ssh_packet_userauth_success);
SSH_PACKET_CALLBACK(ssh_packet_userauth_pk_ok);
SSH_PACKET_CALLBACK(ssh_packet_userauth_info_request);

int
ssh_userauth_agent_pubkey(
    ssh_session session,
    const char* username,
    ssh_public_key publickey
);

static
int
ssh_userauth_agent_publickey(
    ssh_session session,
    const char* username,
    ssh_key pubkey
);

static
int
ssh_userauth_get_response(ssh_session session);

static
int
ssh_userauth_kbdint_init(
    ssh_session session,
    const char* username,
    const char* submethods
);

static
int
ssh_userauth_kbdint_send(ssh_session session);

static
int
ssh_userauth_request_service(ssh_session session);

static
int
_base64_to_bin(
    unsigned char dest[3],
    const char* source,
    int num
);

static
void
_bin_to_base64(
    unsigned char* dest,
    const unsigned char source[3],
    int len
);

ssh_buffer
base64_to_bin(const char* source);

unsigned char*
bin_to_base64(
    const unsigned char* source,
    int len
);

static
int
get_equals(char* string);

static
int
to_block4(
    unsigned long* block,
    const char* source,
    int num
);

ssh_string
make_bignum_string(bignum num);

bignum
make_string_bn(ssh_string string);

void
make_string_bn_inplace(
    ssh_string string,
    bignum bnout
);

void
ssh_print_bignum(
    const char* which,
    bignum num
);

static
socket_t
bind_socket(
    ssh_bind sshbind,
    const char* hostname,
    int port
);

ssh_poll_handle
ssh_bind_get_poll(ssh_bind sshbind);

static
int
ssh_bind_import_keys(ssh_bind sshbind);

static
int
ssh_bind_poll_callback(
    ssh_poll_handle sshpoll,
    socket_t fd,
    int revents,
    void* user
);

int
_ssh_buffer_pack(
    struct ssh_buffer_struct* buffer,
    const char* format,
    int argc,
    ...
);

int
_ssh_buffer_unpack(
    struct ssh_buffer_struct* buffer,
    const char* format,
    int argc,
    ...
);

int
buffer_add_buffer(
    struct ssh_buffer_struct* buffer,
    struct ssh_buffer_struct* source
);

int
buffer_add_ssh_string(
    struct ssh_buffer_struct* buffer,
    struct ssh_string_struct* string
);

int
buffer_add_u16(
    struct ssh_buffer_struct* buffer,
    uint16_t data
);

int
buffer_add_u32(
    struct ssh_buffer_struct* buffer,
    uint32_t data
);

int
buffer_add_u64(
    struct ssh_buffer_struct* buffer,
    uint64_t data
);

int
buffer_add_u8(
    struct ssh_buffer_struct* buffer,
    uint8_t data
);

uint32_t
buffer_get_data(
    struct ssh_buffer_struct* buffer,
    void* data,
    uint32_t len
);

struct ssh_string_struct*
buffer_get_mpint(struct ssh_buffer_struct* buffer);

void*
buffer_get_rest(struct ssh_buffer_struct* buffer);

uint32_t
buffer_get_rest_len(struct ssh_buffer_struct* buffer);

struct ssh_string_struct*
buffer_get_ssh_string(struct ssh_buffer_struct* buffer);

int
buffer_get_u32(
    struct ssh_buffer_struct* buffer,
    uint32_t* data
);

int
buffer_get_u64(
    struct ssh_buffer_struct* buffer,
    uint64_t* data
);

int
buffer_get_u8(
    struct ssh_buffer_struct* buffer,
    uint8_t* data
);

uint32_t
buffer_pass_bytes(
    struct ssh_buffer_struct* buffer,
    uint32_t len
);

uint32_t
buffer_pass_bytes_end(
    struct ssh_buffer_struct* buffer,
    uint32_t len
);

int
buffer_prepend_data(
    struct ssh_buffer_struct* buffer,
    const void* data,
    uint32_t len
);

static
void
buffer_shift(ssh_buffer buffer);

static
int
realloc_buffer(
    struct ssh_buffer_struct* buffer,
    size_t needed
);

int
ssh_buffer_add_data(
    struct ssh_buffer_struct* buffer,
    const void* data,
    uint32_t len
);

void
ssh_buffer_free(struct ssh_buffer_struct* buffer);

void*
ssh_buffer_get_begin(struct ssh_buffer_struct* buffer);

uint32_t
ssh_buffer_get_len(struct ssh_buffer_struct* buffer);

int
ssh_buffer_pack_va(
    struct ssh_buffer_struct* buffer,
    const char* format,
    int argc,
    va_list ap
);

int
ssh_buffer_reinit(struct ssh_buffer_struct* buffer);

int
ssh_buffer_unpack_va(
    struct ssh_buffer_struct* buffer,
    const char* format,
    int argc,
    va_list ap
);

static
void
ssh_legacy_log_callback(
    int priority,
    const char* function,
    const char* buffer,
    void* userdata
);

int
channel_default_bufferize(
    ssh_channel channel,
    void* data,
    int len,
    int is_stderr
);

static
ssh_channel
channel_from_msg(
    ssh_session session,
    ssh_buffer packet
);

static
int
channel_open(
    ssh_channel channel,
    const char* type,
    int window,
    int maxpacket,
    ssh_buffer payload
);

static
int
channel_protocol_select(
    ssh_channel* rchans,
    ssh_channel* wchans,
    ssh_channel* echans,
    ssh_channel* rout,
    ssh_channel* wout,
    ssh_channel* eout
);

static
int
channel_request(
    ssh_channel channel,
    const char* request,
    ssh_buffer buffer,
    int reply
);

static
int
channel_write_common(
    ssh_channel channel,
    const void* data,
    uint32_t len,
    int is_stderr
);

static
int
count_ptrs(ssh_channel* ptrs);

static
char*
generate_cookie(void);

static
int
global_request(
    ssh_session session,
    const char* request,
    ssh_buffer buffer,
    int reply
);

static
int
grow_window(
    ssh_session session,
    ssh_channel channel,
    int minimumsize
);

static
ssh_channel
ssh_channel_accept(
    ssh_session session,
    int channeltype,
    int timeout_ms,
    int* destination_port
);

void
ssh_channel_do_free(ssh_channel channel);

static
int
ssh_channel_exit_status_termination(void* c);

int
ssh_channel_flush(ssh_channel channel);

ssh_channel
ssh_channel_from_local(
    ssh_session session,
    uint32_t id
);

uint32_t
ssh_channel_new_id(ssh_session session);

int
ssh_channel_open_reverse_forward(
    ssh_channel channel,
    const char* remotehost,
    int remoteport,
    const char* sourcehost,
    int localport
);

static
int
ssh_channel_open_termination(void* c);

static
int
ssh_channel_read_termination(void* s);

int
ssh_channel_request_send_exit_signal(
    ssh_channel channel,
    const char* sig,
    int core,
    const char* errmsg,
    const char* lang
);

int
ssh_channel_request_send_exit_status(
    ssh_channel channel,
    int exit_status
);

int
ssh_channel_request_sftp(ssh_channel channel);

static
int
ssh_channel_request_termination(void* c);

static
int
ssh_channel_waitwindow_termination(void* c);

uint32_t
ssh_channel_window_size(ssh_channel channel);

int
ssh_channel_write_stderr(
    ssh_channel channel,
    const void* data,
    uint32_t len
);

ssh_channel
ssh_forward_accept(
    ssh_session session,
    int timeout_ms
);

int
ssh_forward_cancel(
    ssh_session session,
    const char* address,
    int port
);

int
ssh_forward_listen(
    ssh_session session,
    const char* address,
    int port,
    int* bound_port
);

static
int
ssh_global_request_termination(void* s);

SSH_PACKET_CALLBACK(ssh_packet_channel_open_conf);
SSH_PACKET_CALLBACK(ssh_packet_channel_open_fail);
SSH_PACKET_CALLBACK(channel_rcv_change_window);
SSH_PACKET_CALLBACK(channel_rcv_data);
SSH_PACKET_CALLBACK(channel_rcv_eof);
SSH_PACKET_CALLBACK(channel_rcv_close);
SSH_PACKET_CALLBACK(channel_rcv_request);
SSH_PACKET_CALLBACK(ssh_packet_channel_success);
SSH_PACKET_CALLBACK(ssh_packet_channel_failure);
SSH_PACKET_CALLBACK(ssh_request_success);
SSH_PACKET_CALLBACK(ssh_request_denied);

static
int
ssh_waitsession_unblocked(void* s);

static
int
callback_receive_banner(
    const void* data,
    size_t len,
    void* user
);

static
int
dh_handshake(ssh_session session);

static
void
socket_callback_connected(
    int code,
    int errno_code,
    void* user
);

static
void
ssh_client_connection_callback(ssh_session session);

static
int
ssh_connect_termination(void* user);

const char*
ssh_copyright(void);

int
ssh_send_banner(
    ssh_session session,
    int server
);

int
ssh_service_request(
    ssh_session session,
    const char* service
);

static
int
ssh_service_request_termination(void* s);

static
char*
ssh_config_get_cmd(char** str);

static
int
ssh_config_get_int(
    char** str,
    int notfound
);

static
enum ssh_config_opcode_e
ssh_config_get_opcode(char* keyword);

static
const char*
ssh_config_get_str_tok(
    char** str,
    const char* def
);

static
char*
ssh_config_get_token(char** str);

static
int
ssh_config_get_yesno(
    char** str,
    int notfound
);

int
ssh_config_parse_file(
    ssh_session session,
    const char* filename
);

static
int
ssh_config_parse_line(
    ssh_session session,
    const char* line,
    unsigned int count,
    int* parsing,
    int seen[]
);

static
int
getai(
    const char* host,
    int port,
    struct addrinfo** ai
);

static
int
ssh_connect_ai_timeout(
    ssh_session session,
    const char* host,
    int port,
    struct addrinfo* ai,
    long timeout,
    long usec,
    socket_t s
);

socket_t
ssh_connect_host(
    ssh_session session,
    const char* host,
    const char* bind_addr,
    int port,
    long timeout,
    long usec
);

socket_t
ssh_connect_host_nonblocking(
    ssh_session session,
    const char* host,
    const char* bind_addr,
    int port
);

static
int
ssh_connect_socket_close(socket_t s);

static
int
ssh_select_cb(
    socket_t fd,
    int revents,
    void* userdata
);

uint32_t
ssh_crc32(
    const char* buf,
    uint32_t len
);

int
dh_build_k(ssh_session session);

int
dh_generate_e(ssh_session session);

int
dh_generate_f(ssh_session session);

int
dh_generate_x(ssh_session session);

int
dh_generate_y(ssh_session session);

ssh_string
dh_get_e(ssh_session session);

ssh_string
dh_get_f(ssh_session session);

int
dh_import_e(
    ssh_session session,
    ssh_string e_string
);

int
dh_import_f(
    ssh_session session,
    ssh_string f_string
);

void
dh_import_pubkey(
    ssh_session session,
    ssh_string pubkey_string
);

static
int
generate_one_key(
    ssh_string k,
    struct ssh_crypto_struct* crypto,
    unsigned char** output,
    char letter,
    size_t requested_size
);

int
generate_session_keys(ssh_session session);

int
hashbufin_add_cookie(
    ssh_session session,
    unsigned char* cookie
);

int
hashbufout_add_cookie(ssh_session session);

int
make_sessionid(ssh_session session);

static
bignum
select_p(enum ssh_key_exchange_e type);

int
ssh_client_dh_init(ssh_session session);

int
ssh_client_dh_reply(
    ssh_session session,
    ssh_buffer packet
);

void
ssh_crypto_finalize(void);

int
ssh_crypto_init(void);

int
ssh_get_random(
    void* where,
    int len,
    int strong
);

void
_ssh_set_error(
    void* error,
    int code,
    const char* function,
    const char* descr,
    ...
);

void
_ssh_set_error_invalid(
    void* error,
    const char* function
);

void
_ssh_set_error_oom(
    void* error,
    const char* function
);

static
void
bcrypt_hash(
    uint8_t* sha2pass,
    uint8_t* sha2salt,
    uint8_t* out
);

int
bcrypt_pbkdf(
    const char* pass,
    size_t passlen,
    const uint8_t* salt,
    size_t saltlen,
    uint8_t* key,
    size_t keylen,
    unsigned int rounds
);

void
blf_cbc_decrypt(
    blf_ctx* c,
    uint8_t* iva,
    uint8_t* data,
    uint32_t len
);

void
blf_cbc_encrypt(
    blf_ctx* c,
    uint8_t* iv,
    uint8_t* data,
    uint32_t len
);

void
blf_dec(
    blf_ctx* c,
    uint32_t* data,
    uint16_t blocks
);

void
blf_ecb_decrypt(
    blf_ctx* c,
    uint8_t* data,
    uint32_t len
);

void
blf_ecb_encrypt(
    blf_ctx* c,
    uint8_t* data,
    uint32_t len
);

void
blf_enc(
    blf_ctx* c,
    uint32_t* data,
    uint16_t blocks
);

void
blf_key(
    blf_ctx* c,
    const uint8_t* k,
    uint16_t len
);

void
Blowfish_decipher(
    blf_ctx* c,
    uint32_t* xl,
    uint32_t* xr
);

void
Blowfish_encipher(
    blf_ctx* c,
    uint32_t* xl,
    uint32_t* xr
);

void
Blowfish_expand0state(
    blf_ctx* c,
    const uint8_t* key,
    uint16_t keybytes
);

void
Blowfish_expandstate(
    blf_ctx* c,
    const uint8_t* data,
    uint16_t databytes,
    const uint8_t* key,
    uint16_t keybytes
);

void
Blowfish_initstate(blf_ctx* c);

uint32_t
Blowfish_stream2word(
    const uint8_t* data,
    uint16_t databytes,
    uint16_t* current
);

static
void
add(
    unsigned int out[32],
    const unsigned int a[32],
    const unsigned int b[32]
);

static
void
c_select(
    unsigned int p[64],
    unsigned int q[64],
    const unsigned int r[64],
    const unsigned int s[64],
    unsigned int b
);

int
crypto_scalarmult(
    unsigned char* q,
    const unsigned char* n,
    const unsigned char* p
);

int
crypto_scalarmult_base(
    unsigned char* q,
    const unsigned char* n
);

static
void
freeze(unsigned int a[32]);

static
void
mainloop(
    unsigned int work[64],
    const unsigned char e[32]
);

static
void
mult(
    unsigned int out[32],
    const unsigned int a[32],
    const unsigned int b[32]
);

static
void
mult121665(
    unsigned int out[32],
    const unsigned int a[32]
);

static
void
recip(
    unsigned int out[32],
    const unsigned int z[32]
);

static
void
square(
    unsigned int out[32],
    const unsigned int a[32]
);

static
void
squeeze(unsigned int a[32]);

static
void
sub(
    unsigned int out[32],
    const unsigned int a[32],
    const unsigned int b[32]
);

int
crypto_sign_ed25519(
    unsigned char* sm,
    unsigned long long* smlen,
    const unsigned char* m,
    unsigned long long mlen,
    const unsigned char* sk
);

int
crypto_sign_ed25519_keypair(
    unsigned char* pk,
    unsigned char* sk
);

int
crypto_sign_ed25519_open(
    unsigned char* m,
    unsigned long long* mlen,
    const unsigned char* sm,
    unsigned long long smlen,
    const unsigned char* pk
);

static
int
crypto_verify_32(
    const unsigned char* x,
    const unsigned char* y
);

static
void
get_hram(
    unsigned char* hram,
    const unsigned char* sm,
    const unsigned char* pk,
    unsigned char* playground,
    unsigned long long smlen
);

static
uint32_t
equal(
    uint32_t a,
    uint32_t b
);

void
fe25519_add(
    fe25519* r,
    const fe25519* x,
    const fe25519* y
);

void
fe25519_cmov(
    fe25519* r,
    const fe25519* x,
    unsigned char b
);

void
fe25519_freeze(fe25519* r);

unsigned char
fe25519_getparity(const fe25519* x);

void
fe25519_invert(
    fe25519* r,
    const fe25519* x
);

int
fe25519_iseq_vartime(
    const fe25519* x,
    const fe25519* y
);

int
fe25519_iszero(const fe25519* x);

void
fe25519_mul(
    fe25519* r,
    const fe25519* x,
    const fe25519* y
);

void
fe25519_neg(
    fe25519* r,
    const fe25519* x
);

void
fe25519_pack(
    unsigned char r[32],
    const fe25519* x
);

void
fe25519_pow2523(
    fe25519* r,
    const fe25519* x
);

void
fe25519_setone(fe25519* r);

void
fe25519_setzero(fe25519* r);

void
fe25519_square(
    fe25519* r,
    const fe25519* x
);

void
fe25519_sub(
    fe25519* r,
    const fe25519* x,
    const fe25519* y
);

void
fe25519_unpack(
    fe25519* r,
    const unsigned char x[32]
);

static
uint32_t
ge(
    uint32_t a,
    uint32_t b
);

static
void
reduce_add_sub(fe25519* r);

static
void
reduce_mul(fe25519* r);

static
uint32_t
times19(uint32_t a);

static
uint32_t
times38(uint32_t a);

static
void
add_p1p1(
    ge25519_p1p1* r,
    const ge25519* p,
    const ge25519* q
);

static
void
choose_t(
    ge25519_aff* t,
    unsigned long long pos,
    signed char b
);

static
void
cmov_aff(
    ge25519_aff* r,
    const ge25519_aff* p,
    unsigned char b
);

static
void
dbl_p1p1(
    ge25519_p1p1* r,
    const ge25519_p2* p
);

static
unsigned char
equal(
    signed char b,
    signed char c
);

void
ge25519_double_scalarmult_vartime(
    ge25519* r,
    const ge25519* p1,
    const sc25519* s1,
    const ge25519* p2,
    const sc25519* s2
);

int
ge25519_isneutral_vartime(const ge25519* p);

static
void
ge25519_mixadd2(
    ge25519* r,
    const ge25519_aff* q
);

void
ge25519_pack(
    unsigned char r[32],
    const ge25519* p
);

void
ge25519_scalarmult_base(
    ge25519* r,
    const sc25519* s
);

int
ge25519_unpackneg_vartime(
    ge25519* r,
    const unsigned char p[32]
);

static
unsigned char
negative(signed char b);

static
void
p1p1_to_p2(
    ge25519_p2* r,
    const ge25519_p1p1* p
);

static
void
p1p1_to_p3(
    ge25519* r,
    const ge25519_p1p1* p
);

static
void
setneutral(ge25519* r);

static
void
barrett_reduce(
    sc25519* r,
    const uint32_t x[64]
);

static
uint32_t
lt(
    uint32_t a,
    uint32_t b
);

static
void
reduce_add_sub(sc25519* r);

void
sc25519_2interleave2(
    unsigned char r[127],
    const sc25519* s1,
    const sc25519* s2
);

void
sc25519_add(
    sc25519* r,
    const sc25519* x,
    const sc25519* y
);

void
sc25519_from32bytes(
    sc25519* r,
    const unsigned char x[32]
);

void
sc25519_from64bytes(
    sc25519* r,
    const unsigned char x[64]
);

void
sc25519_from_shortsc(
    sc25519* r,
    const shortsc25519* x
);

int
sc25519_isshort_vartime(const sc25519* x);

int
sc25519_iszero_vartime(const sc25519* x);

int
sc25519_lt_vartime(
    const sc25519* x,
    const sc25519* y
);

void
sc25519_mul(
    sc25519* r,
    const sc25519* x,
    const sc25519* y
);

void
sc25519_mul_shortsc(
    sc25519* r,
    const sc25519* x,
    const shortsc25519* y
);

void
sc25519_sub_nored(
    sc25519* r,
    const sc25519* x,
    const sc25519* y
);

void
sc25519_to32bytes(
    unsigned char r[32],
    const sc25519* x
);

void
sc25519_window3(
    signed char r[85],
    const sc25519* s
);

void
sc25519_window5(
    signed char r[51],
    const sc25519* s
);

void
shortsc25519_from16bytes(
    shortsc25519* r,
    const unsigned char x[16]
);

static
int
ssh_gets(
    const char* prompt,
    char* buf,
    size_t len,
    int verify
);

int
ssh_gssapi_auth_mic(ssh_session session);

static
ssh_buffer
ssh_gssapi_build_mic(ssh_session session);

static
void
ssh_gssapi_free(ssh_session session);

int
ssh_gssapi_handle_userauth(
    ssh_session session,
    const char* user,
    uint32_t n_oid,
    ssh_string* oids
);

static
int
ssh_gssapi_init(ssh_session session);

static
void
ssh_gssapi_log_error(
    int verb,
    const char* msg,
    int maj_stat,
    int min_stat
);

static
int
ssh_gssapi_match(
    ssh_session session,
    gss_OID_set* valid_oids
);

static
char*
ssh_gssapi_name_to_char(gss_name_t name);

static
gss_OID
ssh_gssapi_oid_from_string(ssh_string oid_s);

static
int
ssh_gssapi_send_auth_mic(
    ssh_session session,
    ssh_string* oid_set,
    int n_oid
);

static
int
ssh_gssapi_send_mic(ssh_session session);

static
int
ssh_gssapi_send_response(
    ssh_session session,
    ssh_string oid
);

void
ssh_gssapi_set_creds(
    ssh_session session,
    const ssh_gssapi_creds creds
);

SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_mic);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response);
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client);

int
compress_buffer(
    ssh_session session,
    ssh_buffer buf
);

int
decompress_buffer(
    ssh_session session,
    ssh_buffer buf,
    size_t maxlen
);

static
ssh_buffer
gzip_compress(
    ssh_session session,
    ssh_buffer source,
    int level
);

static
ssh_buffer
gzip_decompress(
    ssh_session session,
    ssh_buffer source,
    size_t maxlen
);

static
z_stream*
initcompress(
    ssh_session session,
    int level
);

static
z_stream*
initdecompress(ssh_session session);

static
int
cmp_first_kex_algo(
    const char* client_str,
    const char* server_str
);

int
set_client_kex(ssh_session session);

char**
space_tokenize(const char* chain);

static
char*
ssh_client_select_hostkeys(ssh_session session);

char*
ssh_find_matching(
    const char* available_d,
    const char* preferred_d
);

const char*
ssh_kex_get_description(uint32_t algo);

const char*
ssh_kex_get_supported_method(uint32_t algo);

int
ssh_kex_select_methods(ssh_session session);

void
ssh_list_kex(struct ssh_kex_struct* kex);

SSH_PACKET_CALLBACK(ssh_packet_kexinit);

int
ssh_send_kex(
    ssh_session session,
    int server_kex
);

static
char**
tokenize(const char* chain);

int
verify_existing_algo(
    int algo,
    const char* name
);

static
int
build_session_id1(
    ssh_session session,
    ssh_string servern,
    ssh_string hostn
);

static
ssh_string
encrypt_session_key(
    ssh_session session,
    ssh_public_key srvkey,
    ssh_public_key hostkey,
    int slen,
    int hlen
);

static
ssh_string
make_rsa1_string(
    ssh_string e,
    ssh_string n
);

static
int
modulus_smaller(
    ssh_public_key k1,
    ssh_public_key k2
);

static
ssh_string
ssh_encrypt_rsa1(
    ssh_session session,
    ssh_string data,
    ssh_public_key key
);

int
ssh_get_kex1(ssh_session session);

SSH_PACKET_CALLBACK(ssh_packet_publickey1);

static
int
alldigits(const char* s);

static
int
check_public_key(
    ssh_session session,
    char** tokens
);

static
int
match_hashed_host(
    const char* host,
    const char* sourcehash
);

static
char**
ssh_get_knownhost_line(
    FILE** file,
    const char* filename,
    const char** found_type
);

char**
ssh_knownhosts_algorithms(ssh_session session);

static
void
tokens_free(char** tokens);

void
buffer_free(ssh_buffer buffer);

void*
buffer_get(ssh_buffer buffer);

uint32_t
buffer_get_len(ssh_buffer buffer);

ssh_buffer
buffer_new(void);

ssh_channel
channel_accept_x11(
    ssh_channel channel,
    int timeout_ms
);

int
channel_change_pty_size(
    ssh_channel channel,
    int cols,
    int rows
);

int
channel_close(ssh_channel channel);

ssh_channel
channel_forward_accept(
    ssh_session session,
    int timeout_ms
);

int
channel_forward_cancel(
    ssh_session session,
    const char* address,
    int port
);

int
channel_forward_listen(
    ssh_session session,
    const char* address,
    int port,
    int* bound_port
);

void
channel_free(ssh_channel channel);

int
channel_get_exit_status(ssh_channel channel);

ssh_session
channel_get_session(ssh_channel channel);

int
channel_is_closed(ssh_channel channel);

int
channel_is_eof(ssh_channel channel);

int
channel_is_open(ssh_channel channel);

ssh_channel
channel_new(ssh_session session);

int
channel_open_forward(
    ssh_channel channel,
    const char* remotehost,
    int remoteport,
    const char* sourcehost,
    int localport
);

int
channel_open_session(ssh_channel channel);

int
channel_poll(
    ssh_channel channel,
    int is_stderr
);

int
channel_read(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr
);

int
channel_read_nonblocking(
    ssh_channel channel,
    void* dest,
    uint32_t count,
    int is_stderr
);

int
channel_request_env(
    ssh_channel channel,
    const char* name,
    const char* value
);

int
channel_request_exec(
    ssh_channel channel,
    const char* cmd
);

int
channel_request_pty(ssh_channel channel);

int
channel_request_pty_size(
    ssh_channel channel,
    const char* term,
    int cols,
    int rows
);

int
channel_request_send_signal(
    ssh_channel channel,
    const char* signum
);

int
channel_request_sftp(ssh_channel channel);

int
channel_request_shell(ssh_channel channel);

int
channel_request_subsystem(
    ssh_channel channel,
    const char* subsystem
);

int
channel_request_x11(
    ssh_channel channel,
    int single_connection,
    const char* protocol,
    const char* cookie,
    int screen_number
);

int
channel_select(
    ssh_channel* readchans,
    ssh_channel* writechans,
    ssh_channel* exceptchans,
    struct timeval* timeout
);

int
channel_send_eof(ssh_channel channel);

void
channel_set_blocking(
    ssh_channel channel,
    int blocking
);

int
channel_write(
    ssh_channel channel,
    const void* data,
    uint32_t len
);

int
channel_write_stderr(
    ssh_channel channel,
    const void* data,
    uint32_t len
);

void
privatekey_free(ssh_private_key prv);

ssh_private_key
privatekey_from_file(
    ssh_session session,
    const char* filename,
    int type,
    const char* passphrase
);

void
publickey_free(ssh_public_key key);

ssh_string
publickey_from_file(
    ssh_session session,
    const char* filename,
    int* type
);

ssh_public_key
publickey_from_privatekey(ssh_private_key prv);

ssh_public_key
publickey_from_string(
    ssh_session session,
    ssh_string pubkey_s
);

ssh_string
publickey_to_string(ssh_public_key pubkey);

int
ssh_accept(ssh_session session);

int
ssh_auth_list(ssh_session session);

ssh_string
ssh_get_pubkey(ssh_session session);

ssh_message
ssh_message_retrieve(
    ssh_session session,
    uint32_t packettype
);

enum ssh_keytypes_e
ssh_privatekey_type(ssh_private_key privatekey);

int
ssh_publickey_to_file(
    ssh_session session,
    const char* file,
    ssh_string pubkey,
    int type
);

int
ssh_try_publickey_from_file(
    ssh_session session,
    const char* keyfile,
    ssh_string* publickey,
    int* type
);

int
ssh_type_from_name(const char* name);

const char*
ssh_type_to_char(int type);

int
ssh_userauth_autopubkey(
    ssh_session session,
    const char* passphrase
);

int
ssh_userauth_offer_pubkey(
    ssh_session session,
    const char* username,
    int type,
    ssh_string publickey
);

int
ssh_userauth_privatekey_file(
    ssh_session session,
    const char* username,
    const char* filename,
    const char* passphrase
);

int
ssh_userauth_pubkey(
    ssh_session session,
    const char* username,
    ssh_string publickey,
    ssh_private_key privatekey
);

void
string_burn(ssh_string str);

ssh_string
string_copy(ssh_string str);

void*
string_data(ssh_string str);

int
string_fill(
    ssh_string str,
    const void* data,
    size_t len
);

void
string_free(ssh_string str);

ssh_string
string_from_char(const char* what);

size_t
string_len(ssh_string str);

ssh_string
string_new(size_t size);

char*
string_to_char(ssh_string str);

void
_ssh_log(
    int verbosity,
    const char* function,
    const char* format,
    ...
);

static
int
current_timestring(
    int hires,
    char* buf,
    size_t len
);

void
ssh_log(
    ssh_session session,
    int verbosity,
    const char* format,
    ...
);

void
ssh_log_common(
    struct ssh_common_struct* common,
    int verbosity,
    const char* function,
    const char* format,
    ...
);

void
ssh_log_function(
    int verbosity,
    const char* function,
    const char* buffer
);

static
void
ssh_log_stderr(
    int verbosity,
    const char* function,
    const char* buffer
);

int
match_hostname(
    const char* host,
    const char* pattern,
    unsigned int len
);

static
int
match_pattern(
    const char* s,
    const char* pattern
);

static
int
match_pattern_list(
    const char* string,
    const char* pattern,
    unsigned int len,
    int dolower
);

static
int
ssh_execute_client_request(
    ssh_session session,
    ssh_message msg
);

static
int
ssh_execute_message_callback(
    ssh_session session,
    ssh_message msg
);

static
int
ssh_execute_server_callbacks(
    ssh_session session,
    ssh_message msg
);

static
int
ssh_execute_server_request(
    ssh_session session,
    ssh_message msg
);

ssh_channel
ssh_message_channel_request_open_reply_accept(ssh_message msg);

int
ssh_message_channel_request_open_reply_accept_channel(
    ssh_message msg,
    ssh_channel chan
);

int
ssh_message_channel_request_reply_success(ssh_message msg);

int
ssh_message_handle_channel_request(
    ssh_session session,
    ssh_channel channel,
    ssh_buffer packet,
    const char* request,
    uint8_t want_reply
);

static
ssh_message
ssh_message_new(ssh_session session);

ssh_message
ssh_message_pop_head(ssh_session session);

void
ssh_message_queue(
    ssh_session session,
    ssh_message message
);

static
int
ssh_message_termination(void* s);

static
ssh_buffer
ssh_msg_userauth_build_digest(
    ssh_session session,
    ssh_message msg,
    const char* service
);

SSH_PACKET_CALLBACK(ssh_packet_service_request);
SSH_PACKET_CALLBACK(ssh_packet_userauth_request);
SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response);
SSH_PACKET_CALLBACK(ssh_packet_channel_open);
SSH_PACKET_CALLBACK(ssh_packet_global_request);

const void*
_ssh_list_pop_head(struct ssh_list* list);

int
ssh_analyze_banner(
    ssh_session session,
    int server,
    int* ssh1,
    int* ssh2
);

int
ssh_file_readaccess_ok(const char* file);

char*
ssh_get_local_username(void);

char*
ssh_get_user_home_dir(void);

char*
ssh_hostport(
    const char* host,
    int port
);

int
ssh_is_ipaddr(const char* str);

int
ssh_is_ipaddr_v4(const char* str);

static
struct ssh_iterator*
ssh_iterator_new(const void* data);

int
ssh_list_append(
    struct ssh_list* list,
    const void* data
);

struct ssh_iterator*
ssh_list_find(
    const struct ssh_list* list,
    void* value
);

void
ssh_list_free(struct ssh_list* list);

struct ssh_iterator*
ssh_list_get_iterator(const struct ssh_list* list);

struct ssh_list*
ssh_list_new(void);

int
ssh_list_prepend(
    struct ssh_list* list,
    const void* data
);

void
ssh_list_remove(
    struct ssh_list* list,
    struct ssh_iterator* iterator
);

char*
ssh_lowercase(const char* str);

int
ssh_make_milliseconds(
    long sec,
    long usec
);

int
ssh_match_group(
    const char* group,
    const char* object
);

char*
ssh_path_expand_escape(
    ssh_session session,
    const char* s
);

int
ssh_timeout_elapsed(
    struct ssh_timestamp* ts,
    int timeout
);

static
int
ssh_timestamp_difference(
    struct ssh_timestamp* old,
    struct ssh_timestamp* new
);

void
ssh_timestamp_init(struct ssh_timestamp* ts);

static
int
ssh_bind_set_key(
    ssh_bind sshbind,
    char** key_loc,
    const void* value
);

int
ssh_options_apply(ssh_session session);

int
ssh_options_set_algo(
    ssh_session session,
    int algo,
    const char* list
);

int
packet_send(ssh_session session);

static
int
packet_send2(ssh_session session);

SSH_PACKET_CALLBACK(ssh_packet_unimplemented);

int
ssh_packet_parse_type(ssh_session session);

void
ssh_packet_process(
    ssh_session session,
    uint8_t type
);

void
ssh_packet_register_socket_callback(
    ssh_session session,
    ssh_socket s
);

int
ssh_packet_send_unimplemented(
    ssh_session session,
    uint32_t seqnum
);

void
ssh_packet_set_callbacks(
    ssh_session session,
    ssh_packet_callbacks callbacks
);

void
ssh_packet_set_default_callbacks(ssh_session session);

int
ssh_packet_socket_callback(
    const void* data,
    size_t receivedlen,
    void* user
);

static
int
ssh_packet_write(ssh_session session);

SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback);
SSH_PACKET_CALLBACK(ssh_packet_ignore_callback);
SSH_PACKET_CALLBACK(ssh_packet_dh_reply);
SSH_PACKET_CALLBACK(ssh_packet_newkeys);
SSH_PACKET_CALLBACK(ssh_packet_service_accept);

int
packet_decrypt(
    ssh_session session,
    void* data,
    uint32_t len
);

uint32_t
packet_decrypt_len(
    ssh_session session,
    char* crypted
);

unsigned char*
packet_encrypt(
    ssh_session session,
    void* data,
    uint32_t len
);

int
packet_hmac_verify(
    ssh_session session,
    ssh_buffer buffer,
    unsigned char* mac,
    enum ssh_hmac_e type
);

static
int
ssh_pcap_context_connect(ssh_pcap_context ctx);

void
ssh_pcap_context_free(ssh_pcap_context ctx);

ssh_pcap_context
ssh_pcap_context_new(ssh_session session);

void
ssh_pcap_context_set_file(
    ssh_pcap_context ctx,
    ssh_pcap_file pcap
);

int
ssh_pcap_context_write(
    ssh_pcap_context ctx,
    enum ssh_pcap_direction direction,
    void* data,
    uint32_t len,
    uint32_t origlen
);

int
ssh_pcap_file_close(ssh_pcap_file pcap);

void
ssh_pcap_file_free(ssh_pcap_file pcap);

ssh_pcap_file
ssh_pcap_file_new(void);

int
ssh_pcap_file_open(
    ssh_pcap_file pcap,
    const char* filename
);

static
int
ssh_pcap_file_write(
    ssh_pcap_file pcap,
    ssh_buffer packet
);

int
ssh_pcap_file_write_packet(
    ssh_pcap_file pcap,
    ssh_buffer packet,
    uint32_t original_len
);

int
ssh_set_pcap_file(
    ssh_session session,
    ssh_pcap_file pcap
);

void
_ssh_pki_log(
    const char* function,
    const char* format,
    ...
);

static
int
pki_import_pubkey_buffer(
    ssh_buffer buffer,
    enum ssh_keytypes_e type,
    ssh_key* pkey
);

enum ssh_keytypes_e
pki_privatekey_type_from_string(const char* privkey);

ssh_key
ssh_key_dup(const ssh_key key);

ssh_private_key
ssh_pki_convert_key_to_privatekey(const ssh_key key);

ssh_public_key
ssh_pki_convert_key_to_publickey(const ssh_key key);

ssh_string
ssh_pki_do_sign(
    ssh_session session,
    ssh_buffer sigbuf,
    const ssh_key privkey
);

ssh_string
ssh_pki_do_sign_agent(
    ssh_session session,
    struct ssh_buffer_struct* buf,
    const ssh_key pubkey
);

int
ssh_pki_export_pubkey_blob(
    const ssh_key key,
    ssh_string* pblob
);

int
ssh_pki_export_pubkey_file(
    const ssh_key key,
    const char* filename
);

int
ssh_pki_export_pubkey_rsa1(
    const ssh_key key,
    const char* host,
    char* rsa1,
    size_t rsa1_len
);

int
ssh_pki_export_signature_blob(
    const ssh_signature sig,
    ssh_string* sig_blob
);

int
ssh_pki_import_pubkey_blob(
    const ssh_string key_blob,
    ssh_key* pkey
);

int
ssh_pki_import_signature_blob(
    const ssh_string sig_blob,
    const ssh_key pubkey,
    ssh_signature* psig
);

int
ssh_pki_signature_verify_blob(
    ssh_session session,
    ssh_string sig_blob,
    const ssh_key key,
    unsigned char* digest,
    size_t dlen
);

void
ssh_signature_free(ssh_signature sig);

ssh_signature
ssh_signature_new(void);

ssh_string
ssh_srv_pki_do_sign_sessionid(
    ssh_session session,
    const ssh_key privkey
);

static
int
pki_openssh_import_privkey_blob(
    ssh_buffer key_blob_buffer,
    ssh_key* pkey
);

static
int
pki_private_key_decrypt(
    ssh_string blob,
    const char* passphrase,
    const char* ciphername,
    const char* kdfname,
    ssh_string kdfoptions,
    ssh_auth_callback auth_fn,
    void* auth_data
);

ssh_key
ssh_pki_openssh_privkey_import(
    const char* text_key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

static
int
pki_openssh_export_privkey_blob(
    const ssh_key privkey,
    ssh_buffer buffer
);

static
int
pki_private_key_encrypt(
    ssh_buffer privkey_buffer,
    const char* passphrase,
    const char* ciphername,
    const char* kdfname,
    ssh_auth_callback auth_fn,
    void* auth_data,
    uint32_t rounds,
    ssh_string salt
);

ssh_string
ssh_pki_openssh_privkey_export(
    const ssh_key privkey,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

static
ssh_string
_RSA_do_sign(
    const unsigned char* digest,
    int dlen,
    RSA* privkey
);

static
int
pem_get_password(
    char* buf,
    int size,
    int rwflag,
    void* userdata
);

ssh_signature
pki_do_sign(
    const ssh_key privkey,
    const unsigned char* hash,
    size_t hlen
);

ssh_signature
pki_do_sign_sessionid(
    const ssh_key key,
    const unsigned char* hash,
    size_t hlen
);

static
ssh_string
pki_dsa_signature_to_blob(const ssh_signature sig);

int
pki_export_pubkey_rsa1(
    const ssh_key key,
    const char* host,
    char* rsa1,
    size_t rsa1_len
);

int
pki_key_compare(
    const ssh_key k1,
    const ssh_key k2,
    enum ssh_keycmp_e what
);

ssh_key
pki_key_dup(
    const ssh_key key,
    int demote
);

int
pki_key_generate_dss(
    ssh_key key,
    int parameter
);

int
pki_key_generate_rsa(
    ssh_key key,
    int parameter
);

ssh_key
pki_private_key_from_base64(
    const char* b64_key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

ssh_string
pki_private_key_to_pem(
    const ssh_key key,
    const char* passphrase,
    ssh_auth_callback auth_fn,
    void* auth_data
);

int
pki_pubkey_build_dss(
    ssh_key key,
    ssh_string p,
    ssh_string q,
    ssh_string g,
    ssh_string pubkey
);

int
pki_pubkey_build_rsa(
    ssh_key key,
    ssh_string e,
    ssh_string n
);

ssh_string
pki_publickey_to_blob(const ssh_key key);

ssh_signature
pki_signature_from_blob(
    const ssh_key pubkey,
    const ssh_string sig_blob,
    enum ssh_keytypes_e type
);

static
ssh_signature
pki_signature_from_rsa_blob(
    const ssh_key pubkey,
    const ssh_string sig_blob,
    ssh_signature sig
);

ssh_string
pki_signature_to_blob(const ssh_signature sig);

int
pki_signature_verify(
    ssh_session session,
    const ssh_signature sig,
    const ssh_key key,
    const unsigned char* hash,
    size_t hlen
);

int
pki_ed25519_key_cmp(
    const ssh_key k1,
    const ssh_key k2,
    enum ssh_keycmp_e what
);

int
pki_ed25519_key_dup(
    ssh_key new,
    const ssh_key key
);

int
pki_ed25519_public_key_to_blob(
    ssh_buffer buffer,
    ssh_key key
);

int
pki_ed25519_sig_from_blob(
    ssh_signature sig,
    ssh_string sig_blob
);

ssh_string
pki_ed25519_sig_to_blob(ssh_signature sig);

int
pki_ed25519_sign(
    const ssh_key privkey,
    ssh_signature sig,
    const unsigned char* hash,
    size_t hlen
);

int
pki_ed25519_verify(
    const ssh_key pubkey,
    ssh_signature sig,
    const unsigned char* hash,
    size_t hlen
);

int
pki_key_generate_ed25519(ssh_key key);

static
int
bsd_poll(
    ssh_pollfd_t* fds,
    nfds_t nfds,
    int timeout
);

static
int
ssh_event_fd_wrapper_callback(
    ssh_poll_handle p,
    socket_t fd,
    int revents,
    void* userdata
);

int
ssh_poll(
    ssh_pollfd_t* fds,
    nfds_t nfds,
    int timeout
);

void
ssh_poll_cleanup(void);

int
ssh_poll_ctx_add_socket(
    ssh_poll_ctx ctx,
    ssh_socket s
);

static
int
ssh_poll_ctx_resize(
    ssh_poll_ctx ctx,
    size_t new_size
);

ssh_poll_ctx
ssh_poll_get_default_ctx(ssh_session session);

void
ssh_poll_init(void);

int
ssh_scp_response(
    ssh_scp scp,
    char** response
);

static
int
callback_receive_banner(
    const void* data,
    size_t len,
    void* user
);

static
int
dh_handshake_server(ssh_session session);

static
int
server_set_kex(ssh_session session);

int
ssh_auth_reply_default(
    ssh_session session,
    int partial
);

int
ssh_auth_reply_success(
    ssh_session session,
    int partial
);

LIBSSH_API int
ssh_execute_message_callbacks(ssh_session session);

int
ssh_get_key_params(
    ssh_session session,
    ssh_key* privkey
);

LIBSSH_API int
ssh_message_auth_interactive_request(
    ssh_message msg,
    const char* name,
    const char* instruction,
    unsigned int num_prompts,
    const char** prompts,
    char* echo
);

LIBSSH_API int
ssh_message_auth_kbdint_is_response(ssh_message msg);

ssh_public_key
ssh_message_auth_publickey(ssh_message msg);

LIBSSH_API enum ssh_publickey_state_e
ssh_message_auth_publickey_state(ssh_message msg);

LIBSSH_API int
ssh_message_auth_reply_pk_ok(
    ssh_message msg,
    ssh_string algo,
    ssh_string pubkey
);

LIBSSH_API int
ssh_message_auth_reply_pk_ok_simple(ssh_message msg);

LIBSSH_API int
ssh_message_auth_reply_success(
    ssh_message msg,
    int partial
);

LIBSSH_API int
ssh_message_auth_set_methods(
    ssh_message msg,
    int methods
);

LIBSSH_API ssh_channel
ssh_message_channel_request_channel(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_command(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_env_name(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_env_value(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_open_destination(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_open_destination_port(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_open_originator(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_open_originator_port(ssh_message msg);

static
int
ssh_message_channel_request_open_reply_default(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_pty_height(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_pty_pxheight(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_pty_pxwidth(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_pty_term(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_pty_width(ssh_message msg);

static
int
ssh_message_channel_request_reply_default(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_subsystem(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_x11_auth_cookie(ssh_message msg);

LIBSSH_API const char*
ssh_message_channel_request_x11_auth_protocol(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_x11_screen_number(ssh_message msg);

LIBSSH_API int
ssh_message_channel_request_x11_single_connection(ssh_message msg);

LIBSSH_API const char*
ssh_message_global_request_address(ssh_message msg);

LIBSSH_API int
ssh_message_global_request_port(ssh_message msg);

static
int
ssh_message_global_request_reply_default(ssh_message msg);

LIBSSH_API int
ssh_message_global_request_reply_success(
    ssh_message msg,
    uint16_t bound_port
);

LIBSSH_API int
ssh_message_service_reply_success(ssh_message msg);

static
int
ssh_message_service_request_reply_default(ssh_message msg);

LIBSSH_API const char*
ssh_message_service_service(ssh_message msg);

SSH_PACKET_CALLBACK(ssh_packet_kexdh_init);

LIBSSH_API int
ssh_send_keepalive(ssh_session session);

static
void
ssh_server_connection_callback(ssh_session session);

static
int
ssh_server_kex_termination(void* s);

static
int
ssh_server_kexdh_init(
    ssh_session session,
    ssh_buffer packet
);

static
int
ssh_flush_termination(void* c);

int
ssh_handle_packets(
    ssh_session session,
    int timeout
);

int
ssh_handle_packets_termination(
    ssh_session session,
    int timeout,
    ssh_termination_function fct,
    void* user
);

void
ssh_socket_exception_callback(
    int code,
    int errno_code,
    void* user
);

int
buffer_add_attributes(
    ssh_buffer buffer,
    sftp_attributes attr
);

static
sftp_file
parse_handle_msg(sftp_message msg);

static
sftp_status_message
parse_status_msg(sftp_message msg);

static
void
request_queue_free(sftp_request_queue queue);

static
sftp_request_queue
request_queue_new(sftp_message msg);

static
sftp_message
sftp_dequeue(
    sftp_session sftp,
    uint32_t id
);

static
int
sftp_enqueue(
    sftp_session session,
    sftp_message msg
);

static
void
sftp_ext_free(sftp_ext ext);

static
sftp_ext
sftp_ext_new(void);

static
sftp_message
sftp_get_message(sftp_packet packet);

static
uint32_t
sftp_get_new_id(sftp_session session);

static
int
sftp_handle_close(
    sftp_session sftp,
    ssh_string handle
);

static
void
sftp_message_free(sftp_message msg);

static
sftp_message
sftp_message_new(sftp_session sftp);

void
sftp_packet_free(sftp_packet packet);

sftp_packet
sftp_packet_read(sftp_session sftp);

int
sftp_packet_write(
    sftp_session sftp,
    uint8_t type,
    ssh_buffer payload
);

sftp_attributes
sftp_parse_attr(
    sftp_session session,
    ssh_buffer buf,
    int expectname
);

static
sftp_attributes
sftp_parse_attr_3(
    sftp_session sftp,
    ssh_buffer buf,
    int expectname
);

static
sftp_attributes
sftp_parse_attr_4(
    sftp_session sftp,
    ssh_buffer buf,
    int expectnames
);

static
char*
sftp_parse_longname(
    const char* longname,
    enum sftp_longname_field_e longname_field
);

static
sftp_statvfs_t
sftp_parse_statvfs(
    sftp_session sftp,
    ssh_buffer buf
);

static
int
sftp_read_and_dispatch(sftp_session sftp);

static
void
sftp_set_error(
    sftp_session sftp,
    int errnum
);

static
sftp_attributes
sftp_xstat(
    sftp_session sftp,
    const char* path,
    int param
);

static
void
status_msg_free(sftp_status_message status);

void
sftp_client_message_free(sftp_client_message msg);

const char*
sftp_client_message_get_data(sftp_client_message msg);

const char*
sftp_client_message_get_filename(sftp_client_message msg);

uint32_t
sftp_client_message_get_flags(sftp_client_message msg);

uint8_t
sftp_client_message_get_type(sftp_client_message msg);

void
sftp_client_message_set_filename(
    sftp_client_message msg,
    const char* newname
);

sftp_client_message
sftp_get_client_message(sftp_session sftp);

void*
sftp_handle(
    sftp_session sftp,
    ssh_string handle
);

ssh_string
sftp_handle_alloc(
    sftp_session sftp,
    void* info
);

void
sftp_handle_remove(
    sftp_session sftp,
    void* handle
);

int
sftp_reply_attr(
    sftp_client_message msg,
    sftp_attributes attr
);

int
sftp_reply_data(
    sftp_client_message msg,
    const void* data,
    int len
);

int
sftp_reply_handle(
    sftp_client_message msg,
    ssh_string handle
);

int
sftp_reply_name(
    sftp_client_message msg,
    const char* name,
    sftp_attributes attr
);

int
sftp_reply_names(sftp_client_message msg);

int
sftp_reply_names_add(
    sftp_client_message msg,
    const char* file,
    const char* longname,
    sftp_attributes attr
);

int
sftp_reply_status(
    sftp_client_message msg,
    uint32_t status,
    const char* message
);

int
sftp_send_client_message(
    sftp_session sftp,
    sftp_client_message msg
);

void
ssh_execute_command(
    const char* command,
    socket_t in,
    socket_t out
);

int
ssh_socket_buffered_write_bytes(ssh_socket s);

void
ssh_socket_cleanup(void);

void
ssh_socket_close(ssh_socket s);

int
ssh_socket_connect(
    ssh_socket s,
    const char* host,
    int port,
    const char* bind_addr
);

int
ssh_socket_connect_proxycommand(
    ssh_socket s,
    const char* command
);

int
ssh_socket_data_available(ssh_socket s);

int
ssh_socket_data_writable(ssh_socket s);

int
ssh_socket_fd_isset(
    ssh_socket s,
    fd_set* set
);

void
ssh_socket_fd_set(
    ssh_socket s,
    fd_set* set,
    socket_t* max_fd
);

void
ssh_socket_free(ssh_socket s);

socket_t
ssh_socket_get_fd_in(ssh_socket s);

int
ssh_socket_get_poll_flags(ssh_socket s);

ssh_poll_handle
ssh_socket_get_poll_handle_in(ssh_socket s);

ssh_poll_handle
ssh_socket_get_poll_handle_out(ssh_socket s);

int
ssh_socket_get_status(ssh_socket s);

int
ssh_socket_init(void);

int
ssh_socket_is_open(ssh_socket s);

ssh_socket
ssh_socket_new(ssh_session session);

int
ssh_socket_nonblocking_flush(ssh_socket s);

int
ssh_socket_pollcallback(
    struct ssh_poll_handle_struct* p,
    socket_t fd,
    int revents,
    void* v_s
);

void
ssh_socket_reset(ssh_socket s);

int
ssh_socket_set_blocking(socket_t fd);

void
ssh_socket_set_callbacks(
    ssh_socket s,
    ssh_socket_callbacks callbacks
);

void
ssh_socket_set_except(ssh_socket s);

void
ssh_socket_set_fd(
    ssh_socket s,
    socket_t fd
);

void
ssh_socket_set_fd_in(
    ssh_socket s,
    socket_t fd
);

void
ssh_socket_set_fd_out(
    ssh_socket s,
    socket_t fd
);

int
ssh_socket_set_nonblocking(socket_t fd);

void
ssh_socket_set_read_wontblock(ssh_socket s);

void
ssh_socket_set_write_wontblock(ssh_socket s);

static
int
ssh_socket_unbuffered_read(
    ssh_socket s,
    void* buffer,
    uint32_t len
);

static
int
ssh_socket_unbuffered_write(
    ssh_socket s,
    const void* buffer,
    uint32_t len
);

int
ssh_socket_unix(
    ssh_socket s,
    const char* path
);

int
ssh_socket_write(
    ssh_socket s,
    const void* buffer,
    int len
);

void
ssh_string_burn(struct ssh_string_struct* s);

struct ssh_string_struct*
ssh_string_copy(struct ssh_string_struct* s);

void*
ssh_string_data(struct ssh_string_struct* s);

int
ssh_string_fill(
    struct ssh_string_struct* s,
    const void* data,
    size_t len
);

void
ssh_string_free(struct ssh_string_struct* s);

const char*
ssh_string_get_char(struct ssh_string_struct* s);

size_t
ssh_string_len(struct ssh_string_struct* s);

char*
ssh_string_to_char(struct ssh_string_struct* s);

static
void
libcrypto_lock_callback(
    int mode,
    int i,
    const char* file,
    int line
);

static
void
libcrypto_thread_finalize(void);

static
int
libcrypto_thread_init(void);

void
ssh_threads_finalize(void);

const char*
ssh_threads_get_type(void);

int
ssh_threads_init(void);

static
unsigned long
threads_id_noop(void);

static
int
threads_noop(void** lock);

static
void
cipher_free(struct ssh_cipher_struct* cipher);

static
struct ssh_cipher_struct*
cipher_new(int offset);

int
crypt_set_algorithms(
    ssh_session session,
    enum ssh_des_e des_type
);

static
int
crypt_set_algorithms1(
    ssh_session session,
    enum ssh_des_e des_type
);

static
int
crypt_set_algorithms2(ssh_session session);

int
crypt_set_algorithms_server(ssh_session session);

void
crypto_free(struct ssh_crypto_struct* crypto);

struct ssh_crypto_struct*
crypto_new(void);

size_t
hmac_digest_len(enum ssh_hmac_e type);

void
ssh_cipher_clear(struct ssh_cipher_struct* cipher);

struct ssh_hmac_struct*
ssh_get_hmactab(void);

const char*
ssh_hmac_type_to_string(enum ssh_hmac_e hmac_type);

// macros

#define ABS(A)
#define ARRAY_SIZE(a)
#define BCRYPT_BLOCKS
#define BCRYPT_HASHSIZE
#define BITS(n)

#define BLFRND( \
    s, \
    p, \
    i, \
    j, \
    n \
)

#define BLF_MAXKEYLEN
#define BLF_MAXUTILIZED
#define BLF_N

#define BLOCK( \
    letter, \
    n \
)

#define BLOCKSIZE

#define BURN_BUFFER( \
    x, \
    size \
)

#define BURN_STRING(x)
#define CHANNEL_INITIAL_WINDOW
#define CHANNEL_MAX_PACKET
#define CLIENTBANNER1
#define CLIENTBANNER2
#define CLOCK
#define CLOSE_SOCKET(s)
#define CRYPTO_STRING
#define CURVE25519
#define CURVE25519_PRIVKEY_SIZE
#define CURVE25519_PUBKEY_SIZE
#define DIGEST_MAX_LEN
#define DLT_RAW
#define DSA_HEADER_BEGIN
#define DSA_HEADER_END
#define ECDH
#define ECDSA_HEADER_BEGIN
#define ECDSA_HEADER_END
#define ED25519_PK_LEN
#define ED25519_SIG_LEN
#define ED25519_SK_LEN
#define ERROR_BUFFERLEN
#define F(i)

#define F( \
    s, \
    x \
)

#define FIRST_CHANNEL
#define GCRYPT_STRING
#define GET_A(n)
#define GET_B(n)
#define GET_C(n)
#define HOSTKEYS
#define IPHDR_LEN
#define KBDINT_MAX_PROMPT
#define KEX_METHODS_SIZE
#define KEY_EXCHANGE
#define KNOWNHOSTS_MAXTYPES
#define LIBSFTP_VERSION
#define LIBSSH_API
#define LIBSSH_LEGACY_0_4
#define LIBSSH_MEM_PROTECTION
#define LIBSSH_THREAD
#define LIBSSH_VERSION
#define LIBSSH_VERSION_INT
#define LIBSSH_VERSION_MAJOR
#define LIBSSH_VERSION_MICRO
#define LIBSSH_VERSION_MINOR
#define MAX_BUF_SIZE
#define MAX_PACKET_LEN
#define MAX_PRIVKEY_SIZE
#define MAX_PUBKEY_SIZE
#define MD5_DIGEST_LEN

#define MIN( \
    a, \
    b \
)

#define NSS_BUFLEN_PASSWD
#define OPENSSH_AUTH_MAGIC
#define OPENSSH_HEADER_BEGIN
#define OPENSSH_HEADER_END
#define PCAP_MAGIC
#define PCAP_VERSION_MAJOR
#define PCAP_VERSION_MINOR
#define POLLERR
#define POLLHUP
#define POLLIN
#define POLLNVAL
#define POLLOUT
#define POLLPRI
#define POLLRDBAND
#define POLLRDNORM
#define POLLWRBAND
#define POLLWRNORM

#define PRINTF_ATTRIBUTE( \
    a, \
    b \
)

#define PRIdS
#define P_GROUP14_LEN
#define P_GROUP1_LEN
#define RSA_HEADER_BEGIN
#define RSA_HEADER_END
#define SAFE_FREE(x)
#define SERVERBANNER

#define SET_A( \
    n, \
    i \
)

#define SET_B( \
    n, \
    i \
)

#define SET_C( \
    n, \
    i \
)

#define SET_D( \
    n, \
    i \
)

#define SFTP_CLOSE
#define SFTP_FSETSTAT
#define SFTP_FSTAT
#define SFTP_HANDLES
#define SFTP_LSTAT
#define SFTP_MKDIR
#define SFTP_OPEN
#define SFTP_OPENDIR
#define SFTP_READ
#define SFTP_READDIR
#define SFTP_READLINK
#define SFTP_REALPATH
#define SFTP_REMOVE
#define SFTP_RENAME
#define SFTP_RMDIR
#define SFTP_SETSTAT
#define SFTP_STAT
#define SFTP_SYMLINK
#define SFTP_WRITE
#define SHA512_DIGEST_LENGTH
#define SOCKOPT_TYPE_ARG4
#define SSH2_AGENTC_ADD_IDENTITY
#define SSH2_AGENTC_ADD_ID_CONSTRAINED
#define SSH2_AGENTC_REMOVE_ALL_IDENTITIES
#define SSH2_AGENTC_REMOVE_IDENTITY
#define SSH2_AGENTC_REQUEST_IDENTITIES
#define SSH2_AGENTC_SIGN_REQUEST
#define SSH2_AGENT_FAILURE
#define SSH2_AGENT_IDENTITIES_ANSWER
#define SSH2_AGENT_SIGN_RESPONSE
#define SSH2_DISCONNECT_AUTH_CANCELLED_BY_USER
#define SSH2_DISCONNECT_BY_APPLICATION
#define SSH2_DISCONNECT_COMPRESSION_ERROR
#define SSH2_DISCONNECT_CONNECTION_LOST
#define SSH2_DISCONNECT_HOST_AUTHENTICATION_FAILED
#define SSH2_DISCONNECT_HOST_KEY_NOT_VERIFIABLE
#define SSH2_DISCONNECT_HOST_NOT_ALLOWED_TO_CONNECT
#define SSH2_DISCONNECT_ILLEGAL_USER_NAME
#define SSH2_DISCONNECT_KEY_EXCHANGE_FAILED
#define SSH2_DISCONNECT_MAC_ERROR
#define SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE
#define SSH2_DISCONNECT_PROTOCOL_ERROR
#define SSH2_DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED
#define SSH2_DISCONNECT_RESERVED
#define SSH2_DISCONNECT_SERVICE_NOT_AVAILABLE
#define SSH2_DISCONNECT_TOO_MANY_CONNECTIONS
#define SSH2_EXTENDED_DATA_STDERR
#define SSH2_MSG_CHANNEL_CLOSE
#define SSH2_MSG_CHANNEL_DATA
#define SSH2_MSG_CHANNEL_EOF
#define SSH2_MSG_CHANNEL_EXTENDED_DATA
#define SSH2_MSG_CHANNEL_FAILURE
#define SSH2_MSG_CHANNEL_OPEN
#define SSH2_MSG_CHANNEL_OPEN_CONFIRMATION
#define SSH2_MSG_CHANNEL_OPEN_FAILURE
#define SSH2_MSG_CHANNEL_REQUEST
#define SSH2_MSG_CHANNEL_SUCCESS
#define SSH2_MSG_CHANNEL_WINDOW_ADJUST
#define SSH2_MSG_DEBUG
#define SSH2_MSG_DISCONNECT
#define SSH2_MSG_ECMQV_INIT
#define SSH2_MSG_ECMQV_REPLY
#define SSH2_MSG_GLOBAL_REQUEST
#define SSH2_MSG_IGNORE
#define SSH2_MSG_KEXDH_INIT
#define SSH2_MSG_KEXDH_REPLY
#define SSH2_MSG_KEXINIT
#define SSH2_MSG_KEX_DH_GEX_GROUP
#define SSH2_MSG_KEX_DH_GEX_INIT
#define SSH2_MSG_KEX_DH_GEX_REPLY
#define SSH2_MSG_KEX_DH_GEX_REQUEST
#define SSH2_MSG_KEX_DH_GEX_REQUEST_OLD
#define SSH2_MSG_KEX_ECDH_INIT
#define SSH2_MSG_KEX_ECDH_REPLY
#define SSH2_MSG_NEWKEYS
#define SSH2_MSG_REQUEST_FAILURE
#define SSH2_MSG_REQUEST_SUCCESS
#define SSH2_MSG_SERVICE_ACCEPT
#define SSH2_MSG_SERVICE_REQUEST
#define SSH2_MSG_UNIMPLEMENTED
#define SSH2_MSG_USERAUTH_BANNER
#define SSH2_MSG_USERAUTH_FAILURE
#define SSH2_MSG_USERAUTH_GSSAPI_ERROR
#define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK
#define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE
#define SSH2_MSG_USERAUTH_GSSAPI_MIC
#define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE
#define SSH2_MSG_USERAUTH_GSSAPI_TOKEN
#define SSH2_MSG_USERAUTH_INFO_REQUEST
#define SSH2_MSG_USERAUTH_INFO_RESPONSE
#define SSH2_MSG_USERAUTH_PASSWD_CHANGEREQ
#define SSH2_MSG_USERAUTH_PK_OK
#define SSH2_MSG_USERAUTH_REQUEST
#define SSH2_MSG_USERAUTH_SUCCESS
#define SSH2_OPEN_ADMINISTRATIVELY_PROHIBITED
#define SSH2_OPEN_CONNECT_FAILED
#define SSH2_OPEN_RESOURCE_SHORTAGE
#define SSH2_OPEN_UNKNOWN_CHANNEL_TYPE
#define SSH_AGAIN
#define SSH_AGENTC_ADD_RSA_IDENTITY
#define SSH_AGENTC_ADD_RSA_ID_CONSTRAINED
#define SSH_AGENTC_ADD_SMARTCARD_KEY
#define SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED
#define SSH_AGENTC_LOCK
#define SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES
#define SSH_AGENTC_REMOVE_RSA_IDENTITY
#define SSH_AGENTC_REMOVE_SMARTCARD_KEY
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES
#define SSH_AGENTC_RSA_CHALLENGE
#define SSH_AGENTC_UNLOCK
#define SSH_AGENT_CONSTRAIN_CONFIRM
#define SSH_AGENT_CONSTRAIN_LIFETIME
#define SSH_AGENT_FAILURE
#define SSH_AGENT_OLD_SIGNATURE
#define SSH_AGENT_RSA_IDENTITIES_ANSWER
#define SSH_AGENT_RSA_RESPONSE
#define SSH_AGENT_SUCCESS
#define SSH_AUTH_KERBEROS
#define SSH_AUTH_METHOD_GSSAPI_MIC
#define SSH_AUTH_METHOD_HOSTBASED
#define SSH_AUTH_METHOD_INTERACTIVE
#define SSH_AUTH_METHOD_NONE
#define SSH_AUTH_METHOD_PASSWORD
#define SSH_AUTH_METHOD_PUBLICKEY
#define SSH_AUTH_METHOD_UNKNOWN
#define SSH_AUTH_PASSWORD
#define SSH_AUTH_RHOSTS
#define SSH_AUTH_RHOSTS_RSA
#define SSH_AUTH_RSA
#define SSH_AUTH_TIS
#define SSH_BUFFER_PACK_END
#define SSH_CHANNEL_FLAG_CLOSED_REMOTE
#define SSH_CHANNEL_FLAG_FREED_LOCAL
#define SSH_CHANNEL_FLAG_NOT_BOUND
#define SSH_CIPHER_3DES
#define SSH_CIPHER_BLOWFISH
#define SSH_CIPHER_DES
#define SSH_CIPHER_IDEA
#define SSH_CIPHER_NONE
#define SSH_CIPHER_RC4
#define SSH_CLOSED
#define SSH_CLOSED_ERROR
#define SSH_CMSG_AGENT_REQUEST_FORWARDING
#define SSH_CMSG_AUTH_KERBEROS
#define SSH_CMSG_AUTH_PASSWORD
#define SSH_CMSG_AUTH_RHOSTS
#define SSH_CMSG_AUTH_RHOSTS_RSA
#define SSH_CMSG_AUTH_RSA
#define SSH_CMSG_AUTH_RSA_RESPONSE
#define SSH_CMSG_AUTH_TIS
#define SSH_CMSG_AUTH_TIS_RESPONSE
#define SSH_CMSG_EOF
#define SSH_CMSG_EXEC_CMD
#define SSH_CMSG_EXEC_SHELL
#define SSH_CMSG_EXIT_CONFIRMATION
#define SSH_CMSG_HAVE_AFS_TOKEN
#define SSH_CMSG_HAVE_KERBEROS_TGT
#define SSH_CMSG_MAX_PACKET_SIZE
#define SSH_CMSG_PORT_FORWARD_REQUEST
#define SSH_CMSG_REQUEST_COMPRESSION
#define SSH_CMSG_REQUEST_PTY
#define SSH_CMSG_SESSION_KEY
#define SSH_CMSG_STDIN_DATA
#define SSH_CMSG_USER
#define SSH_CMSG_WINDOW_SIZE
#define SSH_CMSG_X11_REQUEST_FORWARDING
#define SSH_COMP
#define SSH_COM_AGENT2_FAILURE
#define SSH_CRYPT
#define SSH_DEPRECATED
#define SSH_EOF
#define SSH_ERROR
#define SSH_FILEXFER_ATTR_ACCESSTIME
#define SSH_FILEXFER_ATTR_ACL
#define SSH_FILEXFER_ATTR_ACMODTIME
#define SSH_FILEXFER_ATTR_CREATETIME
#define SSH_FILEXFER_ATTR_EXTENDED
#define SSH_FILEXFER_ATTR_MODIFYTIME
#define SSH_FILEXFER_ATTR_OWNERGROUP
#define SSH_FILEXFER_ATTR_PERMISSIONS
#define SSH_FILEXFER_ATTR_SIZE
#define SSH_FILEXFER_ATTR_SUBSECOND_TIMES
#define SSH_FILEXFER_ATTR_UIDGID
#define SSH_FILEXFER_TYPE_DIRECTORY
#define SSH_FILEXFER_TYPE_REGULAR
#define SSH_FILEXFER_TYPE_SPECIAL
#define SSH_FILEXFER_TYPE_SYMLINK
#define SSH_FILEXFER_TYPE_UNKNOWN
#define SSH_FXE_STATVFS_ST_NOSUID
#define SSH_FXE_STATVFS_ST_RDONLY
#define SSH_FXF_APPEND
#define SSH_FXF_CREAT
#define SSH_FXF_EXCL
#define SSH_FXF_READ
#define SSH_FXF_RENAME_ATOMIC
#define SSH_FXF_RENAME_NATIVE
#define SSH_FXF_RENAME_OVERWRITE
#define SSH_FXF_TEXT
#define SSH_FXF_TRUNC
#define SSH_FXF_WRITE
#define SSH_FXP_ATTRS
#define SSH_FXP_CLOSE
#define SSH_FXP_DATA
#define SSH_FXP_EXTENDED
#define SSH_FXP_EXTENDED_REPLY
#define SSH_FXP_FSETSTAT
#define SSH_FXP_FSTAT
#define SSH_FXP_HANDLE
#define SSH_FXP_INIT
#define SSH_FXP_LSTAT
#define SSH_FXP_MKDIR
#define SSH_FXP_NAME
#define SSH_FXP_OPEN
#define SSH_FXP_OPENDIR
#define SSH_FXP_READ
#define SSH_FXP_READDIR
#define SSH_FXP_READLINK
#define SSH_FXP_REALPATH
#define SSH_FXP_REMOVE
#define SSH_FXP_RENAME
#define SSH_FXP_RMDIR
#define SSH_FXP_SETSTAT
#define SSH_FXP_STAT
#define SSH_FXP_STATUS
#define SSH_FXP_SYMLINK
#define SSH_FXP_VERSION
#define SSH_FXP_WRITE
#define SSH_FX_BAD_MESSAGE
#define SSH_FX_CONNECTION_LOST
#define SSH_FX_EOF
#define SSH_FX_FAILURE
#define SSH_FX_FILE_ALREADY_EXISTS
#define SSH_FX_INVALID_HANDLE
#define SSH_FX_NO_CONNECTION
#define SSH_FX_NO_MEDIA
#define SSH_FX_NO_SUCH_FILE
#define SSH_FX_NO_SUCH_PATH
#define SSH_FX_OK
#define SSH_FX_OP_UNSUPPORTED
#define SSH_FX_PERMISSION_DENIED
#define SSH_FX_WRITE_PROTECT
#define SSH_INVALID_SOCKET
#define SSH_KEX_METHODS
#define SSH_KEY_FLAG_EMPTY
#define SSH_KEY_FLAG_PRIVATE
#define SSH_KEY_FLAG_PUBLIC
#define SSH_LANG

#define SSH_LOG( \
    priority, \
    ... \
)

#define SSH_LOG_DEBUG
#define SSH_LOG_INFO
#define SSH_LOG_NONE
#define SSH_LOG_RARE
#define SSH_LOG_TRACE
#define SSH_LOG_WARN
#define SSH_MAC
#define SSH_MSG_CHANNEL_CLOSE
#define SSH_MSG_CHANNEL_CLOSE_CONFIRMATION
#define SSH_MSG_CHANNEL_DATA
#define SSH_MSG_CHANNEL_INPUT_EOF
#define SSH_MSG_CHANNEL_OPEN_CONFIRMATION
#define SSH_MSG_CHANNEL_OPEN_FAILURE
#define SSH_MSG_CHANNEL_OUTPUT_CLOSE
#define SSH_MSG_DEBUG
#define SSH_MSG_DISCONNECT
#define SSH_MSG_IGNORE
#define SSH_MSG_NONE
#define SSH_MSG_PORT_OPEN
#define SSH_OID_TAG
#define SSH_OK
#define SSH_PACKET_CALLBACK(name)
#define SSH_PACKET_NOT_USED
#define SSH_PACKET_USED
#define SSH_PASS_AFS_TOKEN
#define SSH_PASS_KERBEROS_TGT
#define SSH_POLL_CTX_CHUNK
#define SSH_PROTOFLAG_HOST_IN_FWD_OPEN
#define SSH_PROTOFLAG_SCREEN_NUMBER
#define SSH_READ_PENDING
#define SSH_SESSION_FLAG_AUTHENTICATED
#define SSH_SESSION_FLAG_BLOCKING
#define SSH_SMSG_AGENT_OPEN
#define SSH_SMSG_AUTH_KERBEROS_RESPONSE
#define SSH_SMSG_AUTH_RSA_CHALLENGE
#define SSH_SMSG_AUTH_TIS_CHALLENGE
#define SSH_SMSG_EXITSTATUS
#define SSH_SMSG_FAILURE
#define SSH_SMSG_PUBLIC_KEY
#define SSH_SMSG_STDERR_DATA
#define SSH_SMSG_STDOUT_DATA
#define SSH_SMSG_SUCCESS
#define SSH_SMSG_X11_OPEN
#define SSH_SOCKET_CONNECTED_ERROR
#define SSH_SOCKET_CONNECTED_OK
#define SSH_SOCKET_CONNECTED_TIMEOUT
#define SSH_SOCKET_EXCEPTION_EOF
#define SSH_SOCKET_EXCEPTION_ERROR
#define SSH_SOCKET_FLOW_WRITEWILLBLOCK
#define SSH_SOCKET_FLOW_WRITEWONTBLOCK
#define SSH_STRINGIFY(s)
#define SSH_TIMEOUT_DEFAULT
#define SSH_TIMEOUT_INFINITE
#define SSH_TIMEOUT_NONBLOCKING
#define SSH_TIMEOUT_USER
#define SSH_TOSTRING(s)

#define SSH_VERSION( \
    a, \
    b, \
    c \
)

#define SSH_VERSION_DOT( \
    a, \
    b, \
    c \
)

#define SSH_VERSION_INT( \
    a, \
    b, \
    c \
)

#define SSH_WRITE_PENDING
#define TCPHDR_LEN
#define TCPIPHDR_LEN
#define TH_ACK
#define TH_FIN
#define TH_PUSH
#define TH_RST
#define TH_SYN
#define TH_URG
#define WINDOWBASE
#define WINDOWLIMIT
#define WINDOWMASK
#define WINDOWSIZE
#define ZERO_STRUCT(x)
#define ZERO_STRUCTP(x)
#define ZLIB
#define ZLIB_STRING
#define _PKI_CRYPTO_H
#define _POSIX_PTHREAD_SEMANTICS
#define _XCLOSESOCKET
#define __VA_NARG__(...)
#define agent_failed(x)
#define bswap_32(x)
#define buffer_verify(x)
#define discard_const(ptr)

#define discard_const_p( \
    type, \
    ptr \
)

#define fe25519
#define fe25519_add
#define fe25519_cmov
#define fe25519_freeze
#define fe25519_getparity
#define fe25519_invert
#define fe25519_iseq_vartime
#define fe25519_iszero
#define fe25519_mul
#define fe25519_neg
#define fe25519_pack
#define fe25519_pow2523
#define fe25519_setone
#define fe25519_setzero
#define fe25519_square
#define fe25519_sub
#define fe25519_unpack
#define ge25519
#define ge25519_base
#define ge25519_double_scalarmult_vartime
#define ge25519_isneutral_vartime
#define ge25519_p3
#define ge25519_pack
#define ge25519_scalarmult_base
#define ge25519_unpackneg_vartime
#define htonll(x)
#define inline
#define ntohll(x)
#define return_throwable
#define sc25519
#define sc25519_2interleave2
#define sc25519_add
#define sc25519_from32bytes
#define sc25519_from64bytes
#define sc25519_from_shortsc
#define sc25519_isshort_vartime
#define sc25519_iszero_vartime
#define sc25519_lt_vartime
#define sc25519_mul
#define sc25519_mul_shortsc
#define sc25519_sub_nored
#define sc25519_to32bytes
#define sc25519_window3
#define sc25519_window5

#define set_status( \
    session, \
    status \
)

#define set_status( \
    session, \
    status \
)

#define shortsc25519
#define shortsc25519_from16bytes

#define ssh_buffer_pack( \
    buffer, \
    format, \
    ... \
)

#define ssh_buffer_unpack( \
    buffer, \
    format, \
    ... \
)

#define ssh_callbacks_exists( \
    p, \
    c \
)

#define ssh_callbacks_init(p)

#define ssh_iterator_value( \
    type, \
    iterator \
)

#define ssh_list_pop_head( \
    type, \
    ssh_list \
)

#define ssh_pki_log(...)

#define ssh_set_error( \
    error, \
    code, \
    ... \
)

#define ssh_set_error_invalid(error)
#define ssh_set_error_oom(error)
#define ssh_throw(x)

#define ssh_throw_null( \
    CSession, \
    x \
)

#define void_throwable

Detailed Documentation

Enum Values

SSH_LOG_NOLOG

No logging at all.

SSH_LOG_WARNING

Only warnings.

SSH_LOG_PROTOCOL

High level protocol information.

SSH_LOG_PACKET

Lower level protocol infomations, packet level.

SSH_LOG_FUNCTIONS

Every function path.

SSH_SCP_WRITE

Code is going to write/create remote files.

SSH_SCP_READ

Code is going to read remote files.

Typedefs

typedef int (*ssh_thread_callback)(void **lock)

libssh_threads

typedef int (*ssh_auth_callback)(
    const char *prompt,
    char *buf,
    size_t len,
    int echo,
    int verify,
    void *userdata
    )

SSH authentication callback.

Parameters:

prompt

Prompt to be displayed.

buf

Buffer to save the password. You should null-terminate it.

len

Length of the buffer.

echo

Enable or disable the echo of what you type.

verify

Should the password be verified?

userdata

Userdata to be passed to the callback function. Useful for GUI applications.

Returns:

0 on success, < 0 on error.

typedef int (*ssh_poll_callback)(
    ssh_poll_handle p,
    socket_t fd,
    int revents,
    void *userdata
    )

SSH poll callback.

This callback will be used when an event caught on the socket.

Parameters:

p

Poll object this callback belongs to.

fd

The raw socket.

revents

The current poll events on the socket.

userdata

Userdata to be passed to the callback function.

Returns:

0 on success, < 0 if you removed the poll object from its poll context.

Global Functions

void
agent_free(struct ssh_agent_struct* agent)

Free an allocated ssh agent structure.

Parameters:

agent

The ssh agent structure to free.

int
agent_is_running(struct ssh_session_struct* session)

Check if the ssh agent is running.

Parameters:

session

The ssh session to check for the agent.

Returns:

1 if it is running, 0 if not.

struct ssh_agent_struct*
agent_new(struct ssh_session_struct* session)

Create a new ssh agent structure.

Returns:

An allocated ssh agent structure or NULL on error.

LIBSSH_API struct ssh_threads_callbacks_struct*
ssh_threads_get_pthread(void)

returns a pointer on the pthread threads callbacks, to be used with ssh_threads_set_callbacks.

Warning

you have to link with the library ssh_threads.

See also:

ssh_threads_set_callbacks

int
ssh_gssapi_auth_mic(ssh_session session)

launches a gssapi-with-mic auth request

Returns:

SSH_AUTH_ERROR: A serious error happened

SSH_AUTH_DENIED: Authentication failed : use another method

SSH_AUTH_AGAIN: In nonblocking mode, you’ve got to call this again later.

int
set_client_kex(ssh_session session)

sets the key exchange parameters to be sent to the server, in function of the options and available methods.

int
ssh_kex_select_methods(ssh_session session)

Select the different methods on basis of client’s and server’s kex messages, and watches out if a match is possible.

LIBSSH_API int
ssh_auth_list(ssh_session session)

functions in that file are wrappers to the newly named functions.

All of them are depreciated, but these wrapper will avoid breaking backward compatibility

LIBSSH_API ssh_message
ssh_message_retrieve(
    ssh_session session,
    uint32_t packettype
)

Interface previously exported by error.

Deprecated

void
ssh_gssapi_set_creds(
    ssh_session session,
    const ssh_gssapi_creds creds
)

Set the forwadable ticket to be given to the server for authentication.

Unlike ssh_gssapi_get_creds() this is called on the client side of an ssh connection.

Parameters:

creds

gssapi credentials handle.

ssh_pcap_file
ssh_pcap_file_new(void)

create a new ssh_pcap_file object

int
ssh_pcap_file_open(
    ssh_pcap_file pcap,
    const char* filename
)

opens a new pcap file and create header

int
ssh_set_agent_channel(
    ssh_session session,
    ssh_channel channel
)

sets the SSH agent channel.

The SSH agent channel will be used to authenticate this client using an agent through a channel, from another session. The most likely use is to implement SSH Agent forwarding into a SSH proxy.

Parameters:

channel

a SSH channel from another session.

Returns:

SSH_OK in case of success SSH_ERROR in case of an error

int
ssh_set_agent_socket(
    ssh_session session,
    socket_t fd
)

sets the SSH agent socket.

The SSH agent will be used to authenticate this client using the given socket to communicate with the ssh-agent. The caller is responsible for connecting to the socket prior to calling this function.

Returns:

SSH_OK in case of success SSH_ERROR in case of an error

int
ssh_set_pcap_file(
    ssh_session session,
    ssh_pcap_file pcapfile
)

sets the pcap file used to trace the session

Parameters:

current

session

pcap

an handler to a pcap file. A pcap file may be used in several sessions.

Returns:

SSH_ERROR in case of error, SSH_OK otherwise.

void
ssh_socket_cleanup(void)

Cleanup the socket system.

int
ssh_socket_pollcallback(
    struct ssh_poll_handle_struct* p,
    socket_t fd,
    int revents,
    void* v_s
)

SSH poll callback.

This callback will be used when an event caught on the socket.

Parameters:

p

Poll object this callback belongs to.

fd

The raw socket.

revents

The current poll events on the socket.

userdata

Userdata to be passed to the callback function, in this case the socket object.

Returns:

0 on success, < 0 when the poll object has been removed from its poll context.

ssh_agent
agent_new(struct ssh_session_struct* session)

Create a new ssh agent structure.

Returns:

An allocated ssh agent structure or NULL on error.

int
ssh_set_agent_channel(
    ssh_session session,
    ssh_channel channel
)

sets the SSH agent channel.

The SSH agent channel will be used to authenticate this client using an agent through a channel, from another session. The most likely use is to implement SSH Agent forwarding into a SSH proxy.

Parameters:

channel

a SSH channel from another session.

Returns:

SSH_OK in case of success SSH_ERROR in case of an error

int
ssh_set_agent_socket(
    ssh_session session,
    socket_t fd
)

sets the SSH agent socket.

The SSH agent will be used to authenticate this client using the given socket to communicate with the ssh-agent. The caller is responsible for connecting to the socket prior to calling this function.

Returns:

SSH_OK in case of success SSH_ERROR in case of an error

int
ssh_gssapi_auth_mic(ssh_session session)

launches a gssapi-with-mic auth request

Returns:

SSH_AUTH_ERROR: A serious error happened

SSH_AUTH_DENIED: Authentication failed : use another method

SSH_AUTH_AGAIN: In nonblocking mode, you’ve got to call this again later.

static
int
ssh_gssapi_match(
    ssh_session session,
    gss_OID_set* valid_oids
)

returns the OIDs of the mechs that have usable credentials

void
ssh_gssapi_set_creds(
    ssh_session session,
    const ssh_gssapi_creds creds
)

Set the forwadable ticket to be given to the server for authentication.

Unlike ssh_gssapi_get_creds() this is called on the client side of an ssh connection.

Parameters:

creds

gssapi credentials handle.

int
set_client_kex(ssh_session session)

sets the key exchange parameters to be sent to the server, in function of the options and available methods.

int
ssh_kex_select_methods(ssh_session session)

Select the different methods on basis of client’s and server’s kex messages, and watches out if a match is possible.

SSH_PACKET_CALLBACK(ssh_packet_publickey1)

Wait for a SSH_SMSG_PUBLIC_KEY and does the key exchange.

int
ssh_auth_list(ssh_session session)

functions in that file are wrappers to the newly named functions.

All of them are depreciated, but these wrapper will avoid breaking backward compatibility

ssh_message
ssh_message_retrieve(
    ssh_session session,
    uint32_t packettype
)

Interface previously exported by error.

Deprecated

ssh_pcap_file
ssh_pcap_file_new(void)

create a new ssh_pcap_file object

int
ssh_pcap_file_open(
    ssh_pcap_file pcap,
    const char* filename
)

opens a new pcap file and create header

int
ssh_set_pcap_file(
    ssh_session session,
    ssh_pcap_file pcap
)

sets the pcap file used to trace the session

Parameters:

current

session

pcap

an handler to a pcap file. A pcap file may be used in several sessions.

Returns:

SSH_ERROR in case of error, SSH_OK otherwise.

void
ssh_socket_cleanup(void)

Cleanup the socket system.

int
ssh_socket_pollcallback(
    struct ssh_poll_handle_struct* p,
    socket_t fd,
    int revents,
    void* v_s
)

SSH poll callback.

This callback will be used when an event caught on the socket.

Parameters:

p

Poll object this callback belongs to.

fd

The raw socket.

revents

The current poll events on the socket.

userdata

Userdata to be passed to the callback function, in this case the socket object.

Returns:

0 on success, < 0 when the poll object has been removed from its poll context.

Macros

#define ARRAY_SIZE(a)

Get the size of an array.

#define BURN_BUFFER( \
    x, \
    size \
)

Overwrite the buffer with ‘0’.

#define BURN_STRING(x)

Overwrite a string with ‘0’.

#define SAFE_FREE(x)

Free memory space.

#define SSH_CLOSED

Socket is closed.

#define SSH_CLOSED_ERROR

Session was closed due to an error.

#define SSH_LOG_DEBUG

Get detailed debuging information.

#define SSH_LOG_INFO

Get some information what’s going on.

#define SSH_LOG_NONE

No logging at all.

#define SSH_LOG_TRACE

Get trace output, packet information, …

#define SSH_LOG_WARN

Show only warnings.

#define SSH_READ_PENDING

Reading to socket won’t block.

#define SSH_WRITE_PENDING

Output buffer not empty.

#define ZERO_STRUCT(x)

Zero a structure.

#define ZERO_STRUCTP(x)

Zero a structure given a pointer to the structure.

#define __VA_NARG__(...)

Get the argument cound of variadic arguments.

#define discard_const(ptr)

This is a hack to fix warnings.

The idea is to use this everywhere that we get the “discarding const” warning by the compiler. That doesn’t actually fix the real issue, but marks the place and you can search the code for discard_const.

Please use this macro only when there is no other way to fix the warning. We should use this function in only in a very few places.

Also, please call this via the discard_const_p() macro interface, as that makes the return type safe.

#define discard_const_p( \
    type, \
    ptr \
)

Type-safe version of discard_const.

#define ssh_list_pop_head( \
    type, \
    ssh_list \
)

fetch the head element of a list and remove it from list

Parameters:

type

type of the element to return

list

the ssh_list to use

Returns:

the first element of the list, or NULL if the list is empty