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