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