1 /* 2 * ProFTPD - mod_sftp message format 3 * Copyright (c) 2008-2019 TJ Saunders 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. 18 * 19 * As a special exemption, TJ Saunders and other respective copyright holders 20 * give permission to link this program with OpenSSL, and distribute the 21 * resulting executable, without including the source code for OpenSSL in the 22 * source distribution. 23 */ 24 25 #ifndef MOD_SFTP_MSG_H 26 #define MOD_SFTP_MSG_H 27 28 #include "mod_sftp.h" 29 30 char sftp_msg_read_byte(pool *, unsigned char **, uint32_t *); 31 int sftp_msg_read_bool(pool *, unsigned char **, uint32_t *); 32 unsigned char *sftp_msg_read_data(pool *, unsigned char **, uint32_t *, size_t); 33 #ifdef PR_USE_OPENSSL_ECC 34 EC_POINT *sftp_msg_read_ecpoint(pool *, unsigned char **, uint32_t *, 35 const EC_GROUP *, EC_POINT *); 36 #endif /* PR_USE_OPENSSL_ECC */ 37 uint32_t sftp_msg_read_int(pool *, unsigned char **, uint32_t *); 38 uint64_t sftp_msg_read_long(pool *, unsigned char **, uint32_t *); 39 BIGNUM *sftp_msg_read_mpint(pool *, unsigned char **, uint32_t *); 40 char *sftp_msg_read_string(pool *, unsigned char **, uint32_t *); 41 42 /* Variant of the Message Read API whose return value indicates the number 43 * of bytes of the message actually read. A zero-length return value indicates 44 * failure to read the requested data type. 45 */ 46 uint32_t sftp_msg_read_byte2(pool *, unsigned char **, uint32_t *, char *); 47 uint32_t sftp_msg_read_bool2(pool *, unsigned char **, uint32_t *, int *); 48 uint32_t sftp_msg_read_data2(pool *, unsigned char **, uint32_t *, size_t, unsigned char **); 49 #ifdef PR_USE_OPENSSL_ECC 50 uint32_t sftp_msg_read_ecpoint2(pool *, unsigned char **, uint32_t *, 51 const EC_GROUP *, EC_POINT **); 52 #endif /* PR_USE_OPENSSL_ECC */ 53 uint32_t sftp_msg_read_int2(pool *, unsigned char **, uint32_t *, uint32_t *); 54 uint32_t sftp_msg_read_long2(pool *, unsigned char **, uint32_t *, uint64_t *); 55 uint32_t sftp_msg_read_mpint2(pool *, unsigned char **, uint32_t *, BIGNUM **); 56 uint32_t sftp_msg_read_string2(pool *, unsigned char **, uint32_t *, char **); 57 58 uint32_t sftp_msg_write_byte(unsigned char **, uint32_t *, char); 59 uint32_t sftp_msg_write_bool(unsigned char **, uint32_t *, char); 60 uint32_t sftp_msg_write_data(unsigned char **, uint32_t *, 61 const unsigned char *, size_t, int); 62 #ifdef PR_USE_OPENSSL_ECC 63 uint32_t sftp_msg_write_ecpoint(unsigned char **, uint32_t *, const EC_GROUP *, 64 const EC_POINT *); 65 #endif /* PR_USE_OPENSSL_ECC */ 66 uint32_t sftp_msg_write_int(unsigned char **, uint32_t *, uint32_t); 67 uint32_t sftp_msg_write_long(unsigned char **, uint32_t *, uint64_t); 68 uint32_t sftp_msg_write_mpint(unsigned char **, uint32_t *, const BIGNUM *); 69 uint32_t sftp_msg_write_string(unsigned char **, uint32_t *, const char *); 70 71 /* Utility method for obtaining a scratch buffer for constructing SSH2 72 * messages without necessarily needing an SSH2 packet. 73 */ 74 unsigned char *sftp_msg_getbuf(pool *, size_t); 75 76 #endif /* MOD_SFTP_MSG_H */ 77