1 .\" netsniff-ng - the packet sniffing beast
2 .\" Copyright 2013 Daniel Borkmann.
3 .\" Subject to the GPL, version 2.
5 .TH CURVETUN 8 "03 March 2013" "Linux" "netsniff-ng toolkit"
7 curvetun \- a lightweight curve25519 ip4/6 tunnel
11 \fB curvetun\fR [\fIoptions\fR]
14 curvetun is a lightweight, high-speed ECDH multiuser IP tunnel for Linux
15 that is based on epoll(2). curvetun uses the Linux TUN/TAP interface and
16 supports {IPv4, IPv6} over {IPv4, IPv6} with UDP or TCP as carrier protocols.
18 It has an integrated packet forwarding tree, thus multiple users with
19 different IPs can be handled via a single tunnel device on the server side
20 and flows are scheduled for processing in a CPU efficient way, at least in the
21 case of TCP as the carrier protocol.
23 For key management, public-key cryptography based on elliptic curves are being
24 used and packets are encrypted end-to-end by the symmetric stream cipher
25 Salsa20 and authenticated by the MAC Poly1305, where keys have previously
26 been computed with the ECDH key agreement protocol Curve25519.
28 Cryptography is based on Daniel J. Bernstein's networking and cryptography
29 library \[lq]NaCl\[rq]. By design, curvetun does not provide any particular pattern
30 or default port numbers that gives certainty that the connection from a
31 particular flow is actually running curvetun.
33 However, if you have a further need to bypass censorship, you can try using
34 curvetun in combination with Tor's obfsproxy or Telex. Furthermore, curvetun
35 also protects you against replay attacks and DH man-in-the-middle attacks.
36 Additionally, server-side syslog event logging can also be disabled to avoid
37 revealing critical user connection data.
40 obfsproxy from the TOR project
42 \%https://www.torproject.org/projects/obfsproxy.html.en
46 Telex, anti-censorship in the network infrastructure
53 .SS -d <tundev>, --dev <tundev>
54 Defines the name of the tunnel device that is being created. If this option
55 is not set, then the default names, curves{0,1,2,..} for a curvetun server,
56 and curvec{0,1,2,...} for a curvetun client are used.
58 .SS -p <num>, --port <num>
59 Defines the port the curvetun server should listen on. There is no default port
60 for curvetun, so setting this option for server bootstrap is
61 mandatory. This option is for servers only.
63 .SS -t <server>, --stun <server>
64 If needed, this options enables an STUN lookup in order to show public IP/port
65 mapping and to punch a hole into the firewall. In case you are unsure what STUN
66 server to use, simply use ``\-\-stun stunserver.org''.
68 .SS -c[=alias], --client[=alias]
69 Starts curvetun in client mode and connects to the given connection alias that is
70 defined in the configuration file.
73 Generate private and public keypair. This must be done initially.
76 Export our user and key combination to stdout as a one-liner.
79 Dump all known clients that may connect to the local curvetun server and exit.
82 Dump all known servers we as a client can connect to, and exit.
85 Do not fork off as a client or server on startup.
88 Start curvetun in server mode. Additional parameters are needed, at least
89 the definition of the port clients can connect to.
92 Disable all curvetun logging of possible user information. This can
93 be used for having curvetun users connect more anonymously. This option
97 Use UDP as a carrier protocol instead of TCP. By default TCP is the
98 carrier protocol. This option is for servers only.
101 Defines IPv4 as the underlying network protocol to be used on the tunnel
102 device. IPv4 is default. This option is for servers only.
105 Defines IPv6 as the underlying network protocol to be used on the tunnel
106 device. This option is for servers only.
109 Show version information and exit.
112 Show user help and exit.
116 .SS curvetun --server -4 -u -N --port 6666 --stun stunserver.org
117 Starts curvetun in server mode with IPv4 as network protocol and UDP as a transport
118 carrier protocol. The curvetun server listens for incoming connections on port 6666
119 and performs an STUN lookup on startup to stunserver.org.
121 .SS curvetun --client=ethz
122 Starts curvetun in client mode and connects to the defined connection alias ``ethz''
123 that is defined in the curvetun ~/.curvetun/servers configuration.
125 .SS curvetun --keygen
126 Generates initial keypairs and stores them in ~/.curvetun/.
128 .SS curvetun --export
129 Export user data to stdout for configuration of a curvetun server.
132 Encrypted IP tunnels are often used to create virtual private networks (VPN),
133 where parts of the network can only be reached via an insecure or untrusted medium
134 such as the Internet. Only a few software utilities exist to create such tunnels,
135 or, VPNs. Two popular representatives of such software are OpenVPN and VTUN.
137 The latter also introduced the TUN/TAP interfaces into the Linux kernel. VTUN
138 only has a rather basic encryption module, that does not fit todays
139 cryptographic needs. By default, MD5 is used to create 128-Bit wide keys for
140 the symmetric BlowFish cipher in ECB mode [1].
142 Although OpenSSL is used in both VTUN and OpenVPN, OpenVPN is much more
143 feature rich regarding ciphers and user authentication. Nevertheless, letting
144 people choose ciphers or authentication methods is not necessarily a
145 good thing: administrators could either prefer speed over security and
146 therefore choose weak ciphers, so that the communication system will be as
147 good as without any cipher; they could choose weak passwords for symmetric
148 encryption or they could misconfigure the communication system by having too
149 much choice of ciphers and too little experience for picking the right one.
151 Next to the administration issues, there are also software development issues.
152 Cryptographic libraries like OpenSSL are a huge mess and too low-level and
153 complex to fully understand or correctly apply, so that they form further
154 ground for vulnerabilities of such software.
156 In 2010, the cryptographers Tanja Lange and Daniel J. Bernstein have therefore
157 created and published a cryptography library for networking, which is called
158 NaCl (pronounced ''salt''). NaCl addresses such problems as mentioned in
159 OpenSSL and, in contrast to the rather generic use of OpenSSL, was created
160 with a strong focus on public-key authenticated encryption based on elliptic
161 curve cryptography, which is used in curvetun. Partially quoting Daniel J.
164 "RSA is somewhat older than elliptic-curve cryptography: RSA was introduced
165 in 1977, while elliptic-curve cryptography was introduced in 1985. However,
166 RSA has shown many more weaknesses than elliptic-curve cryptography. RSA's
167 effective security level was dramatically reduced by the linear sieve in the
168 late 1970s, by the quadratic sieve and ECM in the 1980s, and by the
169 number-field sieve in the 1990s. For comparison, a few attacks have been
170 developed against some rare elliptic curves having special algebraic
171 structures, and the amount of computer power available to attackers has
172 predictably increased, but typical elliptic curves require just as much
173 computer power to break today as they required twenty years ago.
175 IEEE P1363 standardized elliptic-curve cryptography in the late 1990s,
176 including a stringent list of security criteria for elliptic curves. NIST
177 used the IEEE P1363 criteria to select fifteen specific elliptic curves at
178 five different security levels. In 2005, NSA issued a new ''Suite B''
179 standard, recommending the NIST elliptic curves (at two specific security
180 levels) for all public-key cryptography and withdrawing previous
181 recommendations of RSA."
183 curvetun uses a particular elliptic curve, Curve25519, introduced in the
184 following paper: Daniel J. Bernstein, ''Curve25519: new Diffie-Hellman speed
185 records,'' pages 207-228 in Proceedings of PKC 2006, edited by Moti Yung,
186 Yevgeniy Dodis, Aggelos Kiayias, and Tal Malkin, Lecture Notes in Computer
187 Science 3958, Springer, 2006, ISBN 3-540-33851-9.
189 This elliptic curve follows all of the standard IEEE P1363 security criteria.
190 It also follows new recommendations that achieve ''side-channel immunity''
191 and ''twist security'' while improving speed. What this means is that secure
192 implementations of Curve25519 are considerably simpler and faster than secure
193 implementations of, for example, NIST P-256; there are fewer opportunities for
194 implementors to make mistakes that compromise security, and mistakes are
195 more easily caught by reviewers.
197 An attacker who spends a billion dollars on special-purpose chips to attack
198 Curve25519, using the best attacks available today, has about 1 chance in
199 1000000000000000000000000000 of breaking Curve25519 after a year of computation.
200 One could achieve similar levels of security with 3000-bit RSA, but
201 encryption and authentication with 3000-bit RSA are not nearly fast enough
202 to handle tunnel traffic and would require much more space in network
206 Security analysis of VTun
208 \%http://www.off.net/~jme/vtun_secu.html
212 NaCl: Networking and Cryptography library
214 \%http://nacl.cr.yp.to/
218 If you haven't run curvetun before, you need to do an initial setup once.
220 First, make sure that the servers and clients clocks are periodically
221 synced, for example, by running an ntp daemon. This is necessary to protect
222 against replay attacks. Also, make sure you have read and write access to
223 /dev/net/tun. You should not run curvetun as root! Then, after you have assured
224 this, the first step is to generate keys and config files. On both the client
229 You are asked for a user name. You can use an email address or whatever suits
230 you. Here, we assume you have entered 'mysrv1' on the server and 'myclient1'
233 Now, all necessary files have been created under ~/.curvetun. Files include
234 \[lq]priv.key\[rq], \[lq]pub.key\[rq], \[lq]username\[rq], \[lq]clients\[rq]
235 and \[lq]servers\[rq].
237 \[lq]clients\[rq] and \[lq]servers\[rq] are empty at the beginning and need
238 to be filled. The \[lq]clients\[rq] file is meant for the server, so that it
239 knows what clients are allowed to connect. The \[lq]servers\[rq] file is for
240 the client, where it can select curvetun servers to connect to. Both files are
241 kept very simple, so that a single configuration line per client or server
244 The client needs to export its public key data for the server
248 where it prints sth like:
250 myclient1;11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11
251 \\_______/ \\_____________________________________________________________________________________________/
252 username 32 byte public key for 'myclient1'
254 This line is transferred to the server admin (yes, we assume a manual on-site
255 key exchange scenario where f.e. the admin sets up server and clients), where
256 the admin then adds this entry into his ``clients'' file like:
258 server$ echo "myclient1;11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:" \\
259 "11:11:11:11:11:11:11:11:11:11:11:11:11:11:11" >> ~/.curvetun/clients
261 The server admin can check, if the server has registered it properly by
265 which prints all parsed clients from ``~/.curvetun/clients''. This process could
266 easily be automated/scripted with f.e. Perl and LDAP.
268 Now, the client ``myclient1'' is known to the server; that's it for the server
269 configuration. The next step is to tell the client where he needs to connect to
272 We assume in this example that the tunnel server has a public IP i.e. 1.2.3.4,
273 runs on port 6666 and uses UDP as a carrier protocol. In case you are behind
274 a NAT, you can use curvetun's ``\-\-stun'' option for starting the server, to
275 obtain your mapping. However, in this example we continue with 1.2.3.4 and 6666,
278 First, the server needs to export its key to the client, as
282 where it prints sth like:
284 mysrv1;22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22
285 \\____/ \\_____________________________________________________________________________________________/
286 username 32 byte public key for 'mysrv1'
287 ^-- you need this public key
289 Thus, you now have the server IP, server port, server transport protocol and the
290 server's public key at hand. Thus, on the client side it can be put all together
293 client$ echo "myfirstserver;1.2.3.4;6666;udp;22:22:22:22:22:22:22:22:22:22:" \\
294 "22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:22:" \\
295 "22:22" >> ~/.curvetun/servers
297 where the client can check its config via:
301 Okay, assuming we've made it, then we start the server with:
303 server$ curvetun \-s \-p 6666 \-u
304 server# ifconfig curves0 up
305 server# ifconfig curves0 10.0.0.1/24
307 Then, we start the client with:
309 client$ curvetun \-c=myfirstserver
310 client# ifconfig curvec0 up
311 client# ifconfig curvec0 10.0.0.2/24
313 Also, client-side information, errors or warnings will appear in syslog! By now
314 we should be able to ping the server:
316 client$ ping 10.0.0.1
318 That's it! Routing example:
320 Server side's public IP on eth0 is i.e. 1.2.3.4:
322 server$ ... start curvetun server ...
323 server# ifconfig curves0 up
324 server# ifconfig curves0 10.0.0.1/24
325 server# echo 1 > /proc/sys/net/ipv4/ip_forward
326 server# iptables \-t nat \-A POSTROUTING \-o eth0 \-j MASQUERADE
327 server# iptables \-A FORWARD \-i eth0 \-o curves0 \-m state \-\-state RELATED,ESTABLISHED \-j ACCEPT
328 server# iptables \-A FORWARD \-i curves0 \-o eth0 \-j ACCEPT
330 Client side's IP on eth0 is i.e. 5.6.7.8:
332 client$ ... start curvetun client ...
333 client# ... lookup your default gateway (e.g. via route, here: 5.6.7.9) ...
334 client# ifconfig curvec0 up
335 client# ifconfig curvec0 10.0.0.2/24
336 client# route add \-net 1.2.3.0 netmask 255.255.255.0 gw 5.6.7.9 dev eth0
337 client# route add default gw 10.0.0.1
338 client# route del default gw 5.6.7.9
340 That should be it, happy browsing and emailing via curvetun tunnels!
343 This software is an experimental prototype intended for researchers. It will most
344 likely mature over time, but it is currently not advised to use this software
345 when life is put at risk.
348 Blackhole tunneling is currently not supported.
351 curvetun is licensed under the GNU GPL version 2.0.
355 was originally written for the netsniff-ng toolkit by Daniel Borkmann. It is
356 currently maintained by Tobias Klauser <tklauser@distanz.ch> and Daniel
357 Borkmann <dborkma@tik.ee.ethz.ch>.
369 Manpage was written by Daniel Borkmann.