1 This is the security documentation for tinc, a Virtual Private Network daemon.
3 Copyright 2000 Guus Sliepen <guus@sliepen.warande.net>,
4 2000 Ivo Timmmermans <itimmermans@bigfoot.com>
6 Permission is granted to make and distribute verbatim copies of
7 this documentation provided the copyright notice and this
8 permission notice are preserved on all copies.
10 Permission is granted to copy and distribute modified versions of
11 this documentation under the conditions for verbatim copying,
12 provided that the entire resulting derived work is distributed
13 under the terms of a permission notice identical to this one.
15 $Id: SECURITY,v 1.1.2.3 2000/09/25 20:08:50 guus Exp $
21 The authentication protocol (see protocol.c for the up-to-date version) is:
30 ---------------------------------------
31 Any negotations about the meta protocol
32 encryption go here(u).
33 ---------------------------------------
36 ---------------------------------------
42 (E) Encrypted with symmetric cipher.
44 See section 4 for a detailed example version of the authentication.
46 Authentication in tinc will be done in a way that is very similar to the way
47 the SSH (Secure SHell) authentication protocol works. It is based on public
50 Every tinc host has its own public/private key pair. Suppose there are two
51 tinc hosts, A and B. If A and B trust each other, they store a copy of
52 eachothers public key (in the same way passphrases were stored in versions
53 of tinc <= 1.0pre2). They know these public keys beforehand, and the origin
54 of the public keys has to be known for sure.
56 To make sure that when a connection is made from A to B that B knows A is
57 really who he claims to be, B encrypts a totally random string of bytes with
58 A's public key. B also calculates the hash value from the unencrypted random
59 string. B then sends the encrypted string to A. A then has to decrypt the
60 string, calculate the hash value from that string and send it back to B. Since
61 only he who possesses A's private key can decrypt this string, only he can send
62 back the correct hash value. So, if B receives the same hash value he
63 calculated himself, he knows for sure A is A.
65 Both SSH and tinc use RSA for the public key cryptography. SSH uses MD5 as a
66 secure hash algorithm, tinc uses SHA1. The reason for our choice of SHA1 is
67 the fact that SHA1 is 160 bits instead of 128 (MD5), which makes brute force
68 attacks harder. Also, the OpenSSL documentation recommends SHA1.
73 The rest of the meta connection in tinc will be encrypted with a symmetric
74 block cipher, since RSA is not really suited for this. When a connection is
75 made, both sides have to agree on a key for this block cipher. To make sure
76 that this key exchange is also done securely, and no man-in-the-middle attack
77 is possible, RSA would be the best choice for exchanging keys.
79 Instead of doing RSA encryption again, tinc will use a part of the random
80 string that was exchanged during the authentication phase as the key for the
81 symmetric cipher. Some symmetric ciphers require a random initialisation vector
82 for improved security. This vector can be taken from the random string as well.
84 Is this secure? I (Guus Sliepen) think at this moment that it is:
86 - Since the random string cannot be decrypted by anyone eavesdropping or
87 playing man-in-the-middle, the symmetric key cannot be known by sniffing.
88 - The unencrypted returned hash value is supposed to be cryptographically
89 secure. Furthermore, it can only at most give a way 160 bits of information
90 from the complete random string which is longer than the key for the
91 symmetric cipher, so very few bits will actualy contain information about
92 the symmetric cipher key alone, if any.
93 - If the RSA encryption is cracked, the rest of the communications can be
95 - If the symmetric cipher encryption is cracked without using the information
96 from the encrypted random strings or the hash values, this still won't give
97 the full plaintext for the random string, so it won't facilitate a known-
98 plaintext attack on the RSA encryption.
99 - RSA and symmetric ciphers are fundamentally different. It is very unlikely
100 that the overlap of both will create any interference that will facilitate
101 an easier-than-brute-force attack.
103 Other options for key exchange could be:
105 * A second exchange of RSA encrypted random strings.
106 This is equal to the former scheme just without knowing the hash value of
107 the unecrypted random string. Information theory tells that two seperate
108 RSA messages are as secure as one if the total amount of bits sent is the
109 same, so enlarging the challenge will make one exchange just as secure as
110 two seperate exchanges.
112 * Diffie-Hellman with RSA signing.
113 This should be very secure, but there are a lot of pitfalls with using both
114 encryption with public keys and private keys together with the same keypair.
116 * Diffie-Hellman with passphrases.
117 This is what tinc <= 1.0pre2 used to do. Passphrases are secret, exchanging
118 them must be done with great care, nobody may eavesdrop. Exchanging public
119 keys on the other hand is much safer, everybody may eavesdrop, just as long
120 as you are sure that the public key itself belongs to the right owner.
125 Since the generalized encryption functions of OpenSSL are used, any symmetric
126 cipher that is available in OpenSSL could possibly be used. The default however
127 will be Blowfish. Blowfish is widely in use and still has not been cracked
128 today (as far as we know). It also is one of the faster ciphers available.
130 4. Detailed "example" of communication
131 ---------------------------------------
133 Tinc uses a peer-to-peer protocol, but during the authentication phase we will
134 make a distinction between a server (a tinc daemon listening for incoming
135 connections) and a client (a tinc daemon that is trying to connect to the tinc
136 daemon playing server).
138 The message strings here are kept short for clarity. The real length of the
139 exchanged messages is indicated. The capital words ID, CHALLENGE, CHAL_REPLY
140 and ACK are in reality replaced by the numbers 1, 2, 3 and 4 respectively.
143 --------------------------------------------------------------------------
144 server <listening for connection>
145 client <tries to connect>
146 server <accepts connection>
150 +-------> name of tinc daemon
151 server CHALLENGE 57fb4b2ccd70d6bb35a64c142f47e61d
153 | +----> 64 bits initial vector and
154 +-----------> 448 bits symmetric cipher key for meta
155 data sent to the server
156 \______________________________/
157 +-> 2048 bits totally random string, encrypted
158 with client's public RSA key
159 client CHAL_REPLY 191e23
160 +-> 160 bits SHA1 value of the complete decrypted
161 CHALLENGE sent by the server
165 +-------> name of tinc daemon
166 client CHALLENGE da02add1817c1920989ba6ae2a49cecb
168 | +----> 64 bits initial vector and
169 +-----------> 448 bits symmetric cipher key for meta
170 data sent to the client
171 \______________________________/
172 +-> 2048 bits totally random string, encrypted
173 with server's public RSA key
174 server CHAL_REPLY 2bdeed
175 +-> 160 bits SHA1 value of the complete decrypted
176 CHALLENGE sent by the client
179 --------------------------------------------------------------------------
181 When the server receives the ACK from the client, it should prepare itself
182 for the fact that any subsequent data will be encrypted with the key the server
183 sent itself in the CHALLENGE. Ofcourse, this key is taken from the decrypted
184 version of that CHALLENGE, so that we will know for sure only the real client
185 can send us messages. The same goes for the client when it receives an ACK.