Commit graph

2198 commits

Author SHA1 Message Date
Guus Sliepen
67ff81ec16 Test corner cases in the SPTPS protocol.
* Test zero-byte messages.
* Test maximum size (65535 byte) messages.
* Test different message types.
* Test key renegotiation.
2011-10-05 22:05:13 +02:00
Guus Sliepen
3001351150 Update SPTPS protocol.
* Exchange nonce and ECDH public key first, calculate the ECDSA signature
  over the complete key exchange.
* Make an explicit distinction between client and server in the signatures.
* Add more comments and replace some magic numbers by #defines.

Thanks to Erik Tews for very helpful hints and comments!
2011-10-05 22:00:51 +02:00
Guus Sliepen
810847248a Fix compiler warning. 2011-10-05 21:59:33 +02:00
Guus Sliepen
ddea7a23a6 Return false instead of void when there is an error. 2011-08-30 20:49:48 +02:00
Guus Sliepen
e838289683 Prevent read_rsa_public_key() from returning an uninitialized RSA structure.
In case the config file could not be opened a new but unitialized RSA structure
would be returned, causing a segmentation fault later on. This would only
happen in the case that the config file could be opened before, but not when
read_rsa_public_key() was called. This situation could occur when the --user
option was used, and the config files were not readable by the specified user.
2011-08-30 20:04:18 +02:00
Guus Sliepen
5d4336e542 Handle UDP packets with unknown source addresses properly.
Probably due to a merge, the try_harder() function had duplicated the
rate-limiting code for detecting the sender node based on the HMAC of the
packet. This prevented this detection from running at all. The function is now
identical again to that in the 1.0 branch.
2011-08-10 17:04:17 +02:00
Michael Tokarev
bbc0ba9e87 use execvp() not execve() in tincctl start
sometimes argv[0] will have directory-less name (when the
command is started by shell searching in $PATH for example).
For tincctl start we want the same rules to run tincd as for
tincctl itself (having full path is better but if shell does
not provide one we've no other choice).  Previous code tried
to run ./tincd in this case, which is obviously wrong.

This is a fix for the previous commit.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2011-08-07 10:51:21 +02:00
Michael Tokarev
a7556a9d2c run tincd from the same directory as tincctl and pass all options to it
For tincctl start, run tincd from dirname($0) not SBINDIR -
this allows painless alternative directory installation and
running from build directory too.

Also while at it, pass the rest of command line to tincd, not
only options before "start" argument.  This way it's possible
to pass options to tincd like this:
  tincctl -n net start -- -d 1 -R -U tincuser ...

And also add missing newline at the end of error message there.

Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru>
2011-08-07 10:12:43 +02:00
Michael Tokarev
2696ad2cca don't mention reload twice in tincctl help
Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru>
2011-08-07 10:12:38 +02:00
Guus Sliepen
3d75dbc088 Start of "Simple Peer-To-Peer Security" protocol.
Encryption and authentication of the meta connection is spread out over
meta.c and protocol_auth.c. The new protocol was added there as well,
leading to spaghetti code. To improve things, the new protocol will now
be implemented in sptps.[ch].

The goal is to have a very simplified version of TLS. There is a record
layer, and there are only two record types: application data and
handshake messages. The handshake message contains a random nonce, an
ephemeral ECDH public key, and an ECDSA signature over the former. After
the ECDH public keys are exchanged, a shared secret is calculated, and a
TLS style PRF is used to generate the key material for the cipher and
HMAC algorithm, and further communication is encrypted and authenticated.

A lot of the simplicity comes from the fact that both sides must have
each other's public keys in advance, and there are no options to choose.
There will be one fixed cipher suite, and both peers always authenticate
each other. (Inspiration taken from Ian Grigg's hypotheses[0].)
There might be some compromise in the future, to enable or disable
encryption, authentication and compression, but there will be no choice
of algorithms. This will allow SPTPS to be built with a few embedded
crypto algorithms instead of linking with huge crypto libraries.

The API is also kept simple. There is a start and a stop function. All
data necessary to make the connection work is passed in the start
function. Instead having both send- and receive-record functions, there
is a send-record function and a receive-data function. The latter will
pass protocol data received from the peer to the SPTPS implementation,
which will in turn call a receive-record callback function when
necessary. This hides all the handshaking from the application, and is
completely independent from any event loop or socket characteristics.

[0] http://iang.org/ssl/hn_hypotheses_in_secure_protocol_design.html
2011-07-24 15:44:51 +02:00
Guus Sliepen
0f2aa4bd8b Releasing 1.0.16. 2011-07-23 14:12:23 +02:00
Guus Sliepen
e16ead8dd9 Use usleep() instead of sleep(), MinGW complained. 2011-07-23 14:11:44 +02:00
Guus Sliepen
ff751903aa Don't abort() on low-level crypto errors, just return false.
The abort() calls were accidentily left in for debugging.
2011-07-20 08:19:18 +02:00
Guus Sliepen
2f4ccfe247 Fix tinc 1.0.x daemons connecting when ExperimentalProtocol = yes. 2011-07-19 21:11:11 +02:00
Guus Sliepen
f8d94f34fc Releasing 1.1pre2. 2011-07-17 20:09:08 +02:00
Guus Sliepen
c259d552fa Add missing newline. 2011-07-17 20:06:06 +02:00
Guus Sliepen
f6020a5224 Write loopback address instead of "any" address in pidfile. 2011-07-17 20:01:24 +02:00
Guus Sliepen
50fcfea127 Flush output buffer in send_tcppacket().
This is mainly important for Windows, where the select() call in the
main thread is not being woken up when the tapreader thread calls
route(), causing a delay of up to 1 second before the output buffer is
flushed. This would cause bad performance when UDP communication is not
possible.
2011-07-17 19:34:01 +02:00
Guus Sliepen
25091454da "tincctl stop" now removes the tinc service on Windows. 2011-07-17 19:23:52 +02:00
Guus Sliepen
c6c989cfa1 Fix declaration of usleep(). 2011-07-17 18:02:56 +02:00
Guus Sliepen
18e9839dc8 Ensure symlinked files do not end up in the tarball. 2011-07-17 10:59:54 +02:00
Guus Sliepen
fa4a01e4a2 Use const pointer to source in base64 and hex routines. 2011-07-16 22:38:50 +02:00
Guus Sliepen
574b380dfc Use usleep() instead of sleep(), MinGW complained. 2011-07-16 22:38:22 +02:00
Guus Sliepen
8efc8dc961 Update info manual. 2011-07-16 21:44:17 +02:00
Guus Sliepen
cff27a258f Use ECDSA to sign ECDH key exchange for UDP session keys.
The ECDSA public keys will also be included in the ANS_KEY requests,
but are only used when no ECDSA public key is known yet.
2011-07-16 20:21:44 +02:00
Guus Sliepen
03ac48ea19 Use the same logic as tinc 1.0.x for detecting two nodes with the same Name. 2011-07-16 15:21:37 +02:00
Guus Sliepen
2ba61742d4 Use the correct direction flag when setting cipher keys.
The flag was set incorrectly, but for most ciphers this does not have
any effect. AES in any of the block modes is picky about it though.
2011-07-16 15:15:29 +02:00
Guus Sliepen
be2fc8b045 Make code to detect two nodes with the same Name less triggerhappy.
First of all, if there really are two nodes with the same name, much
more than 10 contradicting ADD_EDGE and DEL_EDGE messages will be sent.
Also, we forgot to reset the counters when nothing happened.

In case there is a ADD_EDGE/DEL_EDGE storm, we do not shut down, but
sleep an increasing amount of time, allowing tinc to recover gracefully
from temporary failures.
2011-07-16 10:47:35 +02:00
Guus Sliepen
303dd1e702 Fix compiler warnings. 2011-07-13 22:52:52 +02:00
Guus Sliepen
791c1898ea Remove unnecessary variables and functions. 2011-07-13 22:31:53 +02:00
Guus Sliepen
fec279a9c5 Make use of the improved hex and base64 functions.
Also, use base64 for all EC related data, it is shorter and easy to
distinguish from the legacy protocol.
2011-07-12 23:43:12 +02:00
Guus Sliepen
06b8271ed5 Make hexadecimal and base64 routines behave the same.
The length parameter for the encoding functions is the length of the
binary input, and for the decoding functions it is the maximum size of
the binary output.

The return value is always the length of the resulting output, excluding
the terminating NULL character for the encoding routines.

All functions can encode and decode in-place. The encoding functions
will always write a terminating NULL character, and the decoding
functions will stop at a NULL character.
2011-07-12 23:23:26 +02:00
Guus Sliepen
c108c79a22 Don't use wildcards in filenames in configure.in. 2011-07-11 22:14:06 +02:00
Guus Sliepen
bbeab00f46 Require ExperimentalProtocol = yes for new features, update documentation. 2011-07-11 21:54:01 +02:00
Guus Sliepen
d1cd3c8145 Close meta connection socket after cleaning up event structures.
Epoll doesn't like it when an already closed filedescriptor is being
removed, so we defer closing the socket until after all else is cleaned
up.
2011-07-10 22:46:43 +02:00
Guus Sliepen
30ef2a981e Automatically exchange ECDSA keys and upgrade to new authentication protocol.
If we don't have ECDSA keys for the node we connect to, set protocol_minor
to 1, to indicate this to the other end. This will first complete the
old way of authentication with RSA keys, and will then exchange ECDSA keys.
The connection will be terminated right afterwards, and the next attempt
will use ECDSA keys.
2011-07-10 22:34:17 +02:00
Guus Sliepen
027228debe Free ECDSA and RSA structures when freeing a connection_t. 2011-07-10 21:04:31 +02:00
Guus Sliepen
73863fab8a Hash input before signing it with ECDSA. 2011-07-08 18:17:34 +02:00
Guus Sliepen
8132be8fbd Very primitive ECDSA signed ECDH key exchange for the meta protocol.
Nonces and hash of the ID requests should be included in the seed for the PRF.
2011-07-07 22:30:55 +02:00
Guus Sliepen
210b5ceeee Read ECDSA keys. 2011-07-07 22:28:25 +02:00
Guus Sliepen
03582eb669 Implement ECDSA sign and verify operations.
Very basic at the moment, doesn't hash the input first,
and uses OpenSSL's DER encoded signature as output.
2011-07-07 22:27:17 +02:00
Guus Sliepen
86d83bd9bd Bump minor protocol to indicate ECDH capability for UDP session keys. 2011-07-05 21:29:31 +02:00
Guus Sliepen
9708bbfa8e Add a minor number to the protocol version. 2011-07-05 21:19:48 +02:00
Guus Sliepen
b99656d84a Round up the size of the secret parts after splitting it in two. 2011-07-04 07:51:47 +02:00
Guus Sliepen
95e1cc36d3 Add ECDSA key import. 2011-07-03 23:44:43 +02:00
Guus Sliepen
1e2d9b0899 Finish base64 decoding routine. 2011-07-03 23:33:56 +02:00
Guus Sliepen
80b81c00b1 Have tincctl generate ECDSA keys.
The generate-keys command now generates both an RSA and an ECDSA keypair,
but one can generate-rsa-keys or generate-ecdsa-keys to just generate one type.
2011-07-03 22:25:29 +02:00
Guus Sliepen
8ace7f3e57 Add ECDSA key generation. 2011-07-03 22:15:00 +02:00
Guus Sliepen
1d92dd62a7 Base64 encoding and decoding functions. 2011-07-03 22:13:58 +02:00
Guus Sliepen
c385d11533 Cleanups in ECDH code. 2011-07-03 22:13:34 +02:00