Prevent SPTPS key regeneration packets from entering an UDP relay path.
authorEtienne Dechamps <etienne@edechamps.fr>
Sun, 17 May 2015 16:09:56 +0000 (17:09 +0100)
committerEtienne Dechamps <etienne@edechamps.fr>
Sun, 17 May 2015 16:09:56 +0000 (17:09 +0100)
commit1e89a63f1638e43dee79afbb18d5f733b27d830b
tree2bda204f23c1048cef0646c123210dccf4ab0575
parenteecfeadeb4fc70ee002b81c20ba12ba3e3acb843
Prevent SPTPS key regeneration packets from entering an UDP relay path.

Commit 10c1f60c643607d9dafd79271c3475cddf81e903 introduced a mechanism
by which a packet received by REQ_KEY could continue its journey over
UDP. This was based on the assumption that REQ_KEY messages would never
be used for handshake packets (which should never be sent over UDP,
because SPTPS currently doesn't handle lost handshake packets very
well).

Unfortunately, there is one case where handshake packets are sent using
REQ_KEY: when regenerating the SPTPS key for a pre-established channel.
With the current code, such packets risk getting relayed over UDP.

When processing a REQ_KEY message, it is impossible for the receiving
end to distinguish between a data SPTPS packet and a handshake packet,
because this information is stored in the type field which is encrypted
with the end-to-end key.

This commit fixes the issue by making tinc use ANS_KEY for all SPTPS
handshake messages. This works because ANS_KEY messages are never
forwarded using the SPTPS relay mechanisms, therefore they are
guaranteed to stick to TCP.
src/net_packet.c