25#include "libssh/priv.h"
26#include "libssh/callbacks.h"
27#include "libssh/kex.h"
28#include "libssh/packet.h"
29#include "libssh/pcap.h"
30#include "libssh/auth.h"
31#include "libssh/channels.h"
32#include "libssh/poll.h"
33#include "libssh/config.h"
34#include "libssh/misc.h"
37enum ssh_session_state_e {
38 SSH_SESSION_STATE_NONE=0,
39 SSH_SESSION_STATE_CONNECTING,
40 SSH_SESSION_STATE_SOCKET_CONNECTED,
41 SSH_SESSION_STATE_BANNER_RECEIVED,
42 SSH_SESSION_STATE_INITIAL_KEX,
43 SSH_SESSION_STATE_KEXINIT_RECEIVED,
45 SSH_SESSION_STATE_AUTHENTICATING,
46 SSH_SESSION_STATE_AUTHENTICATED,
47 SSH_SESSION_STATE_ERROR,
48 SSH_SESSION_STATE_DISCONNECTED
54 DH_STATE_REQUEST_SENT,
56 DH_STATE_NEWKEYS_SENT,
60enum ssh_pending_call_e {
61 SSH_PENDING_CALL_NONE = 0,
62 SSH_PENDING_CALL_CONNECT,
63 SSH_PENDING_CALL_AUTH_NONE,
64 SSH_PENDING_CALL_AUTH_PASSWORD,
65 SSH_PENDING_CALL_AUTH_OFFER_PUBKEY,
66 SSH_PENDING_CALL_AUTH_PUBKEY,
67 SSH_PENDING_CALL_AUTH_AGENT,
68 SSH_PENDING_CALL_AUTH_KBDINT_INIT,
69 SSH_PENDING_CALL_AUTH_KBDINT_SEND,
70 SSH_PENDING_CALL_AUTH_GSSAPI_MIC
74#define SSH_SESSION_FLAG_BLOCKING 0x0001
77#define SSH_SESSION_FLAG_AUTHENTICATED 0x0002
80#define SSH_SESSION_FLAG_NO_MORE_SESSIONS 0x0004
85#define SSH_SESSION_FLAG_KEXINIT_SENT 0x0008
89#define SSH_SESSION_FLAG_KEX_STRICT 0x0010
91#define SSH_SESSION_FLAG_KEX_TAINTED 0x0020
95#define SSH_TIMEOUT_INFINITE -1
97#define SSH_TIMEOUT_USER -2
99#define SSH_TIMEOUT_DEFAULT -3
101#define SSH_TIMEOUT_NONBLOCKING 0
105#define SSH_OPT_FLAG_PASSWORD_AUTH 0x1
106#define SSH_OPT_FLAG_PUBKEY_AUTH 0x2
107#define SSH_OPT_FLAG_KBDINT_AUTH 0x4
108#define SSH_OPT_FLAG_GSSAPI_AUTH 0x8
111#define SSH_OPT_EXP_FLAG_KNOWNHOSTS 0x1
112#define SSH_OPT_EXP_FLAG_GLOBAL_KNOWNHOSTS 0x2
113#define SSH_OPT_EXP_FLAG_PROXYCOMMAND 0x4
114#define SSH_OPT_EXP_FLAG_IDENTITY 0x8
115#define SSH_OPT_EXP_FLAG_CONTROL_PATH 0x10
119#define SSH_EXT_NEGOTIATION 0x01
121#define SSH_EXT_SIG_RSA_SHA256 0x02
122#define SSH_EXT_SIG_RSA_SHA512 0x04
125struct ssh_common_struct {
126 struct error_struct error;
131struct ssh_session_struct {
132 struct ssh_common_struct common;
133 struct ssh_socket_struct *socket;
142 struct ssh_timestamp last_rekey_time;
158 char *peer_discon_msg;
159 char *disconnect_message;
160 ssh_buffer in_buffer;
162 ssh_buffer out_buffer;
163 struct ssh_list *out_queue;
168 enum ssh_pending_call_e pending_call_state;
169 enum ssh_session_state_e session_state;
170 enum ssh_packet_state_e packet_state;
171 enum ssh_dh_state_e dh_handshake_state;
172 enum ssh_channel_request_state_e global_req_state;
173 struct ssh_agent_state_struct *agent_state;
176 struct ssh_auth_auto_state_struct *auto_state;
177 enum ssh_auth_service_state_e service_state;
178 enum ssh_auth_state_e state;
179 uint32_t supported_methods;
180 uint32_t current_method;
187 bool send_first_kex_follows;
197 bool first_kex_follows_guess_wrong;
199 ssh_buffer in_hashbuf;
200 ssh_buffer out_hashbuf;
201 struct ssh_crypto_struct *current_crypto;
203 struct ssh_crypto_struct *next_crypto;
205 struct ssh_list *channels;
210 struct ssh_kbdint_struct *kbdint;
211 struct ssh_gssapi_struct *gssapi;
219 enum ssh_keytypes_e hostkey;
220 enum ssh_digest_e hostkey_digest;
224 struct ssh_list *ssh_message_list;
225 int (*ssh_message_callback)(
struct ssh_session_struct *session,
226 ssh_message msg,
void *userdata);
227 void *ssh_message_callback_data;
229 void (*ssh_connection_callback)(
struct ssh_session_struct *session);
230 struct ssh_packet_callbacks_struct default_packet_callbacks;
231 struct ssh_list *packet_callbacks;
233 ssh_poll_ctx default_poll_ctx;
236 ssh_pcap_context pcap_ctx;
239 struct ssh_list *identity;
240 struct ssh_list *identity_non_exp;
241 struct ssh_list *certificate;
242 struct ssh_list *certificate_non_exp;
243 struct ssh_list *proxy_jumps;
244 struct ssh_list *proxy_jumps_user_cb;
250 char *global_knownhosts;
251 char *wanted_methods[SSH_KEX_METHODS];
252 char *pubkey_accepted_types;
255 unsigned long timeout;
256 unsigned long timeout_usec;
259 int StrictHostKeyChecking;
260 char compressionlevel;
261 char *gss_server_identity;
262 char *gss_client_identity;
263 int gss_delegate_creds;
267 bool config_processed;
268 uint8_t options_seen[SOC_MAX];
272 bool identities_only;
284 ssh_counter socket_counter;
285 ssh_counter raw_counter;
293typedef int (*ssh_termination_function)(
void *user);
294int ssh_handle_packets(ssh_session session,
int timeout);
295int ssh_handle_packets_termination(ssh_session session,
297 ssh_termination_function fct,
299void ssh_socket_exception_callback(
int code,
int errno_code,
void *user);
Definition callbacks.h:165
Definition callbacks.h:333
Definition callbacks.h:411