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