Copy cookie into Catacomb.
[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. A new key
271also inherits attributes from its parameter key.
272.TP
273.BI "\-e, \-\-expire " expire
274The expiry date for the generated key. This may be the string
275.RB ` forever '
276if the key should never expire automatically, or any date acceptable to
277the
278.BR getdate (3)
279library function. Briefly,
280.B getdate
281understands absolute dates such as
282.RB ` 1999-08-02 '
283or
284.RB ` "August 2nd, 1999" ',
285and (perhaps more usefully) relative dates such as
286.RB ` "+2 weeks" '.
287The default is to allow a 2 week expiry, which isn't useful.
288.TP
289.BI "\-c, \-\-comment " comment
290Sets a comment for the key. The default is not to attach a comment.
291.TP
292.BI "\-C, \-\-curve " curve-spec
293Use the elliptic curve described by
294.I curve-spec
295when generating elliptic curve parameters.
296.TP
297.BI "\-t, \-\-tag " tag
298Selects a tag string for the key. The default is not to set a tag. It
299is an error to select a tag which already exists.
300.TP
301.BI "\-r, \-\-retag"
302If a
303.B \-t
304option is given, remove this tag from any key which already has it.
305.TP
306.BI "\-R, \-\-rand-id " tag
307Selects the key to use for the random number generator. Catacomb's
308random number generator can be
309.IR keyed ,
310so that, even if the inputs to the generator are compromised, knowledge
311of the key is also necessary to be able to predict the output. By
312default, the latest-expiring key with type
313.B catacomb-rand
314is used, if present; if not, no key is used.
315.TP
316.BI "\-l, \-\-lock"
317Requests that the secret parts of the newly-generated key be encrypted
318using a passphrase.
319.TP
320.BI "\-q, \-\-quiet"
321Suppresses the progress indication which is usually generated while
322time-consuming key generation tasks are being performed.
323.TP
324.BI "\-L, --lim-lee"
325When generating Diffie-Hellman parameters, generate a Lim-Lee prime
326rather than a random (or safe) prime. See the details on Diffie-Hellman
327key generation below.
328.TP
329.BI "\-S, --subgroup"
330When generating Diffie-Hellman parameters with a Lim-Lee prime, choose a
331generator of a prime-order subgroup rather than a subgroup of order
332.RI ( p "- 1)/2."
333.PP
334The key's type is given by the required
335.I type
336argument. Following the type are zero or more attributes, which are
337attached to the key in the same way as for the
338.B setattr
339command.
340.PP
341The key-generation algorithms supported are as follows:
342.TP
343.B "binary"
344Generates a plain binary key of the requested length. If the requested
345key length is not a multiple of eight, the high-order bits of the first
346octet of the key are zeroed. The default key length is 128 bits.
347.TP
348.B "des"
349Generates a DES key, with parity bits. The key length must be 56, 112
350or 168; the default is 56. The low-order bit of each octet is ignored by
351the DES algorithm; it is used to give each octet odd parity.
352.TP
353.B "rsa"
354Generates a public/private key pair for use with the RSA algorithm.
355.IP
356The key components are
357.I p
358and
359.IR q ,
360a pair of prime numbers;
361.IR n ,
362the product of
363.I p
364and
365.IR q ;
366.IR e ,
367the public exponent;
368.IR d ,
369the private exponent, chosen such that
370.IR ed \ \(==\ 1
371(mod
372.RI ( p \ \-\ 1)( q \ \-\ 1));
373and some other values useful for optimizing private-key operations:
374.IR q \*(ss\-1\*(se\ mod\ p ,
375.IR d \ mod\ p \ \-\ 1,
376and
377.IR d \ mod\ q \ \-\ 1.
378The values
379.I n
380and
381.I e
382constitute the public key; the rest must be kept secret. The key size
383requested by the
384.B \-b
385option determines the size of the modulus
386.IR n ;
387the default is 1024 bits.
388.IP
389The key generation algorithm chooses
390.I p
391and
392.I q
393to be
394.I strong
395primes: both
396.IR p \ \-\ 1
397and
398.IR p \ +\ 1
399have large prime factors \- call them
400.I r
401and
402.I s
403respectively \- and
404.IR r \ \-\ 1
405also has a large prime factor;
406.I q
407has similar properties.
408.IP
409The modulus
410.I n
411cannot be sensibly used as a shared parameter, since knowledge of
412corrssponding public and private exponents is sufficient to be able to
413factor the modulus and recover other users' private keys.
414.TP
415.B "dh-param"
416Generates parameters for use with the Diffie-Hellman key exchange
417protocol, and many related systems, such as ElGamal encryption and
418signatures, and even DSA. (The separate DSA algorithm uses the
419generator described in FIPS186-1.)
420.IP
421The Diffie-Hellman parameters are a prime modulus
422.I p
423and a generator
424.I g
425of a subgroup of
426.BR Z / \c
427.IB p Z
428of order
429.IR q .
430The
431.B \-b
432option controls the size of the modulus
433.IR p ;
434the default size is 1024 bits.
435.IP
436If no
437.I q
438size is selected using the
439.B \-B
440option and the Lim-Lee prime option is disabled, then
441.I p
442is chosen to be a `safe' prime (i.e.,
443.IR p \ =\ 2 q \ +\ 1,
444with
445.I q
446prime). Finding safe primes takes a very long time. In this case, the
447value of
448.I g
449is fixed as 4.
450.IP
451If a size is chosen for
452.I q
453and Lim-Lee primes are not selected then the prime
454.I q
455is generated and
456.I p
457is chosen so that
458.IR p \ \-\ 1
459is a multiple of
460.IR q .
461.IP
462If the
463.B \-L
464option was given Lim-Lee primes are selected: the parameters are chosen
465such that
466.IR p \ =\ 2\ q \*(us0\*(ue\ q \*(us1\*(ue\ q \*(us2\*(ue\ ...\ +\ 1,
467where the
468.IR q \*(us i\*(ue
469are primes at least as large as the setting given by the
470.B \-B
471option (or 256 bits, if no setting was given).
472.IP
473If the
474.B \-S
475option was given, the generator
476.I g
477is chosen to generate the subgroup of order
478.IR q \*(us0\*(ue;
479otherwise,
480.I g
481will generate the group of order
482.RI ( p \ \-\ 1)/2\ =\ q \*(us0\*(ue\ q \*(us1\*(ue\ q \*(us2\*(ue\ ...
483.IP
484Finally, the
485.B \-C
486option can be given, in which case the parameters are taken directly
487from the provided group specification, which may either be the the name
488of one of the built-in groups (say
489.B "key add \-a dh\-param \-C list 42"
490for a list) or a triple
491.RI ( p ,\ q ,\ g ).
492separated by commas. No random generation is done in this case: the
493given parameters are simply stored.
494.TP
495.B "dh"
496Generates a public/private key pair for use with offline Diffie-Hellman,
497ElGamal, DSA or similar discrete-logarithm-based systems. It selects a
498private key
499.IR x \ <\ q ,
500and computes the public key
501.IR y \ =\ g\*(ssx\*(se \ mod\ p .
502.TP
503.B "dsa-param"
504Generates parameters for the DSA algorithm. DSA parameters are also
505suitable for use with Diffie-Hellman and ElGamal system.
506.IP
507The main difference between DSA and Diffie-Hellman parameter generation
508is thatthe DSA parameter generation
509algorithm creates a
510.I seed
511from which the parameters are derived, and, assuming that the SHA-1 hash
512function is strong, it's not feasible to construct a seed from which
513deliberately weak parameters are derived. The algorithm used is the one
514described in the DSA standard, FIPS\ 186, extended only to allow
515sequential search for a prime
516.I q
517and to allow arbitrary parameter sizes. The seed is stored,
518Base64-encoded, as the value of the attribute
519.BR seed .
520.IP
521The default lengths for
522.I p
523and
524.I q
525are 768 and 160 bits respectively, since the DSA standard specifies that
526.I q
527be 160 bits, and the choice of 768 bits for
528.I p
529gives commensurate security.
530.TP
531.B "dsa"
532Generates a public/private key pair for DSA. As for Diffie-Hellman
533keys, it selects a
534private key
535.IR x \ <\ q ,
536and computes the public key
537.IR y \ =\ g\*(ssx\*(se \ mod\ p .
538.TP
539.B "bbs"
540Generates a public/private key pair for the Blum-Blum-Shub random-number
541generator, and the Blum-Goldwasser semantically-secure public-key
542encryption system.
543.IP
544The key components are prime numbers
545.I p
546and
547.IR q ,
548both congruent to 3 (mod\ 4), and their product
549.IR n .
550The public key is simply the modulus
551.IR n ;
552the factors
553.I p
554and
555.I q
556are the private key.
557.IP
558The key-generation algorithm ensures that the two primes
559.I p
560and
561.I q
562are
563.I strong
564(see the discussion of strong primes above, in the section on RSA keys),
565and that
566.RI ( p \ \-\ 1)/2
567and
568.RI ( q \ \-\ 1)/2
569are relatively prime, giving a maximum possible period length.
570.IP
571The key size requested by the
572.B \-b
573option determines the length of the modulus
574.IR n ;
575the default length is 1024 bits.
576.TP
577.B "ec-param"
578Store an elliptic curve specification. If no explicit
579.I curve-spec
580is given (the
581.RB ` \-C '
582option) then a curve is chosen whose order is about the size given by the
583.RB ` \-b '
584option (default is 256 bits).
585.IP
586A
587.I curve-spec
588can be given explicitly (in which case
589.RB ` \-b '
590is ignored). It can either be the name of a built-in curve (say
591.B "key add \-a ec\-param \-C list 42"
592for a list of curve names) or a full specification. The curve is
593checked for correctness and security according to the SEC1
594specification: failed checks cause a warning to be issued to standard
595error (though the program continues anyway). The check can be
596suppressed using the
597.RB ` \-q '
598option.
599.IP
600A curve specification consists of the following elements optionally
601separated by whitespace: a
602.IR "field type" ,
603which is one of
604.BR "prime" ,
605.BR "niceprime" ,
606.BR "binpoly" ,
607.or
608.BR "binnorm" ;
609an optional
610.RB ` : ';
611the field modulus
612.IR p ;
613if the field type is
614.B binnorm
615then an optional
616.RB ` , '
617and the representation of the normal element \*(*b; an optional
618.RB ` / ';
619a
620.IR "curve type" ,
621which is one of
622.BR "prime" ,
623.BR "primeproj" ,
624.BR "bin" ,
625and
626.BR "binproj"
627(the `proj' types currently have much better performance);
628an optional
629.RB ` : ';
630the two field-element parameters
631.I a
632and
633.IR b
634which define the elliptic curve
635.IR E ,
636separated by an optional
637.RB ` , ';
638an optional
639.RB ` / ';
640the
641.IR x -
642and
643.IR y -coordinates
644of the generator point
645.IR G ,
646separated by an optional
647.RB ` , ';
648an optional
649.RB ` : ';
650the order
651.I r
652of the group generated by
653.IR G ;
654an optional
655.RB ` * ';
656and the
657.I cofactor
658.I h
659=
660.RI # E / r .
661.TP
662.B "ec"
663Generate a private scalar and a corresponding public point on an
664elliptic curve. See
665.B ec-param
666above for how to specify elliptic curve parameter sets. The scalar
667.I x
668is chosen unformly between 0 and the curve order
669.IR r ;
670the public point is then
671.I x
672\(mu
673.IR G .
674.SS "expire"
675Forces keys to immediately expire. An expired key is not chosen when a
676program requests a key by its type. The keys to expire are listed by
677their
678.IR tag s.
679.SS "delete"
680Deletes keys immediately. The keys to delete are listed by their
681.IR tag s.
682Be careful when deleting keys. It might be a better idea
683to expire keys rather than deleting them.
684.SS "tag"
685Sets, deletes or changes the tag attached to a key. The first tag or
686keyid names the key to be modified; the second, if present specifies the
687new tag to be set. If no second argument is given, the existing tag, if
688any, is removed and no new tag is set. It is an error to set a tag
689which already exists on another key, unless you give the
690.B \-r
691option, which removes the tag first.
692.SS "setattr"
693Attaches attributes to a key. The key to which the attributes should be
694attached is given by its
695.IR tag .
696Each attribute has the form
697.IB name = value\fR.
698An attribute can be deleted by assigning it an empty value. Although
699the keyring file format is capable of representing an attribute with an
700empty value as distinct from a nonexistant attribute, this interface
701does not allow empty attributes to be set.
702.SS "comment"
703Sets, deletes or changes the comment attached to a key. The first
704argument is a key tag or keyid which names the key to be modified; the
705second, if present, is the new comment. If no second argument is given,
706the existing comment, if any, is removed, and no new comment is set.
707.SS "lock"
708Locks a key or key component using a passphrase. If the key is already
709locked, the existing passphrase is requested, and a new passphrase is
710set.
711.SS "unlock"
712Unlocks a passphrase-locked key or key component. If the key is not
713locked, an error is reported.
714.SS "list"
715Lists the keys in the keyring. A couple of options are supported:
716.TP
717.B "\-v, \-\-verbose"
718Increases the amount of information displayed for each key. Repeat for
719a greater effect.
720.TP
721.B "\-q, \-\-quiet"
722Decreases the amount of information displayed for each key. Each use
723cancels a
724.RB ` \-v '
725option.
726.TP
727.B "\-u, \-\-utc"
728Display key expiry times as UTC rather than using the local time zone.
729.TP
730.BI "\-f, \-\-filter " filter
731Specifies a filter. Only keys and key components which match the filter
732are listed.
733.PP
734By default, a single line of output is generated for each, showing
735keyids, types, expiry and deletion dates, and comments. Additional
736.RB ` \-v '
737options show more information, such as the exact time of day for expiry
738and deletion, key attributes, and a dump of the actual key data. If the
739verbosity level is sufficiently high, passphrases are requested to
740decrypt locked keys. Make sure nobody is looking over your shoulder
741when you do this!
742.SS "fingerprint"
743Reports a fingerprint (secure hash) on components of requested keys.
744The following option is supported:
745.TP
746.BI "\-f, \-\-filter " filter
747Specifies a filter. Only keys and key components which match the filter
748are fingerprinted. The default is to only fingerprint nonsecret
749components.
750.TP
751.BI "\-a, \-\-algorithm " hash
752Names the hashing algorithm. Run
753.B hashsum -a list
754for a list of hashing algorithms. The default is
755.BR rmd160 .
756.PP
757The keys to be fingerprinted are named by their tags or keyids given as
758command line arguments. If no key tags are given, all keys which match
759the filter are fingerprinted. See
760.BR keyring (5)
761for a description of how key fingerprints are computed.
762.SS "tidy"
763Simply reads the keyring from file and writes it back again. This has
764the effect of removing any deleted keys from the file.
765.SS "extract"
766Writes a selection of keys to a file. An option is supported:
767.TP
768.BI "\-f, \-\-filter " filter
769Specifies a filter. Only keys and key components which match the filter
770are written.
771.PP
772Keys extracted are written to the file named by the first argument,
773which may be
774.RB ` \- '
775to designate standard output. The keys to extract are listed by their
776tags; if no tags are given, all keys which match the filter are
777extracted. The output is a valid keyring file.
778.SS "merge"
779Merges the keys from the named
780.IR file ,
781which may be
782.RB ` \- '
783to designate standard input, with the keyring. Keys already in the
784keyring are not overwritten: you must explicitly remove them first if
785you want them to be replaced during the merge.
786.SH "SEE ALSO"
787.BR keyring (5).
788.SH AUTHOR
789Mark Wooding, <mdw@nsict.org>
790