- Removed options "string" stuff. It was a bad idea...
[tinc] / doc / SECURITY
1 This is the security documentation for tinc, a Virtual Private Network daemon.
2
3    Copyright 2000 Guus Sliepen <guus@sliepen.warande.net>,
4              2000 Ivo Timmmermans <itimmermans@bigfoot.com>
5
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.
9
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.
14
15    $Id: SECURITY,v 1.1.2.2 2000/09/17 20:11:59 guus Exp $
16
17
18 1.  Authentication
19 ------------------
20
21 The authentication protocol (see protocol.c for the up-to-date version) is:
22
23    Client               Server
24    send_id(u)
25                         send_challenge(R)
26    send_chal_reply(H)                   
27                         send_id(u)
28    send_challenge(R)
29                         send_chal_reply(H)
30    ---------------------------------------
31    Any negotations about the meta protocol
32    encryption go here(u).
33    ---------------------------------------
34    send_ack(u)
35                         send_ack(u)
36    ---------------------------------------
37    Other requests(E)...
38
39    (u) Unencrypted,
40    (R) RSA,
41    (H) SHA1,
42    (E) Encrypted with symmetric cipher.
43
44 Authentication in tinc will be done in a way that is very similar to the way
45 the SSH (Secure SHell) authentication protocol works. It is based on public
46 key cryptography.
47
48 Every tinc host has it's own public/private key pair. Suppose there are two
49 tinc hosts, A and B. If A and B trust each other, they store a copy of
50 eachothers public key (in the same way passphrases were stored in versions
51 of tinc <= 1.0pre2). They know these public keys beforehand, and the origin
52 of the public keys has to be known for sure.
53
54 To make sure that when a connection is made from A to B that B knows A is
55 really who he claims to be, B encrypts a totally random string of bytes with
56 A's public key. B also calculates the hash value from the unencrypted random
57 string. B then sends the encrypted string to A. A then has to decrypt the
58 string, calculate the hash value from that string and send it back to B. Since
59 only he who possesses A's private key can decrypt this string, only he can send
60 back the correct hash value. So, if B receives the same hash value he
61 calculated himself, he knows for sure A is A.
62
63 Both SSH and tinc use RSA for the public key cryptography. SSH uses MD5 as a
64 secure hash algorithm, tinc uses SHA1. The reason for our choice of SHA1 is
65 the fact that SHA1 is 160 bits instead of 128 (MD5), which makes brute force
66 attacks harder. Also, the OpenSSL documentation recommends SHA1.
67
68 2.  Key exchange
69 ----------------
70
71 The rest of the meta connection in tinc will be encrypted with a symmetric
72 block cipher, since RSA is not really suited for this. When a connection is
73 made, both sides have to agree on a key for this block cipher. To make sure
74 that this key exchange is also done securely, and no man-in-the-middle attack
75 is possible, RSA would be the best choice for exchanging keys.
76
77 Instead of doing RSA encryption again, tinc will use a part of the random
78 string that was exchanged during the authentication phase as the key for the
79 symmetric cipher. Some symmetric ciphers require a random initialisation vector
80 for improved security. This vector can be taken from the random string as well.
81
82 Is this secure? I (Guus Sliepen) think at this moment that it is:
83
84 - Since the random string cannot be decrypted by anyone eavesdropping or
85   playing man-in-the-middle, the symmetric key cannot be known by sniffing.
86 - The unencrypted returned hash value is supposed to be cryptographically
87   secure. Furthermore, it can only at most give a way 160 bits of information
88   from the complete random string which is longer than the key for the
89   symmetric cipher, so very few bits will actualy contain information about
90   the symmetric cipher key alone, if any.
91 - If the RSA encryption is cracked, the rest of the communications can be
92   decrypted anyway.
93 - If the symmetric cipher encryption is cracked without using the information
94   from the encrypted random strings or the hash values, this still won't give
95   the full plaintext for the random string, so it won't facilitate a known-
96   plaintext attack on the RSA encryption.
97 - RSA and symmetric ciphers are fundamentally different. It is very unlikely
98   that the overlap of both will create any interference that will facilitate
99   an easier-than-brute-force attack.
100
101 Other options for key exchange could be:
102
103 * A second exchange of RSA encrypted random strings.
104   This is equal to the former scheme just without knowing the hash value of
105   the unecrypted random string.
106   
107 * Diffie-Hellman with RSA signing.
108   This should be very secure, but there are a lot of pitholes with using both
109   encryption with public keys and private keys together with the same keypair.
110
111 * Diffie-Hellman with passphrases.
112   This is what tinc <= 1.0pre2 used to do. Passphrases are secret, exchanging
113   them must be done with great care, nobody may eavesdrop. Exchanging public
114   keys on the other hand is much safer, everybody may eavesdrop, just as long
115   as you are sure that the public key itself belongs to the right owner.
116
117 3.  Symmetric cipher
118 --------------------
119
120 Since the generalized encryption functions of OpenSSL are used, any symmetric
121 cipher that is available in OpenSSL could possibly be used. The default however
122 will be Blowfish. Blowfish is widely in use and still has not been cracked
123 today (as far as we know). It also is one of the faster ciphers available.