
Some checks failed
CIFuzz / Fuzzing (push) Waiting to run
C/C++ CI self-hosted / win10 cygwin-release (push) Waiting to run
C/C++ CI self-hosted / ARM default (push) Waiting to run
C/C++ CI self-hosted / ARM64 default (push) Waiting to run
C/C++ CI self-hosted / alpine default (push) Waiting to run
C/C++ CI self-hosted / centos7 default (push) Waiting to run
C/C++ CI self-hosted / debian-i386 default (push) Waiting to run
C/C++ CI self-hosted / dfly30 default (push) Waiting to run
C/C++ CI self-hosted / dfly48 default (push) Waiting to run
C/C++ CI self-hosted / dfly60 default (push) Waiting to run
C/C++ CI self-hosted / dfly62 default (push) Waiting to run
C/C++ CI self-hosted / dfly64 default (push) Waiting to run
C/C++ CI self-hosted / fbsd10 default (push) Waiting to run
C/C++ CI self-hosted / fbsd12 default (push) Waiting to run
C/C++ CI self-hosted / fbsd13 default (push) Waiting to run
C/C++ CI self-hosted / fbsd14 default (push) Waiting to run
C/C++ CI self-hosted / nbsd10 default (push) Waiting to run
C/C++ CI self-hosted / nbsd3 default (push) Waiting to run
C/C++ CI self-hosted / nbsd4 default (push) Waiting to run
C/C++ CI self-hosted / nbsd8 default (push) Waiting to run
C/C++ CI self-hosted / nbsd9 default (push) Waiting to run
C/C++ CI self-hosted / obsd51 default (push) Waiting to run
C/C++ CI self-hosted / obsd67 default (push) Waiting to run
C/C++ CI self-hosted / obsd72 default (push) Waiting to run
C/C++ CI self-hosted / obsd73 default (push) Waiting to run
C/C++ CI self-hosted / obsd74 default (push) Waiting to run
C/C++ CI self-hosted / obsdsnap default (push) Waiting to run
C/C++ CI self-hosted / obsdsnap-i386 default (push) Waiting to run
C/C++ CI self-hosted / omnios default (push) Waiting to run
C/C++ CI self-hosted / openindiana default (push) Waiting to run
C/C++ CI self-hosted / ubuntu-2204 default (push) Waiting to run
C/C++ CI self-hosted / obsd-arm64 default (push) Waiting to run
C/C++ CI self-hosted / aix51 default (push) Waiting to run
C/C++ CI self-hosted / fbsd14-ppc64 default (push) Waiting to run
C/C++ CI self-hosted / sol10 default (push) Waiting to run
C/C++ CI self-hosted / sol11 default (push) Waiting to run
C/C++ CI self-hosted / win10 default (push) Waiting to run
C/C++ CI self-hosted / debian-riscv64 default (push) Waiting to run
C/C++ CI self-hosted / openwrt-mips default (push) Waiting to run
C/C++ CI self-hosted / openwrt-mipsel default (push) Waiting to run
C/C++ CI self-hosted / ARM64 pam (push) Waiting to run
C/C++ CI self-hosted / centos7 pam (push) Waiting to run
C/C++ CI self-hosted / debian-i386 pam (push) Waiting to run
C/C++ CI self-hosted / dfly48 pam (push) Waiting to run
C/C++ CI self-hosted / dfly58 pam (push) Waiting to run
C/C++ CI self-hosted / dfly60 pam (push) Waiting to run
C/C++ CI self-hosted / dfly62 pam (push) Waiting to run
C/C++ CI self-hosted / dfly64 pam (push) Waiting to run
C/C++ CI self-hosted / fbsd10 pam (push) Waiting to run
C/C++ CI self-hosted / fbsd12 pam (push) Waiting to run
C/C++ CI self-hosted / fbsd13 pam (push) Waiting to run
C/C++ CI self-hosted / fbsd14 pam (push) Waiting to run
C/C++ CI self-hosted / nbsd10 pam (push) Waiting to run
C/C++ CI self-hosted / nbsd8 pam (push) Waiting to run
C/C++ CI self-hosted / nbsd9 pam (push) Waiting to run
C/C++ CI self-hosted / omnios pam (push) Waiting to run
C/C++ CI self-hosted / openindiana pam (push) Waiting to run
C/C++ CI self-hosted / sol10 pam (push) Waiting to run
C/C++ CI self-hosted / sol11 pam-krb5 (push) Waiting to run
C/C++ CI self-hosted / sol11 sol64 (push) Waiting to run
C/C++ CI self-hosted / dfly30 without-openssl (push) Waiting to run
C/C++ CI / ubuntu-latest aws-lc (push) Failing after 31s
C/C++ CI / ubuntu-latest boringssl (push) Failing after 31s
C/C++ CI / ubuntu-latest clang-15 (push) Failing after 31s
C/C++ CI / ubuntu-latest clang-19 (push) Failing after 19s
C/C++ CI / ubuntu-latest default (push) Failing after 3s
C/C++ CI / ubuntu-latest gcc-14 (push) Failing after 4s
C/C++ CI / ubuntu-latest libressl-3.2.6 (push) Failing after 4s
C/C++ CI / ubuntu-latest libressl-3.3.6 (push) Failing after 3s
C/C++ CI / ubuntu-latest libressl-3.4.3 (push) Failing after 3s
C/C++ CI / ubuntu-latest libressl-3.5.3 (push) Failing after 4s
C/C++ CI / ubuntu-latest libressl-3.6.1 (push) Failing after 4s
C/C++ CI / ubuntu-latest libressl-3.7.2 (push) Failing after 4s
C/C++ CI / ubuntu-latest libressl-3.8.4 (push) Failing after 3s
C/C++ CI / ubuntu-latest libressl-3.9.2 (push) Failing after 3s
C/C++ CI / ubuntu-latest libressl-4.0.0 (push) Failing after 4s
C/C++ CI / ubuntu-latest libressl-master (push) Failing after 4s
C/C++ CI / ubuntu-latest musl (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-1.1.1 (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-1.1.1_stable (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-1.1.1t (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-1.1.1w (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-3.0 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-3.0.0 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-3.0.15 (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-3.1 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-3.1.0 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-3.1.7 (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-3.2 (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-3.2.3 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-3.3 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-3.3.2 (push) Failing after 4s
C/C++ CI / ubuntu-latest openssl-3.4.0 (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-master (push) Failing after 3s
C/C++ CI / ubuntu-latest openssl-noec (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.71 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.72 (push) Failing after 3s
C/C++ CI / ubuntu-latest putty-0.73 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.74 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.75 (push) Failing after 3s
C/C++ CI / ubuntu-latest putty-0.76 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.77 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.78 (push) Failing after 3s
C/C++ CI / ubuntu-latest putty-0.79 (push) Failing after 3s
C/C++ CI / ubuntu-latest putty-0.80 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.81 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-0.82 (push) Failing after 3s
C/C++ CI / ubuntu-latest putty-0.83 (push) Failing after 4s
C/C++ CI / ubuntu-latest putty-snapshot (push) Failing after 4s
C/C++ CI / ubuntu-latest tcmalloc (push) Failing after 3s
C/C++ CI / ubuntu-latest zlib-develop (push) Failing after 3s
C/C++ CI / ubuntu-22.04 c89 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 clang-11 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 clang-12-Werror (push) Has been cancelled
C/C++ CI / ubuntu-22.04 clang-14 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 clang-sanitize-address (push) Has been cancelled
C/C++ CI / ubuntu-22.04 clang-sanitize-undefined (push) Has been cancelled
C/C++ CI / windows-2019 cygwin-release (push) Has been cancelled
C/C++ CI / windows-2022 cygwin-release (push) Has been cancelled
C/C++ CI / macos-13 default (push) Has been cancelled
C/C++ CI / macos-14 default (push) Has been cancelled
C/C++ CI / macos-15 default (push) Has been cancelled
C/C++ CI / ubuntu-22.04 default (push) Has been cancelled
C/C++ CI / ubuntu-22.04-arm default (push) Has been cancelled
C/C++ CI / ubuntu-24.04-arm default (push) Has been cancelled
C/C++ CI / windows-2019 default (push) Has been cancelled
C/C++ CI / windows-2022 default (push) Has been cancelled
C/C++ CI / ubuntu-22.04 gcc-11-Werror (push) Has been cancelled
C/C++ CI / ubuntu-22.04 gcc-12-Werror (push) Has been cancelled
C/C++ CI / ubuntu-22.04 gcc-9 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 gcc-sanitize-address (push) Has been cancelled
C/C++ CI / ubuntu-22.04 gcc-sanitize-undefined (push) Has been cancelled
C/C++ CI / ubuntu-22.04 hardenedmalloc (push) Has been cancelled
C/C++ CI / ubuntu-22.04 heimdal (push) Has been cancelled
C/C++ CI / ubuntu-22.04 kitchensink (push) Has been cancelled
C/C++ CI / ubuntu-22.04-arm kitchensink (push) Has been cancelled
C/C++ CI / ubuntu-24.04-arm kitchensink (push) Has been cancelled
C/C++ CI / ubuntu-22.04 krb5 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 libedit (push) Has been cancelled
C/C++ CI / macos-13 pam (push) Has been cancelled
C/C++ CI / macos-14 pam (push) Has been cancelled
C/C++ CI / macos-15 pam (push) Has been cancelled
C/C++ CI / ubuntu-22.04 pam (push) Has been cancelled
C/C++ CI / ubuntu-22.04 selinux (push) Has been cancelled
C/C++ CI / ubuntu-22.04 sk (push) Has been cancelled
C/C++ CI / ubuntu-22.04 valgrind-1 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 valgrind-2 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 valgrind-3 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 valgrind-4 (push) Has been cancelled
C/C++ CI / ubuntu-22.04 valgrind-unit (push) Has been cancelled
C/C++ CI / ubuntu-22.04 without-openssl (push) Has been cancelled
227 lines
7.6 KiB
C
227 lines
7.6 KiB
C
/* $OpenBSD: packet.h,v 1.99 2024/08/15 00:51:51 djm Exp $ */
|
|
|
|
/*
|
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
|
* All rights reserved
|
|
* Interface for the packet protocol functions.
|
|
*
|
|
* As far as I am concerned, the code I have written for this software
|
|
* can be used freely for any purpose. Any derived versions of this
|
|
* software must be clearly marked as such, and if the derived work is
|
|
* incompatible with the protocol description in the RFC file, it must be
|
|
* called by a name other than "ssh" or "Secure Shell".
|
|
*/
|
|
|
|
#ifndef PACKET_H
|
|
#define PACKET_H
|
|
|
|
#include <termios.h>
|
|
|
|
#ifdef WITH_OPENSSL
|
|
# include <openssl/bn.h>
|
|
# include <openssl/evp.h>
|
|
# ifdef OPENSSL_HAS_ECC
|
|
# include <openssl/ec.h>
|
|
# else /* OPENSSL_HAS_ECC */
|
|
# define EC_KEY void
|
|
# define EC_GROUP void
|
|
# define EC_POINT void
|
|
# endif /* OPENSSL_HAS_ECC */
|
|
#else /* WITH_OPENSSL */
|
|
# define BIGNUM void
|
|
# define EC_KEY void
|
|
# define EC_GROUP void
|
|
# define EC_POINT void
|
|
# define EVP_PKEY void
|
|
#endif /* WITH_OPENSSL */
|
|
|
|
#include <signal.h>
|
|
#include "openbsd-compat/sys-queue.h"
|
|
|
|
struct kex;
|
|
struct sshkey;
|
|
struct sshbuf;
|
|
struct session_state; /* private session data */
|
|
|
|
#include "dispatch.h" /* typedef, DISPATCH_MAX */
|
|
|
|
struct key_entry {
|
|
TAILQ_ENTRY(key_entry) next;
|
|
struct sshkey *key;
|
|
};
|
|
|
|
struct ssh {
|
|
/* Session state */
|
|
struct session_state *state;
|
|
|
|
/* Key exchange */
|
|
struct kex *kex;
|
|
|
|
/* cached local and remote ip addresses and ports */
|
|
char *remote_ipaddr;
|
|
int remote_port;
|
|
char *local_ipaddr;
|
|
int local_port;
|
|
char *rdomain_in;
|
|
|
|
/* Optional preamble for log messages (e.g. username) */
|
|
char *log_preamble;
|
|
|
|
/* Dispatcher table */
|
|
dispatch_fn *dispatch[DISPATCH_MAX];
|
|
/* number of packets to ignore in the dispatcher */
|
|
int dispatch_skip_packets;
|
|
|
|
/* datafellows */
|
|
int compat;
|
|
|
|
/* Lists for private and public keys */
|
|
TAILQ_HEAD(, key_entry) private_keys;
|
|
TAILQ_HEAD(, key_entry) public_keys;
|
|
|
|
/* Client/Server authentication context */
|
|
void *authctxt;
|
|
|
|
/* Channels context */
|
|
struct ssh_channels *chanctxt;
|
|
|
|
/* APP data */
|
|
void *app_data;
|
|
};
|
|
|
|
typedef int (ssh_packet_hook_fn)(struct ssh *, struct sshbuf *,
|
|
u_char *, void *);
|
|
|
|
struct ssh *ssh_alloc_session_state(void);
|
|
struct ssh *ssh_packet_set_connection(struct ssh *, int, int);
|
|
void ssh_packet_set_timeout(struct ssh *, int, int);
|
|
int ssh_packet_stop_discard(struct ssh *);
|
|
int ssh_packet_connection_af(struct ssh *);
|
|
void ssh_packet_set_nonblocking(struct ssh *);
|
|
int ssh_packet_get_connection_in(struct ssh *);
|
|
int ssh_packet_get_connection_out(struct ssh *);
|
|
void ssh_packet_close(struct ssh *);
|
|
void ssh_packet_set_input_hook(struct ssh *, ssh_packet_hook_fn *, void *);
|
|
void ssh_packet_clear_keys(struct ssh *);
|
|
void ssh_clear_newkeys(struct ssh *, int);
|
|
|
|
int ssh_packet_is_rekeying(struct ssh *);
|
|
int ssh_packet_check_rekey(struct ssh *);
|
|
void ssh_packet_set_protocol_flags(struct ssh *, u_int);
|
|
u_int ssh_packet_get_protocol_flags(struct ssh *);
|
|
void ssh_packet_set_tos(struct ssh *, int);
|
|
void ssh_packet_set_interactive(struct ssh *, int, int, int);
|
|
int ssh_packet_is_interactive(struct ssh *);
|
|
void ssh_packet_set_server(struct ssh *);
|
|
void ssh_packet_set_authenticated(struct ssh *);
|
|
void ssh_packet_set_mux(struct ssh *);
|
|
int ssh_packet_get_mux(struct ssh *);
|
|
int ssh_packet_set_log_preamble(struct ssh *, const char *, ...)
|
|
__attribute__((format(printf, 2, 3)));
|
|
|
|
int ssh_packet_log_type(u_char);
|
|
|
|
int ssh_packet_send2_wrapped(struct ssh *);
|
|
int ssh_packet_send2(struct ssh *);
|
|
|
|
int ssh_packet_read(struct ssh *);
|
|
int ssh_packet_read_poll2(struct ssh *, u_char *, u_int32_t *seqnr_p);
|
|
int ssh_packet_process_incoming(struct ssh *, const char *buf, u_int len);
|
|
int ssh_packet_process_read(struct ssh *, int);
|
|
int ssh_packet_read_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
|
|
int ssh_packet_read_poll_seqnr(struct ssh *, u_char *, u_int32_t *seqnr_p);
|
|
|
|
void ssh_packet_disconnect(struct ssh *, const char *fmt, ...)
|
|
__attribute__((format(printf, 2, 3)))
|
|
__attribute__((noreturn));
|
|
void ssh_packet_send_debug(struct ssh *, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
|
|
|
|
int ssh_set_newkeys(struct ssh *, int mode);
|
|
void ssh_packet_get_bytes(struct ssh *, u_int64_t *, u_int64_t *);
|
|
|
|
int ssh_packet_write_poll(struct ssh *);
|
|
int ssh_packet_write_wait(struct ssh *);
|
|
int ssh_packet_have_data_to_write(struct ssh *);
|
|
int ssh_packet_not_very_much_data_to_write(struct ssh *);
|
|
int ssh_packet_interactive_data_to_write(struct ssh *);
|
|
|
|
int ssh_packet_connection_is_on_socket(struct ssh *);
|
|
int ssh_packet_remaining(struct ssh *);
|
|
|
|
void ssh_tty_make_modes(struct ssh *, int, struct termios *);
|
|
void ssh_tty_parse_modes(struct ssh *, int);
|
|
|
|
void ssh_packet_set_alive_timeouts(struct ssh *, int);
|
|
int ssh_packet_inc_alive_timeouts(struct ssh *);
|
|
int ssh_packet_set_maxsize(struct ssh *, u_int);
|
|
u_int ssh_packet_get_maxsize(struct ssh *);
|
|
|
|
int ssh_packet_get_state(struct ssh *, struct sshbuf *);
|
|
int ssh_packet_set_state(struct ssh *, struct sshbuf *);
|
|
|
|
const char *ssh_remote_ipaddr(struct ssh *);
|
|
int ssh_remote_port(struct ssh *);
|
|
const char *ssh_local_ipaddr(struct ssh *);
|
|
int ssh_local_port(struct ssh *);
|
|
const char *ssh_packet_rdomain_in(struct ssh *);
|
|
char *ssh_remote_hostname(struct ssh *);
|
|
|
|
void ssh_packet_set_rekey_limits(struct ssh *, u_int64_t, u_int32_t);
|
|
time_t ssh_packet_get_rekey_timeout(struct ssh *);
|
|
|
|
void *ssh_packet_get_input(struct ssh *);
|
|
void *ssh_packet_get_output(struct ssh *);
|
|
|
|
/* new API */
|
|
int sshpkt_start(struct ssh *ssh, u_char type);
|
|
int sshpkt_send(struct ssh *ssh);
|
|
int sshpkt_disconnect(struct ssh *, const char *fmt, ...)
|
|
__attribute__((format(printf, 2, 3)));
|
|
int sshpkt_add_padding(struct ssh *, u_char);
|
|
void sshpkt_fatal(struct ssh *ssh, int r, const char *fmt, ...)
|
|
__attribute__((format(printf, 3, 4)))
|
|
__attribute__((noreturn));
|
|
int sshpkt_msg_ignore(struct ssh *, u_int);
|
|
|
|
int sshpkt_put(struct ssh *ssh, const void *v, size_t len);
|
|
int sshpkt_putb(struct ssh *ssh, const struct sshbuf *b);
|
|
int sshpkt_put_u8(struct ssh *ssh, u_char val);
|
|
int sshpkt_put_u32(struct ssh *ssh, u_int32_t val);
|
|
int sshpkt_put_u64(struct ssh *ssh, u_int64_t val);
|
|
int sshpkt_put_string(struct ssh *ssh, const void *v, size_t len);
|
|
int sshpkt_put_cstring(struct ssh *ssh, const void *v);
|
|
int sshpkt_put_stringb(struct ssh *ssh, const struct sshbuf *v);
|
|
int sshpkt_put_ec(struct ssh *ssh, const EC_POINT *v, const EC_GROUP *g);
|
|
int sshpkt_put_ec_pkey(struct ssh *ssh, EVP_PKEY *pkey);
|
|
int sshpkt_put_bignum2(struct ssh *ssh, const BIGNUM *v);
|
|
|
|
int sshpkt_get(struct ssh *ssh, void *valp, size_t len);
|
|
int sshpkt_get_u8(struct ssh *ssh, u_char *valp);
|
|
int sshpkt_get_u32(struct ssh *ssh, u_int32_t *valp);
|
|
int sshpkt_get_u64(struct ssh *ssh, u_int64_t *valp);
|
|
int sshpkt_get_string(struct ssh *ssh, u_char **valp, size_t *lenp);
|
|
int sshpkt_get_string_direct(struct ssh *ssh, const u_char **valp, size_t *lenp);
|
|
int sshpkt_peek_string_direct(struct ssh *ssh, const u_char **valp, size_t *lenp);
|
|
int sshpkt_get_cstring(struct ssh *ssh, char **valp, size_t *lenp);
|
|
int sshpkt_getb_froms(struct ssh *ssh, struct sshbuf **valp);
|
|
int sshpkt_get_ec(struct ssh *ssh, EC_POINT *v, const EC_GROUP *g);
|
|
int sshpkt_get_bignum2(struct ssh *ssh, BIGNUM **valp);
|
|
int sshpkt_get_end(struct ssh *ssh);
|
|
void sshpkt_fmt_connection_id(struct ssh *ssh, char *s, size_t l);
|
|
const u_char *sshpkt_ptr(struct ssh *, size_t *lenp);
|
|
|
|
#if !defined(WITH_OPENSSL)
|
|
# undef BIGNUM
|
|
# undef EC_KEY
|
|
# undef EC_GROUP
|
|
# undef EC_POINT
|
|
# undef EVP_PKEY
|
|
#elif !defined(OPENSSL_HAS_ECC)
|
|
# undef EC_KEY
|
|
# undef EC_GROUP
|
|
# undef EC_POINT
|
|
#endif
|
|
|
|
#endif /* PACKET_H */
|