Change manpage style slightly.
[u/mdw/catacomb] / key.1
1 .\" -*-nroff-*-
2 .ie t \{\
3 . ds ss \s8\u
4 . ds se \d\s0
5 . ds us \s8\d
6 . ds ue \u\s0
7 .\}
8 .el \{\
9 . ds ss ^
10 . ds se
11 . ds us _
12 . ds se
13 .\}
14 .TH key 1 "5 June 1999" "Straylight/Edgeware" "Catacomb cryptographic library"
15 .SH NAME
16 key \- simple key management system
17 .SH SYNOPSIS
18 .B key
19 .RB [ \-k
20 .IR keyring ]
21 .I command
22 .PP
23 where
24 .I command
25 is one of:
26 .PP
27 .B add
28 .RB [ \-lqrLS ]
29 .RB [ \-a
30 .IR alg ]
31 .RB [ \-b | \-B
32 .IR bits ]
33 .RB [ \-p
34 .IR param ]
35 .RB [ \-R
36 .IR tag ]
37 .br
38 \h'8n'
39 .RB [ \-e
40 .IR expire ]
41 .RB [ \-t
42 .IR tag ]
43 .RB [ \-c
44 .IR comment ]
45 .I type
46 .IR attr ...
47 .br
48 .B expire
49 .IR tag ...
50 .br
51 .B delete
52 .IR tag ...
53 .br
54 .B tag
55 .I tag
56 .RI [ new-tag ]
57 .br
58 .B comment
59 .I tag
60 .RI [ comment ]
61 .br
62 .B setattr
63 .I tag
64 .IR attr ...
65 .br
66 .B lock
67 .I qtag
68 .br
69 .B unlock
70 .I qtag
71 .br
72 .B list
73 .RB [ \-uqv ]
74 .RB [ \-f
75 .IR filter ]
76 .RI [ tag ...]
77 .br
78 .B fingerprint
79 .RB [ \-f
80 .IR filter ]
81 .RI [ tag ...]
82 .br
83 .B tidy
84 .br
85 .B extract
86 .RB [ \-f
87 .IR filter ]
88 .I file
89 .RI [ tag ...]
90 .br
91 .B merge
92 .I file
93 .SH DESCRIPTION
94 The
95 .B key
96 command performs useful operations on Catacomb keyring files. It
97 provides a number of subcommands, by which the various operations may be
98 carried out.
99 .SS "Global options"
100 Before the command name,
101 .I "global options"
102 may be given. The following global options are supported:
103 .TP
104 .BR "\-h, \-\-help " [ \fIcommand ]
105 Writes a brief summary of
106 .BR key 's
107 various options to standard output, and
108 returns a successful exit status. With a command name, gives help on
109 that command.
110 .TP
111 .B "\-v, \-\-version"
112 Writes the program's version number to standard output, and returns a
113 successful exit status.
114 .TP
115 .B "\-u, \-\-usage"
116 Writes a very terse command line summary to standard output, and returns
117 a successful exit status.
118 .TP
119 .BI "\-k, \-\-keyring " file
120 Names the keyring file which
121 .B key
122 is to process. The default keyring, used if this option doesn't specify
123 one, is the file named
124 .B keyring
125 in the current directory. The keyring must be stored in a regular file:
126 pipes, sockets, devices etc. are not allowed.
127 The
128 .B key
129 program attempts to lock the keyring before accessing it, using
130 .BR fcntl (2)
131 locking. It will however time out after a short while (10 seconds) and
132 report a failure.
133 .SS Concepts
134 In addition to the actual key data itself, a Catacomb key has a number
135 of other pieces of information attached to it:
136 .TP
137 .B "keyid"
138 Every key has a 32-bit identifying number, written in hexadecimal.
139 Keyids are not actually related to the key contents: they're generated
140 randomly. Applications use keyids to refer to specific keys; users are
141 probably better off with tags and types. A
142 .I deleted
143 key cannot be looked up by keyid.
144 .TP
145 .B "tag"
146 A key's tag is a unique string which can be used by users and
147 applications to identify the key. Tag strings may not contain spaces,
148 colons or dots. A
149 .I deleted
150 key cannot be looked up by tag. Whenever a tag name is wanted, a hex
151 keyid or key type string can be given instead.
152 .TP
153 .B "type"
154 A key's type string describes what the key may be used for. The type
155 string is arbitrary, except that it may not contain whitespace
156 characters, dots or colons. Applications use key types to obtain an
157 arbitrary but suitable key for some purpose. An
158 .I expired
159 key cannot be looked up by type, but may be looked up by keyid or tag.
160 .TP
161 .B "key encoding"
162 There are a number of different ways in which keys can be represented,
163 according to the uses to which the key will be put. Most symmetric
164 algorithms use
165 .I binary
166 keys. Keys used with number-theoretic systems (like most common
167 public-key systems) use
168 .I "multiprecision integer"
169 keys. Algorithms which require several key constituents (again, like
170 most public-key systems) use
171 .I structured
172 keys, which consist of a collection of named parts. Finally, keys
173 (including structured keys) can be encrypted.
174 .TP
175 .B "filter"
176 Keys and key components may be selected by a filter expression, a
177 sequence of flag names separated by commas. Flags are:
178 .BR binary ,
179 .BR integer ,
180 .B struct
181 or
182 .B encrypt
183 (describing the key encoding);
184 .BR symmetric ,
185 .BR private ,
186 .B public
187 or
188 .B shared
189 (describing the category of key);
190 .B burn
191 and its negation
192 .B \-burn
193 (whether the key should be erased from memory after use); and
194 .B secret
195 and its negation
196 .B \-secret
197 (whether the key is safe to divulge).
198 .TP
199 .B "qualified tag"
200 A key component may be identified by the key's tag (or keyid, or type).
201 Subcomponents of structured keys are identified by following the tag by
202 a dot and the name of the subcomponent.
203 .TP
204 .B "expiry time"
205 Most keys expire after a certain amount of time. Once a key has
206 expired, it will no longer be chosen as a result of a lookup by key
207 type. However, it is not deleted until its deletion time is also
208 reached.
209 .TP
210 .B "deletion time"
211 A key's deletion time is the latest expiry time of any of the objects
212 which require that key. For example, a key used for authenticating
213 cryptographic cookies should have its deletion time set to the longest
214 expiry time of any of the cookies it can authenticate. Once a key's
215 deletion time is passed, it can no longer be referred to by
216 applications, and will be removed from the keyring next time it's
217 written to disk.
218 .TP
219 .B "comment"
220 A key may be given a comment when it's created. The comment is for the
221 benefit of users, and isn't interpreted by applications at all.
222 (Hopefully.)
223 .TP
224 .B "attributes"
225 A key as zero or more name/value pairs. The names and values are
226 arbitrary strings, except they may not contain null bytes. Some
227 attributes may have meaning for particular applications or key types;
228 others may be assigned global meanings in future.
229 .SH "COMMAND REFERENCE"
230 .SS add
231 The
232 .B add
233 command creates a new key and adds it to the keyring. The command
234 accepts the following options:
235 .TP
236 .BI "\-a, \-\-algorithm " alg
237 Selects a key generation algorithm. The default algorithm is
238 .BR binary ;
239 the different algorithms are described below.
240 .TP
241 .BI "\-b, \-\-bits " bits
242 The length of the key to generate, in bits. The default, if this option
243 is not supplied, depends on the key-generation algorithm.
244 .TP
245 .BI "\-B, \-\-qbits " bits
246 The length of the subsidiary key or parameter, in bits. Not all
247 key-generation algorithms have a subsidiary key size.
248 .TP
249 .BI "\-p, \-\-parameters " tag
250 Selects a key containing parameter values to copy. Not all
251 key-generation algorithms allow the use of shared parameters.
252 .TP
253 .BI "\-e, \-\-expire " expire
254 The expiry date for the generated key. This may be the string
255 .RB ` forever '
256 if the key should never expire automatically, or any date acceptable to
257 the
258 .BR getdate (3)
259 library function. Briefly,
260 .B getdate
261 understands absolute dates such as
262 .RB ` 1999-08-02 '
263 or
264 .RB ` "August 2nd, 1999" ',
265 and (perhaps more usefully) relative dates such as
266 .RB ` "+2 weeks" '.
267 The default is to allow a 2 week expiry, which isn't useful.
268 .TP
269 .BI "\-c, \-\-comment " comment
270 Sets a comment for the key. The default is not to attach a comment.
271 .TP
272 .BI "\-t, \-\-tag " tag
273 Selects a tag string for the key. The default is not to set a tag. It
274 is an error to select a tag which already exists.
275 .TP
276 .BI "\-r, \-\-retag"
277 If a
278 .B \-t
279 option is given, remove this tag from any key which already has it.
280 .TP
281 .BI "\-R, \-\-rand-id " tag
282 Selects the key to use for the random number generator. Catacomb's
283 random number generator can be
284 .IR keyed ,
285 so that, even if the inputs to the generator are compromised, knowledge
286 of the key is also necessary to be able to predict the output. By
287 default, the latest-expiring key with type
288 .B catacomb-rand
289 is used, if present; if not, no key is used.
290 .TP
291 .BI "\-l, \-\-lock"
292 Requests that the secret parts of the newly-generated key be encrypted
293 using a passphrase.
294 .TP
295 .BI "\-q, \-\-quiet"
296 Suppresses the progress indication which is usually generated while
297 time-consuming key generation tasks are being performed.
298 .TP
299 .BI "\-L, --lim-lee"
300 When generating Diffie-Hellman parameters, generate a Lim-Lee prime
301 rather than a random (or safe) prime. See the details on Diffie-Hellman
302 key generation below.
303 .TP
304 .BI "\-S, --subgroup"
305 When generating Diffie-Hellman parameters with a Lim-Lee prime, choose a
306 generator of a prime-order subgroup rather than a subgroup of order
307 .RI ( p "- 1)/2."
308 .PP
309 The key's type is given by the required
310 .I type
311 argument. Following the type are zero or more attributes, which are
312 attached to the key in the same way as for the
313 .B setattr
314 command.
315 .PP
316 The key-generation algorithms supported are as follows:
317 .TP
318 .B "binary"
319 Generates a plain binary key of the requested length. If the requested
320 key length is not a multiple of eight, the high-order bits of the first
321 octet of the key are zeroed. The default key length is 128 bits.
322 .TP
323 .B "des"
324 Generates a DES key, with parity bits. The key length must be 56, 112
325 or 168; the default is 56. The low-order bit of each octet is ignored by
326 the DES algorithm; it is used to give each octet odd parity.
327 .TP
328 .B "rsa"
329 Generates a public/private key pair for use with the RSA algorithm.
330 .IP
331 The key components are
332 .I p
333 and
334 .IR q ,
335 a pair of prime numbers;
336 .IR n ,
337 the product of
338 .I p
339 and
340 .IR q ;
341 .IR e ,
342 the public exponent;
343 .IR d ,
344 the private exponent, chosen such that
345 .IR ed \ \(==\ 1
346 (mod
347 .RI ( p \ \-\ 1)( q \ \-\ 1));
348 and some other values useful for optimizing private-key operations:
349 .IR q \*(ss\-1\*(se\ mod\ p ,
350 .IR d \ mod\ p \ \-\ 1,
351 and
352 .IR d \ mod\ q \ \-\ 1.
353 The values
354 .I n
355 and
356 .I e
357 constitute the public key; the rest must be kept secret. The key size
358 requested by the
359 .B \-b
360 option determines the size of the modulus
361 .IR n ;
362 the default is 1024 bits.
363 .IP
364 The key generation algorithm chooses
365 .I p
366 and
367 .I q
368 to be
369 .I strong
370 primes: both
371 .IR p \ \-\ 1
372 and
373 .IR p \ +\ 1
374 have large prime factors \- call them
375 .I r
376 and
377 .I s
378 respectively \- and
379 .IR r \ \-\ 1
380 also has a large prime factor;
381 .I q
382 has similar properties.
383 .IP
384 The modulus
385 .I n
386 cannot be sensibly used as a shared parameter, since knowledge of
387 corrssponding public and private exponents is sufficient to be able to
388 factor the modulus and recover other users' private keys.
389 .TP
390 .B "dh-params"
391 Generates parameters for use with the Diffie-Hellman key exchange
392 protocol, and many related systems, such as ElGamal encryption and
393 signatures, and even DSA. (The separate DSA algorithm uses the
394 generator described in FIPS186-1.)
395 .IP
396 The Diffie-Hellman parameters are a prime modulus
397 .I p
398 and a generator
399 .I g
400 of a subgroup of
401 .BR Z / \c
402 .IB p Z
403 of order
404 .IR q .
405 The
406 .B \-b
407 option controls the size of the modulus
408 .IR p ;
409 the default size is 1024 bits.
410 .IP
411 If no
412 .I q
413 size is selected using the
414 .B \-B
415 option and the Lim-Lee prime option is disabled, then
416 .I p
417 is chosen to be a `safe' prime (i.e.,
418 .IR p \ =\ 2 q \ +\ 1,
419 with
420 .I q
421 prime). In this case, the value of
422 .I g
423 is fixed as 4.
424 .IP
425 If a size is chosen for
426 .I q
427 and Lim-Lee primes are not selected then the prime
428 .I q
429 is generated and
430 .I p
431 is chosen so that
432 .IR p \ \-\ 1
433 is a multiple of
434 .IR q .
435 .IP
436 If the
437 .B \-L
438 option was given Lim-Lee primes are selected: the parameters are chosen
439 such that
440 .IR p \ =\ 2\ q \*(us0\*(ue\ q \*(us1\*(ue\ q \*(us2\*(ue\ ...\ +\ 1,
441 where the
442 .IR q \*(us i\*(ue
443 are primes at least as large as the setting given by the
444 .B \-B
445 option (or 256 bits, if no setting was given).
446 .IP
447 If the
448 .B \-S
449 option was given, the generator
450 .I g
451 is chosen to generate the subgroup of order
452 .IR q \*(us0\*(ue;
453 otherwise,
454 .I g
455 will generate the group of order
456 .RI ( p \ \-\ 1)/2\ =\ q \*(us0\*(ue\ q \*(us1\*(ue\ q \*(us2\*(ue\ ...
457 .TP
458 .B "dh"
459 Generates a public/private key pair for use with offline Diffie-Hellman,
460 ElGamal, DSA or similar discrete-logarithm-based systems. It selects a
461 private key
462 .IR x \ <\ q ,
463 and computes the public key
464 .IR y \ =\ g\*(ssx\*(se \ mod\ p .
465 .TP
466 .B "dsa-param"
467 Generates parameters for the DSA algorithm. DSA parameters are also
468 suitable for use with Diffie-Hellman and ElGamal system.
469 .IP
470 The main difference between DSA and Diffie-Hellman parameter generation
471 is thatthe DSA parameter generation
472 algorithm creates a
473 .I seed
474 from which the parameters are derived, and, assuming that the SHA-1 hash
475 function is strong, it's not feasible to construct a seed from which
476 deliberately weak parameters are derived. The algorithm used is the one
477 described in the DSA standard, FIPS\ 186, extended only to allow
478 sequential search for a prime
479 .I q
480 and to allow arbitrary parameter sizes. The seed is stored,
481 Base64-encoded, as the value of the attribute
482 .BR seed .
483 .IP
484 The default lengths for
485 .I p
486 and
487 .I q
488 are 768 and 160 bits respectively, since the DSA standard specifies that
489 .I q
490 be 160 bits, and the choice of 768 bits for
491 .I p
492 gives commensurate security.
493 .TP
494 .B "dsa"
495 Generates a public/private key pair for DSA. As for Diffie-Hellman
496 keys, it selects a
497 private key
498 .IR x \ <\ q ,
499 and computes the public key
500 .IR y \ =\ g\*(ssx\*(se \ mod\ p .
501 .TP
502 .B "bbs"
503 Generates a public/private key pair for the Blum-Blum-Shub random-number
504 generator, and the Blum-Goldwasser semantically-secure public-key
505 encryption system.
506 .IP
507 The key components are prime numbers
508 .I p
509 and
510 .IR q ,
511 both congruent to 3 (mod\ 4), and their product
512 .IR n .
513 The public key is simply the modulus
514 .IR n ;
515 the factors
516 .I p
517 and
518 .I q
519 are the private key.
520 .IP
521 The key-generation algorithm ensures that the two primes
522 .I p
523 and
524 .I q
525 are
526 .I strong
527 (see the discussion of strong primes above, in the section on RSA keys),
528 and that
529 .RI ( p \ \-\ 1)/2
530 and
531 .RI ( q \ \-\ 1)/2
532 are relatively prime, giving a maximum possible period length.
533 .IP
534 The key size requested by the
535 .B \-b
536 option determines the length of the modulus
537 .IR n ;
538 the default length is 1024 bits.
539 .SS "expire"
540 Forces keys to immediately expire. An expired key is not chosen when a
541 program requests a key by its type. The keys to expire are listed by
542 their
543 .IR tag s.
544 .SS "delete"
545 Deletes keys immediately. The keys to delete are listed by their
546 .IR tag s.
547 Be careful when deleting keys. It might be a better idea
548 to expire keys rather than deleting them.
549 .SS "tag"
550 Sets, deletes or changes the tag attached to a key. The first tag or
551 keyid names the key to be modified; the second, if present specifies the
552 new tag to be set. If no second argument is given, the existing tag, if
553 any, is removed and no new tag is set. It is an error to set a tag
554 which already exists on another key, unless you give the
555 .B \-r
556 option, which removes the tag first.
557 .SS "setattr"
558 Attaches attributes to a key. The key to which the attributes should be
559 attached is given by its
560 .IR tag .
561 Each attribute has the form
562 .IB name = value\fR.
563 An attribute can be deleted by assigning it an empty value. Although
564 the keyring file format is capable of representing an attribute with an
565 empty value as distinct from a nonexistant attribute, this interface
566 does not allow empty attributes to be set.
567 .SS "comment"
568 Sets, deletes or changes the comment attached to a key. The first
569 argument is a key tag or keyid which names the key to be modified; the
570 second, if present, is the new comment. If no second argument is given,
571 the existing comment, if any, is removed, and no new comment is set.
572 .SS "lock"
573 Locks a key or key component using a passphrase. If the key is already
574 locked, the existing passphrase is requested, and a new passphrase is
575 set.
576 .SS "unlock"
577 Unlocks a passphrase-locked key or key component. If the key is not
578 locked, an error is reported.
579 .SS "list"
580 Lists the keys in the keyring. A couple of options are supported:
581 .TP
582 .B "\-v, \-\-verbose"
583 Increases the amount of information displayed for each key. Repeat for
584 a greater effect.
585 .TP
586 .B "\-q, \-\-quiet"
587 Decreases the amount of information displayed for each key. Each use
588 cancels a
589 .RB ` \-v '
590 option.
591 .TP
592 .B "\-u, \-\-utc"
593 Display key expiry times as UTC rather than using the local time zone.
594 .TP
595 .BI "\-f, \-\-filter " filter
596 Specifies a filter. Only keys and key components which match the filter
597 are listed.
598 .PP
599 By default, a single line of output is generated for each, showing
600 keyids, types, expiry and deletion dates, and comments. Additional
601 .RB ` \-v '
602 options show more information, such as the exact time of day for expiry
603 and deletion, key attributes, and a dump of the actual key data. If the
604 verbosity level is sufficiently high, passphrases are requested to
605 decrypt locked keys. Make sure nobody is looking over your shoulder
606 when you do this!
607 .SS "fingerprint"
608 Reports a fingerprint (secure hash) on components of requested keys.
609 The following option is supported:
610 .TP
611 .BI "\-f, \-\-filter " filter
612 Specifies a filter. Only keys and key components which match the filter
613 are fingerprinted. The default is to only fingerprint nonsecret
614 components.
615 .PP
616 The keys to be fingerprinted are named by their tags or keyids given as
617 command line arguments. If no key tags are given, all keys which match
618 the filter are fingerprinted.
619 .SS "tidy"
620 Simply reads the keyring from file and writes it back again. This has
621 the effect of removing any deleted keys from the file.
622 .SS "extract"
623 Writes a selection of keys to a file. An option is supported:
624 .TP
625 .BI "\-f, \-\-filter " filter
626 Specifies a filter. Only keys and key components which match the filter
627 are written.
628 .PP
629 Keys extracted are written to the file named by the first argument,
630 which may be
631 .RB ` \- '
632 to designate standard output. The keys to extract are listed by their
633 tags; if no tags are given, all keys which match the filter are
634 extracted. The output is a valid keyring file.
635 .SS "merge"
636 Merges the keys from the named
637 .IR file ,
638 which may be
639 .RB ` \- '
640 to designate standard input, with the keyring. Keys already in the
641 keyring are not overwritten: you must explicitly remove them first if
642 you want them to be replaced during the merge.
643 .SH "SEE ALSO"
644 .BR keyring (5).
645 .SH AUTHOR
646 Mark Wooding, <mdw@nsict.org>
647