2 sptps.h -- Simple Peer-to-Peer Security
3 Copyright (C) 2011 Guus Sliepen <guus@tinc-vpn.org>,
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.
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.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #define STATE_FIRST_KEX 0 // Waiting for peer's ECDHE pubkey
28 #define STATE_NORMAL 1
29 #define STATE_WAIT_KEX 2 // Waiting for peer's ECDHE pubkey
30 #define STATE_WAIT_ACK 3 // Waiting for peer's acknowledgement of pubkey reception
32 typedef bool (*send_data_t)(void *handle, const char *data, size_t len);
33 typedef bool (*receive_record_t)(void *handle, uint8_t type, const char *data, uint16_t len);
35 typedef struct sptps {
60 send_data_t send_data;
61 receive_record_t receive_record;
64 extern bool start_sptps(sptps_t *s, void *handle, bool initiator, ecdsa_t mykey, ecdsa_t hiskey, const char *label, size_t labellen, send_data_t send_data, receive_record_t receive_record);
65 extern bool stop_sptps(sptps_t *s);
66 extern bool send_record(sptps_t *s, uint8_t type, const char *data, uint16_t len);
67 extern bool receive_data(sptps_t *s, const char *data, size_t len);