chiark / gitweb /
e58c28cf4acf665473cbffeb30b1c03eeab65dbb
[tripe] / doc / tripe.8.in
1 .\" -*-nroff-*-
2 .\".
3 .de hP
4 .IP
5 \h'-\w'\fB\\$1\ \fP'u'\fB\\$1\ \fP\c
6 ..
7 .de VS
8 .sp 1
9 .RS
10 .nf
11 .ft B
12 ..
13 .de VE
14 .ft R
15 .fi
16 .RE
17 .sp 1
18 ..
19 .ie t \{\
20 .  ds o \(bu
21 .  ds ss \s8\u
22 .  ds se \d\s0
23 .  if \n(.g \{\
24 .    fam P
25 .  \}
26 .\}
27 .el \{\
28 .  ds o o
29 .  ds ss ^
30 .  ds se
31 .\}
32 .TH tripe 8 "10 February 2001" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
33 .SH "NAME"
34 tripe \- a simple VPN daemon
35 .SH "SYNOPSIS"
36 .B tripe
37 .RB [ \-D ]
38 .RB [ \-d
39 .IR dir ]
40 .RB [ \-b
41 .IR addr ]
42 .RB [ \-p
43 .IR port ]
44 .RB [ \-n
45 .IR tunnel ]
46 .br
47         
48 .RB [ \-U
49 .IR user ]
50 .RB [ \-G
51 .IR group ]
52 .RB [ \-a
53 .IR socket ]
54 .RB [ \-T
55 .IR trace-opts ]
56 .br
57         
58 .RB [ \-k
59 .IR priv-keyring ]
60 .RB [ \-K
61 .IR pub-keyring ]
62 .RB [ \-t
63 .IR key-tag ]
64 .SH "DESCRIPTION"
65 The
66 .B tripe
67 program is a server which can provide strong IP-level encryption and
68 authentication between co-operating hosts.  The program and its protocol
69 are deliberately very simple, to make analysing them easy and to help
70 build trust rapidly in the system.
71 .SS "Overview"
72 The
73 .B tripe
74 server manages a number of secure connections to other `peer' hosts.
75 Each daemon is given a private key of its own, and a file of public keys
76 for the peers with which it is meant to communicate.  It is responsible
77 for negotiating sets of symmetric keys with its peers, and for
78 encrypting, encapsulating and sending IP packets to its peers, and
79 decrypting, checking and de-encapsulating packets it receives from
80 them.
81 .PP
82 When the server starts, it creates a Unix-domain socket on which it
83 listens for administration commands.  It also logs warnings and
84 diagnostic information to the programs connected to its admin socket.
85 Clients connected to the socket can add new peers, and remove or find
86 out about existing peers.  The textual protocol used to give the
87 .B tripe
88 server admin commands is described in
89 .BR tripe\-admin (5).
90 A client program
91 .BR tripectl (1)
92 is provided to allow commands to be sent to the server either
93 interactively or by simple scripts.
94 .SS "Command-line arguments"
95 If not given any command-line arguments,
96 .B tripe
97 will initialize by following these steps:
98 .hP 1.
99 It sets the directory named by the
100 .B TRIPEDIR
101 environment variable (or
102 .B "@configdir@"
103 if the variable is unset) as the current directory.
104 .hP 2.
105 It acquires a UDP socket with an arbitrary kernel-selected port number.
106 It will use this socket to send and receive all communications with its
107 peer servers.  The port chosen may be discovered by means of the
108 .B PORT
109 admin command (see
110 .BR tripe\-admin (5)).
111 .hP 3.
112 It loads the private key with the tag or type name
113 .B tripe\-dh
114 from the Catacomb-format file
115 .BR keyring ,
116 and loads the file
117 .B keyring.pub
118 ready for extracting the public keys of peers as they're introduced.
119 (The format of these files is described in
120 .BR keyring (5).
121 They are maintained using the program
122 .BR key (1)
123 provided with the Catacomb distribution.)
124 .hP 4.
125 It creates and listens to the Unix-domain socket
126 .BR tripesock .
127 .PP
128 Following this, the server enters its main loop, accepting admin
129 connections and obeying any administrative commands, and communicating
130 with peers.  It also treats its standard input and standard output
131 streams as an admin connection, reading commands from standard input and
132 writing responses and diagnostics messages to standard output.  Finally,
133 it will reload keys from its keyring files if it notices that they've
134 changed (it checks inode number and modification time) \- there's no
135 need to send a signal.
136 .PP
137 Much of this behaviour may be altered by giving
138 .B tripe
139 suitable command-line options:
140 .TP
141 .B "\-h, \-\-help"
142 Writes a brief description of the command-line options available to
143 standard output and exits with status 0.
144 .TP
145 .B "\-v, \-\-version"
146 Writes
147 .BR tripe 's
148 version number to standard output and exits with status 0.
149 .TP
150 .B "\-u, \-\-usage"
151 Writes a brief usage summary to standard output and exits with status 0.
152 .TP
153 .B "\-\-tunnels"
154 Writes to standard output a list of the configured tunnel drivers, one
155 per line, and exits with status 0.  This is intended for the use of the
156 start-up script, so that it can check that it will actually work.
157 .TP
158 .B "\-D, \-\-daemon"
159 Dissociates from its terminal and starts running in the background after
160 completing the initialization procedure described above.  If running as
161 a daemon,
162 .B tripe
163 will not read commands from standard input or write diagnostics to
164 standard output.  A better way to start
165 .B tripe
166 in the background is with
167 .BR tripectl (1).
168 .TP
169 .BI "\-d, \-\-directory=" dir
170 Makes
171 .I dir
172 the current directory.  The default directory to change to is given by
173 the environment variable
174 .BR TRIPEDIR ;
175 if that's not specified, a default default of
176 .B "@configdir@"
177 is used.  Give a current directory of
178 .B .
179 if you don't want it to change directory at all.
180 .TP
181 .BI "\-b, \-\-bind-address="addr
182 Bind the UDP socket to IP address
183 .I addr
184 rather than the default of
185 .BR INADDR_ANY .
186 This is useful if your main globally-routable IP address is one you want
187 to tunnel through the VPN.
188 .TP
189 .BI "\-p, \-\-port=" port
190 Use the specified UDP port for all communications with peers, rather
191 than an arbitarary kernel-assigned port.
192 .TP
193 .BI "\-n, \-\-tunnel=" tunnel
194 Use the specified tunnel driver for new peers by default.
195 .TP
196 .BI "\-U, \-\-setuid=" user
197 Set uid to that of
198 .I user
199 (either a user name or integer uid) after initialization.  Also set gid
200 to
201 .IR user 's
202 primary group, unless overridden by a
203 .B \-G
204 option.
205 .TP
206 .BI "\-G, \-\-setgid=" group
207 Set gid to that of
208 .I group
209 (either a group name or integer gid) after initialization.
210 .TP
211 .BI "\-k, \-\-priv\-keyring=" file
212 Reads the private key from
213 .I file
214 rather than the default
215 .BR keyring .
216 .TP
217 .BI "\-K, \-\-pub\-keyring=" file
218 Reads public keys from
219 .I file
220 rather than the default
221 .BR keyring.pub .
222 This can be the same as the private keyring, but that's not recommended.
223 .TP
224 .BI "\-t, \-\-tag=" tag
225 Uses the private key whose tag or type is
226 .I tag
227 rather than the default
228 .BR tripe\-dh .
229 .TP
230 .BI "\-a, \-\-admin\-socket=" socket
231 Accept admin connections to a Unix-domain socket named
232 .IR socket .
233 The default socket, if this option isn't specified, is given by the
234 environment variable
235 .BR TRIPESOCK ;
236 if that's not set either, then a default default of
237 .B "@socketdir@/tripesock"
238 is used instead.
239 .TP
240 .BI "\-T, \-\-trace=" trace-opts
241 Allows the enabling or disabling of various internal diagnostics.  See
242 below for the list of options.
243 .SS "Setting up a VPN with tripe"
244 The
245 .B tripe
246 server identifies peers by name.  While it's
247 .I possible
248 for each host to maintain its own naming system for its peers, this is
249 likely to lead to confusion, and it's more sensible to organize a naming
250 system that works everywhere.  How you manage this naming is up to you.
251 The only restriction on the format of names is that they must be valid
252 Catacomb key tags, since this is how
253 .B tripe
254 identifies which public key to use for a particular peer: they may not
255 contain whitespace characters, or a colon
256 .RB ` : '
257 or dot
258 .RB ` . ',
259 .PP
260 Allocating IP addresses for VPNs can get quite complicated.  I'll
261 attempt to illustrate with a relatively simple example.  Our objective
262 will be to set up a virtual private network between two sites of
263 .BR example.com .
264 The two sites are using distinct IP address ranges from the private
265 address space described in RFC1918: site A is using addresses from
266 10.0.1.0/24 and site B is using 10.0.2.0/24.  Each site has a gateway
267 host set up with both an address on the site's private network, and an
268 externally-routable address from the public IP address space.  Site A's
269 gateway machine,
270 .BR alice ,
271 has the addresses 10.0.1.1 and 200.0.1.1; site B's gateway is
272 .B bob
273 and has addresses 10.0.2.1 and 200.0.2.1.
274 .hP 1.
275 Install
276 .B tripe
277 on both of the gateway hosts.  Create the directory
278 .BR /var/lib/tripe .
279 .hP 2.
280 On
281 .BR alice ,
282 make
283 .B /var/lib/tripe
284 the current directory and generate a Diffie-Hellman group:
285 .RS
286 .VS
287 key add \-adh\-param \-LS \-b2048 \-B256 \e
288         \-eforever \-tparam tripe\-dh\-param
289 .VE
290 (See
291 .BR key (1)
292 from the Catacomb distribution for details about the
293 .B key
294 command.)  Also generate a private key for
295 .BR alice :
296 .VS
297 key add \-adh \-pparam \-talice \e
298         \-e"now + 1 year" tripe\-dh
299 .VE
300 Extract the group parameters and
301 .BR alice 's
302 public key to
303 .I separate
304 files, and put the public key in
305 .BR keyring.pub :
306 .VS
307 key extract param param
308 key extract \-f\-secret alice.pub alice
309 key \-kkeyring.pub merge alice.pub
310 .VE
311 Send the files
312 .B param
313 and
314 .B alice.pub
315 to
316 .B bob
317 in some secure way (e.g., in PGP-signed email, or by using SSH), so that
318 you can be sure they've not been altered in transit.
319 .RE
320 .hP 3.
321 On
322 .B bob
323 now, make
324 .B /var/lib/tripe
325 the current directory, and import the key material from
326 .BR alice :
327 .RS
328 .VS
329 key merge param
330 key \-kkeyring.pub merge alice.pub
331 .VE
332 Generate a private key for
333 .B bob
334 and extract the public half, as before:
335 .VS
336 key add \-adh \-pparam \-tbob \e
337         \-e"now + 1 year" tripe\-dh
338 key extract \-f\-secret bob.pub bob
339 key \-kkeyring.pub merge bob.pub
340 .VE
341 and send
342 .B bob.pub
343 back to
344 .B alice
345 using some secure method.
346 .RE
347 .hP 4
348 On
349 .BR alice ,
350 merge
351 .B bob 's
352 key into the public keyring.  Now, on each host, run
353 .RS
354 .VS
355 key \-kkeyring.pub fingerprint
356 .VE
357 and check that the hashes match.  If the two sites have separate
358 administrators, they should read the hashes to each other over the
359 telephone (assuming that they can recognize each other's voices).
360 .RE
361 .hP 5.
362 Start the
363 .B tripe
364 servers up.  Run
365 .RS
366 .VS
367 tripectl \-slD \-S\-p22003
368 .VE
369 on each of
370 .B alice
371 and
372 .BR bob .
373 (The
374 .RB ` \-p22003 '
375 forces the server to use UDP port 22003: use some other number if 22003
376 is inappropriate for your requirements.  I chose it by taking the first
377 16 bits of the RIPEMD160 hash of
378 .RB ` TrIPE '.
379 .RE
380 .hP 6.
381 To get
382 .B alice
383 talking to
384 .BR bob ,
385 run this shell script (or one like it):
386 .RS
387 .VS
388 #! /bin/sh
389
390 tripectl add bob 200.0.2.1 22003
391 ifname=`tripectl ifname bob`
392 ifconfig $ifname 10.0.1.1 pointopoint 10.0.2.1
393 route add -net \e
394         10.0.2.0 netmask 255.255.255.0 \e
395         gw 10.0.2.1
396 .VE
397 Read
398 .BR ifconfig (8)
399 and
400 .BR route (8)
401 to find out about your system's variants of these commands.  The
402 versions shown above assume a Linux system.
403 Run a similar script on
404 .BR bob ,
405 to tell its
406 .B tripe
407 server to talk to
408 .BR alice .
409 .RE
410 .hP 7.
411 Congratulations.  The two servers will exchange keys and begin sending
412 packets almost immediately.  You've set up a virtual private network.
413 .SS "Using elliptic curve keys"
414 The
415 .B tripe
416 server can use elliptic curve Diffie-Hellman for key exchange, rather
417 than traditional integer Diffie-Hellman.  Given current public
418 knowledge, elliptic curves can provide similar or better security to
419 systems based on integer discrete log problems, faster, and with less
420 transmitted data.  It's a matter of controversy whether this will
421 continue to be the case.  The author uses elliptic curves.
422 .PP
423 The server works out which it
424 should be doing based on the key type, which is either
425 .B tripe\-dh
426 for standard Diffie-Hellman, or
427 .B tripe\-ec
428 for elliptic curves.  To create elliptic curve keys, say something like
429 .VS
430 key add \-aec\-param \-Cnist-p192 \-eforever \e
431         \-tparam tripe\-ec\-param
432 .VE
433 to construct a parameters key, using your preferred elliptic curve in
434 the
435 .B \-C
436 option (see
437 .BR key (1)
438 for details); and create the private keys by
439 .VS
440 key add \-aec \-pparam \-talice \e
441         \-e"now + 1 year" tripe\-ec
442 .VE
443 Now start
444 .B tripe
445 with the
446 .B \-ttripe\-ec
447 option, and all should be well.
448 .SS "Using other symmetric algorithms"
449 The default symmetric algorithms
450 .B tripe
451 uses are Blowfish (by Schneier) for symmetric encryption, and RIPEMD-160
452 (by Dobbertin, Bosselaers and Preneel) for hashing and as a MAC (in HMAC
453 mode, designed by Bellare, Canetti and Krawczyk).  These can all be
454 overridden by setting attributes on your private key, as follows.
455 .TP
456 .B cipher
457 Names the symmetric encryption scheme to use.  The default is
458 .BR blowfish\-cbc .
459 .TP
460 .B hash
461 Names the hash function to use.  The default is
462 .BR rmd160 .
463 .TP
464 .B mac
465 Names the message authentication code to use.  The name of the MAC may
466 be followed by a
467 .RB ` / '
468 and the desired tag length in bits.  The default is
469 .IB hash \-hmac
470 at half the underlying hash function's output length.
471 .TP
472 .B mgf
473 A `mask-generation function', used in the key-exchange.  The default is
474 .IB hash \-mgf
475 and there's no good reason to change it.
476 .SS "Using SLIP interfaces"
477 Though not for the faint of heart, it is possible to get
478 .B tripe
479 to read and write network packets to a pair of file descriptors using
480 SLIP encapsulation.  No fancy header compression of any kind is
481 supported.
482 .PP
483 Two usage modes are supported: a preallocation system, whereby SLIP
484 interfaces are created and passed to the
485 .B tripe
486 server at startup; and a dynamic system, where the server runs a script
487 to allocate a new SLIP interface when it needs one.  It is possible to
488 use a mixture of these two modes, starting
489 .B tripe
490 with a few preallocated interfaces and having it allocate more
491 dynamically as it needs them.
492 .PP
493 The behaviour of
494 .BR tripe 's
495 SLIP driver is controlled by the
496 .B TRIPE_SLIPIF
497 environment variable.  The server will not create SLIP tunnels if this
498 variable is not defined.  The variable's value is a colon-delimited list
499 of preallocated interfaces, followed optionally by the filename of a
500 script to run to dynamically allocate more interfaces.
501 .PP
502 A static allocation entry has the form
503 .IR infd [ \c
504 .BI , outfd \c
505 .RB ] \c
506 .BI = \c
507 .IR ifname ,
508 If the
509 .I outfd
510 is omitted, the same file descriptor is used for input and output.
511 .PP
512 The dynamic allocation script must be named by an absolute or relative
513 pathname, beginning with 
514 .RB ` / '
515 or
516 .RB ` . '.
517 The server will pass the script an argument, which is the name of the
518 peer for which the interface is being created.  The script should
519 allocate a new SLIP interface (presumably by creating a pty pair),
520 configure it appropriately, and write the interface's name to its
521 standard output, followed by a newline.  It should then read and write
522 SLIP packets on its stdin and stdout.  The script's stdin will be closed
523 when the interface is no longer needed, and the server will attempt to
524 send it a
525 .B SIGTERM
526 signal (though this may fail if the script runs with higher privileges
527 than the server).
528 .PP
529 The output file descriptor should not block unless it really needs to:
530 the
531 .B tripe
532 daemon assumes that it won't, and will get wedged waiting for it to
533 accept output.
534 .SS "About the name"
535 The program's name is
536 .BR tripe ,
537 all in lower-case.  The name of the protocol it uses is `TrIPE', with
538 four capital letters and one lower-case.  The name stands for `Trivial
539 IP Encryption'.
540 .SH "BUGS"
541 The code hasn't been audited.  It may contain security bugs.  If you
542 find one, please inform the author
543 .IR immediately .
544 .SH "SEE ALSO"
545 .BR key (1),
546 .BR tripectl (1),
547 .BR tripe\-admin (5).
548 .PP
549 .IR "The Trivial IP Encryption Protocol" ,
550 .IR "The Wrestlers Protocol" .
551 .SH "AUTHOR"
552 Mark Wooding, <mdw@distorted.org.uk>