X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;ds=sidebyside;f=src%2Fsptps.c;h=395c92fc540f38897fe71a80869056e75fcb62c0;hb=483c5dcfb43719e5fd50902641252e28a04fd74e;hp=6668763a939e74c5fbeff774926893f4397184ab;hpb=efd21e232dced3225f119aeb7a585ebf55b7cf77;p=tinc diff --git a/src/sptps.c b/src/sptps.c index 6668763a..395c92fc 100644 --- a/src/sptps.c +++ b/src/sptps.c @@ -27,9 +27,6 @@ #include "prf.h" #include "sptps.h" -char *logfilename; -#include "utils.c" - /* Nonce MUST be exchanged first (done) Signatures MUST be done over both nonces, to guarantee the signature is fresh @@ -60,7 +57,6 @@ static bool error(sptps_t *s, int s_errno, const char *msg) { // Send a record (private version, accepts all record types, handles encryption and authentication). static bool send_record_priv(sptps_t *s, uint8_t type, const char *data, uint16_t len) { char buffer[len + 23UL]; - //char ciphertext[len + 19]; // Create header with sequence number, length and record type uint32_t seqno = htonl(s->outseqno++); @@ -89,7 +85,7 @@ static bool send_record_priv(sptps_t *s, uint8_t type, const char *data, uint16_ } // Send an application record. -bool send_record(sptps_t *s, uint8_t type, const char *data, uint16_t len) { +bool sptps_send_record(sptps_t *s, uint8_t type, const char *data, uint16_t len) { // Sanity checks: application cannot send data before handshake is finished, // and only record types 0..127 are allowed. if(!s->outstate) @@ -292,7 +288,7 @@ static bool receive_sig(sptps_t *s, const char *data, uint16_t len) { } // Force another Key EXchange (for testing purposes). -bool force_kex(sptps_t *s) { +bool sptps_force_kex(sptps_t *s) { if(!s->outstate || s->state != SPTPS_SECONDARY_KEX) return error(s, EINVAL, "Cannot force KEX in current state"); @@ -326,6 +322,7 @@ static bool receive_handshake(sptps_t *s, const char *data, uint16_t len) { // We expect a handshake message to indicate transition to the new keys. if(!receive_ack(s, data, len)) return false; + s->receive_record(s->handle, SPTPS_HANDSHAKE, NULL, 0); s->state = SPTPS_SECONDARY_KEX; return true; // TODO: split ACK into a VERify and ACK? @@ -335,7 +332,7 @@ static bool receive_handshake(sptps_t *s, const char *data, uint16_t len) { } // Receive incoming data. Check if it contains a complete record, if so, handle it. -bool receive_data(sptps_t *s, const char *data, size_t len) { +bool sptps_receive_data(sptps_t *s, const char *data, size_t len) { while(len) { // First read the 2 length bytes. if(s->buflen < 6) { @@ -425,7 +422,7 @@ bool receive_data(sptps_t *s, const char *data, size_t len) { } // Start a SPTPS session. -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) { +bool sptps_start(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) { // Initialise struct sptps memset(s, 0, sizeof *s); @@ -456,7 +453,7 @@ bool start_sptps(sptps_t *s, void *handle, bool initiator, ecdsa_t mykey, ecdsa_ } // Stop a SPTPS session. -bool stop_sptps(sptps_t *s) { +bool sptps_stop(sptps_t *s) { // Clean up any resources. ecdh_free(&s->ecdh); free(s->inbuf);