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