chiark / gitweb /
server/keymgmt.c: Track and find keys by their 32-bit IDs.
[tripe] / server / tripe.8.in
CommitLineData
74eb47db 1.\" -*-nroff-*-
2.\".
fc916a09
MW
3.\" Manual for the server
4.\"
5.\" (c) 2008 Straylight/Edgeware
6.\"
7.
8.\"----- Licensing notice ---------------------------------------------------
9.\"
10.\" This file is part of Trivial IP Encryption (TrIPE).
11.\"
11ad66c2
MW
12.\" TrIPE is free software: you can redistribute it and/or modify it under
13.\" the terms of the GNU General Public License as published by the Free
14.\" Software Foundation; either version 3 of the License, or (at your
15.\" option) any later version.
fc916a09 16.\"
11ad66c2
MW
17.\" TrIPE is distributed in the hope that it will be useful, but WITHOUT
18.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20.\" for more details.
fc916a09
MW
21.\"
22.\" You should have received a copy of the GNU General Public License
11ad66c2 23.\" along with TrIPE. If not, see <https://www.gnu.org/licenses/>.
fc916a09
MW
24.
25.\"--------------------------------------------------------------------------
e99aedcf 26.so ../common/defs.man \" @@@PRE@@@
fc916a09
MW
27.
28.\"--------------------------------------------------------------------------
0647ba7c 29.TH tripe 8tripe "10 February 2001" "Straylight/Edgeware" "TrIPE: Trivial IP Encryption"
fc916a09
MW
30.
31.\"--------------------------------------------------------------------------
74eb47db 32.SH "NAME"
fc916a09 33.
74eb47db 34tripe \- a simple VPN daemon
fc916a09
MW
35.
36.\"--------------------------------------------------------------------------
74eb47db 37.SH "SYNOPSIS"
fc916a09 38.
74eb47db 39.B tripe
46dde080 40.RB [ \-DF ]
74eb47db 41.RB [ \-d
42.IR dir ]
d13e5724 43.RB [ \-b
44.IR addr ]
33ced0d3 45.RB [ \-p
46.IR port ]
42da2a58 47.RB [ \-n
48.IR tunnel ]
d13e5724 49.br
85b1ebd6 50 \c
33ced0d3 51.RB [ \-U
52.IR user ]
53.RB [ \-G
54.IR group ]
d13e5724 55.RB [ \-a
56.IR socket ]
a9279e37
MW
57.RB [ \-m
58.IR mode ]
d13e5724 59.RB [ \-T
60.IR trace-opts ]
74eb47db 61.br
85b1ebd6 62 \c
74eb47db 63.RB [ \-k
64.IR priv-keyring ]
65.RB [ \-K
66.IR pub-keyring ]
67.RB [ \-t
68.IR key-tag ]
fc916a09
MW
69.
70.\"--------------------------------------------------------------------------
74eb47db 71.SH "DESCRIPTION"
fc916a09 72.
74eb47db 73The
74.B tripe
75program is a server which can provide strong IP-level encryption and
1a19f865 76authentication between co-operating hosts. The program and its protocol
77are deliberately very simple, to make analysing them easy and to help
78build trust rapidly in the system.
74eb47db 79.SS "Overview"
80The
81.B tripe
82server manages a number of secure connections to other `peer' hosts.
83Each daemon is given a private key of its own, and a file of public keys
84for the peers with which it is meant to communicate. It is responsible
85for negotiating sets of symmetric keys with its peers, and for
86encrypting, encapsulating and sending IP packets to its peers, and
87decrypting, checking and de-encapsulating packets it receives from
88them.
89.PP
90When the server starts, it creates a Unix-domain socket on which it
91listens for administration commands. It also logs warnings and
92diagnostic information to the programs connected to its admin socket.
93Clients connected to the socket can add new peers, and remove or find
94out about existing peers. The textual protocol used to give the
95.B tripe
96server admin commands is described in
97.BR tripe\-admin (5).
98A client program
99.BR tripectl (1)
100is provided to allow commands to be sent to the server either
101interactively or by simple scripts.
102.SS "Command-line arguments"
103If not given any command-line arguments,
104.B tripe
105will initialize by following these steps:
1a19f865 106.hP 1.
107It sets the directory named by the
108.B TRIPEDIR
109environment variable (or
f7b5d108 110.B "\*(/c"
1a19f865 111if the variable is unset) as the current directory.
112.hP 2.
f492fa0b 113It acquires a UDP socket. The default port is 4070
74eb47db 114It will use this socket to send and receive all communications with its
115peer servers. The port chosen may be discovered by means of the
116.B PORT
117admin command (see
118.BR tripe\-admin (5)).
1a19f865 119.hP 3.
74eb47db 120It loads the private key with the tag or type name
fc5f4823
MW
121.B tripe
122(or, failing that,
74eb47db 123.B tripe\-dh
fc5f4823 124for backwards compatibility reasons) from the Catacomb-format file
74eb47db 125.BR keyring ,
126and loads the file
127.B keyring.pub
128ready for extracting the public keys of peers as they're introduced.
129(The format of these files is described in
130.BR keyring (5).
131They are maintained using the program
132.BR key (1)
133provided with the Catacomb distribution.)
1a19f865 134.hP 4.
74eb47db 135It creates and listens to the Unix-domain socket
136.BR tripesock .
137.PP
138Following this, the server enters its main loop, accepting admin
139connections and obeying any administrative commands, and communicating
140with peers. It also treats its standard input and standard output
141streams as an admin connection, reading commands from standard input and
33ced0d3 142writing responses and diagnostics messages to standard output. Finally,
143it will reload keys from its keyring files if it notices that they've
144changed (it checks inode number and modification time) \- there's no
145need to send a signal.
74eb47db 146.PP
147Much of this behaviour may be altered by giving
148.B tripe
149suitable command-line options:
150.TP
151.B "\-h, \-\-help"
152Writes a brief description of the command-line options available to
153standard output and exits with status 0.
154.TP
155.B "\-v, \-\-version"
156Writes
157.BR tripe 's
158version number to standard output and exits with status 0.
159.TP
160.B "\-u, \-\-usage"
161Writes a brief usage summary to standard output and exits with status 0.
162.TP
42da2a58 163.B "\-\-tunnels"
164Writes to standard output a list of the configured tunnel drivers, one
165per line, and exits with status 0. This is intended for the use of the
3cdc3f3a 166start-up script, so that it can check that it will actually work.
167.TP
74eb47db 168.B "\-D, \-\-daemon"
169Dissociates from its terminal and starts running in the background after
170completing the initialization procedure described above. If running as
171a daemon,
172.B tripe
173will not read commands from standard input or write diagnostics to
174standard output. A better way to start
175.B tripe
176in the background is with
177.BR tripectl (1).
178.TP
46dde080
MW
179.B "\-F, \-\-foreground"
180Runs the server in the `foreground'; i.e.,
181.B tripe
182will quit if it sees end-of-file on its standard input. This is
183incompatible with
184.BR \-D .
185.TP
74eb47db 186.BI "\-d, \-\-directory=" dir
187Makes
188.I dir
797cf76b
MW
189the current directory. The default directory to change to is given by
190the environment variable
191.BR TRIPEDIR ;
192if that's not specified, a default default of
f7b5d108 193.B "\*(/c"
797cf76b 194is used. Give a current directory of
74eb47db 195.B .
196if you don't want it to change directory at all.
197.TP
d13e5724 198.BI "\-b, \-\-bind-address="addr
199Bind the UDP socket to IP address
200.I addr
201rather than the default of
202.BR INADDR_ANY .
203This is useful if your main globally-routable IP address is one you want
204to tunnel through the VPN.
205.TP
74eb47db 206.BI "\-p, \-\-port=" port
207Use the specified UDP port for all communications with peers, rather
f492fa0b
MW
208than the default port 4070. If this is zero, the kernel will assign a
209free port, which can be determined using the
210.B PORT
211administration command (see
212.BR tripe-admin (5)).
74eb47db 213.TP
42da2a58 214.BI "\-n, \-\-tunnel=" tunnel
215Use the specified tunnel driver for new peers by default.
216.TP
33ced0d3 217.BI "\-U, \-\-setuid=" user
218Set uid to that of
219.I user
220(either a user name or integer uid) after initialization. Also set gid
221to
222.IR user 's
223primary group, unless overridden by a
224.B \-G
aa2405e8
MW
225option. The selected user (and group) will also be the owner of the
226administration socket.
33ced0d3 227.TP
228.BI "\-G, \-\-setgid=" group
ec9b8aed
MW
229If the current effective uid is zero (i.e., the daemon was invoked as
230.BR root )
231then set gid to that of
33ced0d3 232.I group
ec9b8aed
MW
233(either a group name or integer gid) after initialization. In any
234event, arrange hat the administration socket be owned by the given
235.IR group .
33ced0d3 236.TP
74eb47db 237.BI "\-k, \-\-priv\-keyring=" file
238Reads the private key from
239.I file
240rather than the default
241.BR keyring .
242.TP
243.BI "\-K, \-\-pub\-keyring=" file
244Reads public keys from
245.I file
246rather than the default
247.BR keyring.pub .
248This can be the same as the private keyring, but that's not recommended.
249.TP
250.BI "\-t, \-\-tag=" tag
251Uses the private key whose tag or type is
252.I tag
253rather than the default
fc5f4823
MW
254.B tripe
255or
74eb47db 256.BR tripe\-dh .
257.TP
258.BI "\-a, \-\-admin\-socket=" socket
259Accept admin connections to a Unix-domain socket named
797cf76b
MW
260.IR socket .
261The default socket, if this option isn't specified, is given by the
262environment variable
263.BR TRIPESOCK ;
264if that's not set either, then a default default of
f7b5d108 265.B "\*(/s/tripesock"
797cf76b 266is used instead.
74eb47db 267.TP
a9279e37
MW
268.BI "\-m, \-\-admin\-perms=" mode
269Permissions (as an octal number) to set on the administration socket. The
270default is 600, which allows only the socket owner. Setting 660 allows
271members of the
272.I group
273configured through the
274.B \-G
275option to connect to the socket, which may be useful. Allowing world access
276is a terrible idea.
277.TP
74eb47db 278.BI "\-T, \-\-trace=" trace-opts
279Allows the enabling or disabling of various internal diagnostics. See
280below for the list of options.
fc5f4823 281.SS "Key exchange group types"
d6623498 282The
283.B tripe
fc5f4823 284server uses Diffie\(en\&Hellman key exchange to agree the symmetric keys
b86e6f3f 285used for bulk data transfer.
fc5f4823
MW
286.PP
287The server works out which it should be doing based on the key's
288.B kx-group
b86e6f3f 289attribute.
fc5f4823
MW
290If this attribute isn't present, then the key's type is examined: if
291it's of the form
1a0b1e9f 292.BI tripe\- group
fc5f4823
MW
293then the
294.I group
295is used. If no group is specified,
296.B dh
297is used as a fallback.
b86e6f3f
MW
298The following groups are defined.
299.TP
300.B dh
301.RS
302Use traditional Diffie\(enHellman in a
303.IR "Schnorr group" :
304a prime-order subgroup of the multiplicative group of
305a finite field; this is the usual
306.I g\*(ssx\*(se
307mod
308.I p
309kind of Diffie\(en\&Hellman.
fc5f4823
MW
310.PP
311To create usual Schnorr-group keys, say something like
74eb47db 312.VS
fc5f4823
MW
313key add \-adh-param \-LS \-b3072 \-B256 \e
314 \-eforever \-tparam tripe\-param kx-group=dh
74eb47db 315.VE
fc5f4823 316to construct a parameters key; and create the private keys by
d6623498 317.VS
318key add \-adh \-pparam \-talice \e
fc5f4823 319 \-e"now + 1 year" tripe
d6623498 320.VE
b86e6f3f
MW
321.RE
322.sv -1
323.TP
324.B ec
325.RS
326Use elliptic curve Diffie\(enHellman.
327An elliptic curve group is a prime-order
328subgroup of the abelian group of
329.BR K -rational
330points on an elliptic curve defined over a finite field
331.BR K .
332.PP
333Given current public knowledge, elliptic curves can provide similar or
334better security to systems based on integer discrete log problems,
335faster, and with less transmitted data. It's a matter of controversy
336whether this will continue to be the case. The author uses elliptic
337curves.
338.PP
fc5f4823 339To create elliptic curve keys, say something like
d6623498 340.VS
fc5f4823
MW
341key add \-aec\-param \-Cnist-p256 \-eforever \e
342 \-tparam tripe\-param kx-group=ec
52c03a2a 343.VE
344to construct a parameters key, using your preferred elliptic curve in
345the
346.B \-C
347option (see
348.BR key (1)
349for details); and create the private keys by
350.VS
351key add \-aec \-pparam \-talice \e
fc5f4823 352 \-e"now + 1 year" tripe
52c03a2a 353.VE
b86e6f3f 354.RE
26936c83
MW
355.sv -1
356.TP
357.B x25519
358.RS
359Use Bernstein's X25519 Diffie\(enHellman function.
360This is technically a variant on
361the general elliptic curve Diffie\(enHellman
362available through the
363.B ec
364setting,
365but carefully designed and heavily optimized.
366.PP
367To create
368.B x25519
369keys,
370say something like
371.VS
372key add \-aempty \-eforever \e
373 \-tparam tripe\-param kx-group=x25519
374.VE
375to construct a parameters key
376(see
377.BR key (1)
378for details);
379and create the private keys by
380.VS
381key add \-ax25519 \-pparam \-talice \e
382 \-e"now + 1 year" tripe
383.VE
384.RE
385.sv -1
386.TP
387.B x448
388.RS
389Use Hamburg's X448 Diffie\(enHellman function.
390Like
391.B x25519
392above,
393this is technically a variant on
394the general elliptic curve Diffie\(enHellman
395available through the
396.B ec
397setting,
398but carefully designed and heavily optimized.
399.PP
400To create
401.B x448
402keys,
403say something like
404.VS
405key add \-aempty \-eforever \e
406 \-tparam tripe\-param kx-group=x448
407.VE
408to construct a parameters key
409(see
410.BR key (1)
411for details);
412and create the private keys by
413.VS
414key add \-ax448 \-pparam \-talice \e
415 \-e"now + 1 year" tripe
416.VE
417.RE
fc5f4823
MW
418Note that the
419.BR tripe-keys (8)
420program provides a rather more convenient means for generating and
421managing keys for
422.BR tripe .
b5c45da1 423.SS "Using other symmetric algorithms"
424The default symmetric algorithms
425.B tripe
426uses are Blowfish (by Schneier) for symmetric encryption, and RIPEMD-160
427(by Dobbertin, Bosselaers and Preneel) for hashing and as a MAC (in HMAC
428mode, designed by Bellare, Canetti and Krawczyk). These can all be
429overridden by setting attributes on your private key, as follows.
430.TP
a93aacce 431.B bulk
b87bffcb
MW
432Names the bulk-crypto transform to use. See below.
433.TP
434.B blkc
435Names a block cipher, used by some bulk-crypto transforms (e.g.,
a305982d
MW
436.BR iiv ).
437The default is to use the block cipher underlying the chosen
b87bffcb
MW
438.BR cipher ,
439if any.
a93aacce 440.TP
b5c45da1 441.B cipher
442Names the symmetric encryption scheme to use. The default is
443.BR blowfish\-cbc .
444.TP
445.B hash
446Names the hash function to use. The default is
447.BR rmd160 .
448.TP
449.B mac
450Names the message authentication code to use. The name of the MAC may
451be followed by a
452.RB ` / '
453and the desired tag length in bits. The default is
454.IB hash \-hmac
455at half the underlying hash function's output length.
73d383c0
MW
456If the MAC's name contains a
457.RB ` / '
458character,
459e.g.,
460.RB ` sha512/256 ',
461then an
462.I additional
463.RB ` / '
464and the tag size is required to disambiguate,
465so, e.g.,
466one might write
467.RB ` sha512/256/256 '.
b5c45da1 468.TP
469.B mgf
470A `mask-generation function', used in the key-exchange. The default is
471.IB hash \-mgf
472and there's no good reason to change it.
b87bffcb
MW
473.PP
474The available bulk-crypto transforms are as follows.
475.TP
476.B v0
477Originally this was the only transform available. It's a standard
478generic composition of a CPA-secure symmetric encryption scheme with a
479MAC; initialization vectors for symmetric encryption are chosen at
480random and included explicitly in the cryptogram.
481.TP
482.B iiv
483A newer `implicit-IV' transform. Rather than having an explicit random
484IV, the IV is computed from the sequence number using a block cipher.
485This has two advantages over the
486.B v0
487transform. Firstly, it adds less overhead to encrypted messages
488(because the IV no longer needs to be sent explicitly). Secondly, and
489more significantly, the transform is entirely deterministic, so (a) it
490doesn't need the (possibly slow) random number generator, and (b) it
491closes a kleptographic channel, over which a compromised implementation
492could leak secret information to a third party.
de8edc7f
MW
493.TP
494.B naclbox
495A transform based on the NaCl
496.B crypto_secretbox
497transformation.
498The main difference is that NaCl uses XSalsa20,
499while TrIPE uses plain Salsa20 or ChaCha,
500because it doesn't need the larger nonce space.
501You can set the
502.B cipher
503key attribute to one of
504.BR salsa20 ,
505.BR salsa20/12 ,
506.BR salsa20/8 ,
507.BR chacha20 ,
508.BR chacha12 ,
509or
510.B chacha8
511to select the main cipher.
512You can set the
513.B mac
514key attribute to
515.B poly1305
516or
517.B poly1305/128
518but these are the default and no other choice is permitted.
519(This is for forward compatibility,
520in case other MACs and/or tag sizes are allowed later.)
07bdda1f
MW
521.SS "Other key attributes"
522The following attributes can also be set on keys.
523.TP
524.B serialization
525Selects group-element serialization formats.
526The recommended setting is
527.BR constlen ,
528which selects a constant-length encoding when hashing group elements.
529The default,
530for backwards compatibility, is
531.BR v0 ;
532but this is deprecated.
533(The old format uses a variable length format for hashing,
534which can leak information through timing.)
b9066fbb 535.SS "Using SLIP interfaces"
536Though not for the faint of heart, it is possible to get
537.B tripe
538to read and write network packets to a pair of file descriptors using
539SLIP encapsulation. No fancy header compression of any kind is
98fdb08d 540supported.
541.PP
542Two usage modes are supported: a preallocation system, whereby SLIP
543interfaces are created and passed to the
544.B tripe
545server at startup; and a dynamic system, where the server runs a script
546to allocate a new SLIP interface when it needs one. It is possible to
547use a mixture of these two modes, starting
b9066fbb 548.B tripe
98fdb08d 549with a few preallocated interfaces and having it allocate more
550dynamically as it needs them.
551.PP
552The behaviour of
553.BR tripe 's
554SLIP driver is controlled by the
555.B TRIPE_SLIPIF
1f68dfc5 556environment variable. The server will not create SLIP tunnels if this
557variable is not defined. The variable's value is a colon-delimited list
558of preallocated interfaces, followed optionally by the filename of a
559script to run to dynamically allocate more interfaces.
b9066fbb 560.PP
98fdb08d 561A static allocation entry has the form
b9066fbb 562.IR infd [ \c
563.BI , outfd \c
564.RB ] \c
565.BI = \c
98fdb08d 566.IR ifname ,
b9066fbb 567If the
568.I outfd
569is omitted, the same file descriptor is used for input and output.
570.PP
98fdb08d 571The dynamic allocation script must be named by an absolute or relative
e04c2d50 572pathname, beginning with
98fdb08d 573.RB ` / '
574or
575.RB ` . '.
576The server will pass the script an argument, which is the name of the
577peer for which the interface is being created. The script should
578allocate a new SLIP interface (presumably by creating a pty pair),
579configure it appropriately, and write the interface's name to its
580standard output, followed by a newline. It should then read and write
581SLIP packets on its stdin and stdout. The script's stdin will be closed
582when the interface is no longer needed, and the server will attempt to
583send it a
584.B SIGTERM
585signal (though this may fail if the script runs with higher privileges
586than the server).
587.PP
b9066fbb 588The output file descriptor should not block unless it really needs to:
589the
590.B tripe
1f68dfc5 591daemon assumes that it won't, and will get wedged waiting for it to
592accept output.
74eb47db 593.SS "About the name"
594The program's name is
595.BR tripe ,
596all in lower-case. The name of the protocol it uses is `TrIPE', with
597four capital letters and one lower-case. The name stands for `Trivial
598IP Encryption'.
fc916a09
MW
599.
600.\"--------------------------------------------------------------------------
74eb47db 601.SH "BUGS"
fc916a09 602.
74eb47db 603The code hasn't been audited. It may contain security bugs. If you
604find one, please inform the author
605.IR immediately .
fc916a09
MW
606.
607.\"--------------------------------------------------------------------------
74eb47db 608.SH "SEE ALSO"
fc916a09 609.
74eb47db 610.BR key (1),
611.BR tripectl (1),
fc5f4823
MW
612.BR tripe\-admin (5),
613.BR tripe\-keys (8).
74eb47db 614.PP
615.IR "The Trivial IP Encryption Protocol" ,
616.IR "The Wrestlers Protocol" .
fc916a09
MW
617.
618.\"--------------------------------------------------------------------------
74eb47db 619.SH "AUTHOR"
fc916a09 620.
d36eda2a 621Mark Wooding, <mdw@distorted.org.uk>
fc916a09
MW
622.
623.\"----- That's all, folks --------------------------------------------------