1263970Sdes/* $OpenBSD: packet.h,v 1.59 2013/07/12 00:19:59 djm Exp $ */ 2224638Sbrooks/* $FreeBSD$ */ 392559Sdes 457429Smarkm/* 557429Smarkm * Author: Tatu Ylonen <ylo@cs.hut.fi> 657429Smarkm * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 757429Smarkm * All rights reserved 857429Smarkm * Interface for the packet protocol functions. 960576Skris * 1065674Skris * As far as I am concerned, the code I have written for this software 1165674Skris * can be used freely for any purpose. Any derived versions of this 1265674Skris * software must be clearly marked as such, and if the derived work is 1365674Skris * incompatible with the protocol description in the RFC file, it must be 1465674Skris * called by a name other than "ssh" or "Secure Shell". 1557429Smarkm */ 1657429Smarkm 1757429Smarkm#ifndef PACKET_H 1857429Smarkm#define PACKET_H 1957429Smarkm 20162856Sdes#include <termios.h> 21162856Sdes 2257464Sgreen#include <openssl/bn.h> 23221420Sdes#ifdef OPENSSL_HAS_ECC 24221420Sdes#include <openssl/ec.h> 25221420Sdes#endif 2657429Smarkm 2792559Sdesvoid packet_set_connection(int, int); 28181111Sdesvoid packet_set_timeout(int, int); 2992559Sdesvoid packet_set_nonblocking(void); 3092559Sdesint packet_get_connection_in(void); 3192559Sdesint packet_get_connection_out(void); 3292559Sdesvoid packet_close(void); 3392559Sdesvoid packet_set_encryption_key(const u_char *, u_int, int); 3498684Sdesu_int packet_get_encryption_key(u_char *); 3592559Sdesvoid packet_set_protocol_flags(u_int); 3692559Sdesu_int packet_get_protocol_flags(void); 3792559Sdesvoid packet_start_compression(int); 38221420Sdesvoid packet_set_interactive(int, int, int); 3992559Sdesint packet_is_interactive(void); 40149753Sdesvoid packet_set_server(void); 41149753Sdesvoid packet_set_authenticated(void); 42224638Sbrooks#ifdef NONE_CIPHER_ENABLED 43224638Sbrooksint packet_get_authentication_state(void); 44224638Sbrooks#endif 4557429Smarkm 4692559Sdesvoid packet_start(u_char); 4792559Sdesvoid packet_put_char(int ch); 4892559Sdesvoid packet_put_int(u_int value); 49197679Sdesvoid packet_put_int64(u_int64_t value); 5092559Sdesvoid packet_put_bignum(BIGNUM * value); 5192559Sdesvoid packet_put_bignum2(BIGNUM * value); 52221420Sdes#ifdef OPENSSL_HAS_ECC 53221420Sdesvoid packet_put_ecpoint(const EC_GROUP *, const EC_POINT *); 54221420Sdes#endif 5592559Sdesvoid packet_put_string(const void *buf, u_int len); 5692559Sdesvoid packet_put_cstring(const char *str); 5792559Sdesvoid packet_put_raw(const void *buf, u_int len); 5892559Sdesvoid packet_send(void); 5957429Smarkm 6092559Sdesint packet_read(void); 6192559Sdesvoid packet_read_expect(int type); 6292559Sdesvoid packet_process_incoming(const char *buf, u_int len); 6392559Sdesint packet_read_seqnr(u_int32_t *seqnr_p); 6492559Sdesint packet_read_poll_seqnr(u_int32_t *seqnr_p); 6557429Smarkm 6692559Sdesu_int packet_get_char(void); 6792559Sdesu_int packet_get_int(void); 68197679Sdesu_int64_t packet_get_int64(void); 6992559Sdesvoid packet_get_bignum(BIGNUM * value); 7092559Sdesvoid packet_get_bignum2(BIGNUM * value); 71221420Sdes#ifdef OPENSSL_HAS_ECC 72221420Sdesvoid packet_get_ecpoint(const EC_GROUP *, EC_POINT *); 73221420Sdes#endif 74149753Sdesvoid *packet_get_raw(u_int *length_ptr); 7592559Sdesvoid *packet_get_string(u_int *length_ptr); 76221420Sdeschar *packet_get_cstring(u_int *length_ptr); 77181111Sdesvoid *packet_get_string_ptr(u_int *length_ptr); 78263970Sdesvoid packet_disconnect(const char *fmt,...) __attribute__((noreturn)) __attribute__((format(printf, 1, 2))); 7992559Sdesvoid packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2))); 8057429Smarkm 8198684Sdesvoid set_newkeys(int mode); 8298684Sdesint packet_get_keyiv_len(int); 8398684Sdesvoid packet_get_keyiv(int, u_char *, u_int); 8498684Sdesint packet_get_keycontext(int, u_char *); 8598684Sdesvoid packet_set_keycontext(int, u_char *); 86181111Sdesvoid packet_get_state(int, u_int32_t *, u_int64_t *, u_int32_t *, u_int64_t *); 87181111Sdesvoid packet_set_state(int, u_int32_t, u_int64_t, u_int32_t, u_int64_t); 8898684Sdesint packet_get_ssh1_cipher(void); 8998684Sdesvoid packet_set_iv(int, u_char *); 90197679Sdesvoid *packet_get_newkeys(int); 9198684Sdes 9292559Sdesvoid packet_write_poll(void); 9392559Sdesvoid packet_write_wait(void); 9492559Sdesint packet_have_data_to_write(void); 9592559Sdesint packet_not_very_much_data_to_write(void); 9657429Smarkm 9792559Sdesint packet_connection_is_on_socket(void); 9892559Sdesint packet_remaining(void); 9992559Sdesvoid packet_send_ignore(int); 10092559Sdesvoid packet_add_padding(u_char); 10157429Smarkm 10292559Sdesvoid tty_make_modes(int, struct termios *); 10392559Sdesvoid tty_parse_modes(int, int *); 10457429Smarkm 105197679Sdesvoid packet_set_alive_timeouts(int); 106197679Sdesint packet_inc_alive_timeouts(void); 107137019Sdesint packet_set_maxsize(u_int); 108197679Sdesu_int packet_get_maxsize(void); 10957429Smarkm 11092559Sdes/* don't allow remaining bytes after the end of the message */ 11192559Sdes#define packet_check_eom() \ 11257429Smarkmdo { \ 11360576Skris int _len = packet_remaining(); \ 11460576Skris if (_len > 0) { \ 115124211Sdes logit("Packet integrity error (%d bytes remaining) at %s:%d", \ 11660576Skris _len ,__FILE__, __LINE__); \ 11760576Skris packet_disconnect("Packet integrity error."); \ 11860576Skris } \ 11960576Skris} while (0) 12060576Skris 121124211Sdesint packet_need_rekeying(void); 122224638Sbrooks#ifdef NONE_CIPHER_ENABLED 123224638Sbrooksvoid packet_request_rekeying(void); 124224638Sbrooks#endif 125263970Sdesvoid packet_set_rekey_limits(u_int32_t, time_t); 126263970Sdestime_t packet_get_rekey_timeout(void); 127124211Sdes 128197679Sdesvoid packet_backup_state(void); 129197679Sdesvoid packet_restore_state(void); 130197679Sdes 131197679Sdesvoid *packet_get_input(void); 132197679Sdesvoid *packet_get_output(void); 133197679Sdes 13457429Smarkm#endif /* PACKET_H */ 135