1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
/*
20140108
Jan Mojzis
Public domain.
*/
#ifndef PACKET_H____
#define PACKET_H____
#include "buf.h"
#include "crypto_uint32.h"
#include "crypto_uint8.h"
#include "sshcrypto.h"
#include "limit.h"
#include "channel.h"
#define PACKET_UNAUTHENTICATED_MESSAGES 30
#define PACKET_LIMIT 32768
#define PACKET_FULLLIMIT 35000
#define PACKET_RECVLIMIT 131072
#define PACKET_ZEROBYTES 64
struct packet {
/* flags */
int flagkeys;
int flagauthorized;
int flagrekeying;
/* channel */
int flageofsent;
int flagclosesent;
int flagchanneleofreceived;
/* packet id */
crypto_uint32 sendpacketid;
crypto_uint32 receivepacketid;
/* keys */
unsigned char serverkey[sshcrypto_cipher_KEYMAX];
unsigned char clientkey[sshcrypto_cipher_KEYMAX];
unsigned char servermackey[sshcrypto_cipher_KEYMAX];
unsigned char clientmackey[sshcrypto_cipher_KEYMAX];
unsigned char servernonce[sshcrypto_cipher_KEYMAX];
unsigned char clientnonce[sshcrypto_cipher_KEYMAX];
unsigned char sessionid[sshcrypto_hash_MAX];
char name[LOGIN_NAME_MAX + 1];
crypto_uint8 kex_packet_follows;
crypto_uint8 kex_guess;
/* buffers */
unsigned char hellosendspace[256];
unsigned char helloreceivespace[256];
unsigned char kexsendspace[1024];
unsigned char kexrecvspace[65536];
unsigned char hashbufspace[65536];
struct buf hellosend;
struct buf helloreceive;
struct buf kexsend;
struct buf kexrecv;
struct buf hashbuf;
/* send/recv */
unsigned char recvbufspace[4 * PACKET_FULLLIMIT + 1 + PACKET_ZEROBYTES];
unsigned char sendbufspace[4 * PACKET_FULLLIMIT + 1];
struct buf recvbuf;
struct buf sendbuf;
crypto_uint32 packet_length;
};
/* packet.c */
extern struct packet packet;
extern void packet_purge(void);
extern void packet_init(void);
/* packet_send.c */
extern int packet_sendisready(void);
extern int packet_send(void);
extern int packet_sendall(void);
/* packet_recv.c */
extern int packet_recvisready(void);
extern int packet_recv(void);
/* packet_get.c */
extern int packet_get(struct buf *, crypto_uint8);
extern int packet_getall(struct buf *, crypto_uint8);
/* packet_put.c */
extern void packet_put(struct buf *);
extern int packet_putisready(void);
/* packet_hello.c */
extern int packet_hello_send(void);
extern int packet_hello_receive(void);
/* packet_kex.c */
extern int packet_kex_send(void);
extern int packet_kex_receive(void);
/* packet_kexdh.c */
extern int packet_kexdh(const char *, struct buf *, struct buf *);
/* packet_auth.c */
extern int packet_auth(struct buf *, struct buf *, int);
/* packet_channel_open.c */
extern int packet_channel_open(struct buf *, struct buf *);
/* packet_channel_request.c */
extern int packet_channel_request(struct buf *, struct buf *, const char *);
/* packet_channel_recv.c */
extern int packet_channel_recv_data(struct buf *);
extern int packet_channel_recv_extendeddata(struct buf *);
extern int packet_channel_recv_windowadjust(struct buf *);
extern int packet_channel_recv_eof(struct buf *);
extern int packet_channel_recv_close(struct buf *);
/* packet_channel_send.c */
extern void packet_channel_send_data(struct buf *);
extern void packet_channel_send_extendeddata(struct buf *);
extern int packet_channel_send_windowadjust(struct buf *);
extern void packet_channel_send_eof(struct buf *);
extern int packet_channel_send_close(struct buf *, int, int);
/* packet_unimplemented.c */
extern int packet_unimplemented(struct buf *);
#endif
|