X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fsptps.c;h=ed1d952bbb48f94ab542f57dc5f44671084bd5d2;hb=d1ec010660905ae0b99d783737350ccc08b37b16;hp=b907dadf919dc9b6cb4ebfe727f730d6e67d6d00;hpb=6bc8df3e010509f69af95d2cc14ec893def6f644;p=tinc diff --git a/src/sptps.c b/src/sptps.c index b907dadf..ed1d952b 100644 --- a/src/sptps.c +++ b/src/sptps.c @@ -209,7 +209,7 @@ static bool generate_key_material(sptps_t *s, const char *shared, size_t len) { memcpy(seed + 13, s->hiskex + 1, 32); memcpy(seed + 45, s->mykex + 1, 32); } - memcpy(seed + 78, s->label, s->labellen); + memcpy(seed + 77, s->label, s->labellen); // Use PRF to generate the key material if(!prf(shared, len, seed, s->labellen + 64 + 13, s->key, keylen)) @@ -339,7 +339,6 @@ bool sptps_force_kex(sptps_t *s) { // Receive a handshake record. static bool receive_handshake(sptps_t *s, const char *data, uint16_t len) { // Only a few states to deal with handshaking. - fprintf(stderr, "Received handshake message, current state %d\n", s->state); switch(s->state) { case SPTPS_SECONDARY_KEX: // We receive a secondary KEX request, first respond by sending our own. @@ -628,18 +627,17 @@ bool sptps_start(sptps_t *s, void *handle, bool initiator, bool datagram, ecdsa_ // Stop a SPTPS session. bool sptps_stop(sptps_t *s) { // Clean up any resources. + cipher_close(&s->incipher); + cipher_close(&s->outcipher); + digest_close(&s->indigest); + digest_close(&s->outdigest); ecdh_free(&s->ecdh); free(s->inbuf); - s->inbuf = NULL; free(s->mykex); - s->mykex = NULL; free(s->hiskex); - s->hiskex = NULL; free(s->key); - s->key = NULL; free(s->label); - s->label = NULL; free(s->late); - s->late = NULL; + memset(s, 0, sizeof *s); return true; }