Eliminate buggy clone-and-hack keyreport functions.
[u/mdw/catacomb] / catsign.1
CommitLineData
fa54fe1e 1.\" -*-nroff-*-
2.de VS
3.sp 1
4.RS
5.nf
6.ft B
7..
8.de VE
9.ft R
10.fi
11.RE
12.sp 1
13..
14.ie t \{\
15. if \n(.g \{\
16. fam P
17. \}
18.\}
19.de hP
20.IP
21.ft B
22\h'-\w'\\$1\ 'u'\\$1\ \c
23.ft P
24..
25.ie t .ds o \(bu
26.el .ds o o
27.TH catsign 1 "17 March 2005" "Straylight/Edgeware" "Catacomb cryptographic library"
28.SH NAME
29catsign \- sign and verify messages
30.SH SYNOPSIS
31.B catsign
32.RB [ \-k
33.IR keyring ]
34.I command
35.PP
36where
37.I command
38is one of:
39.PP
40.B help
41.RI [ command ...]
42.br
43.B show
44.RI [ item ...]
45.br
46.B sign
47.RB [ \-adt ]
48.RB [ \-k
49.IR tag ]
50.RB [ \-f
51.IR format ]
52.RB [ \-o
53.IR output ]
54.RI [ file ]
55.br
56.B verify
57.RB [ \-aquv ]
58.RB [ \-k
59.IR tag ]
60.RB [ \-f
61.IR format ]
9cea6911 62.RB [ \-t
63.IR time ]
fa54fe1e 64.br
65
66.RB [ \-o
67.IR output ]
68.RI [ file
69.RI [ message ]]
70.br
71.B info
72.RB [ \-a ]
73.RB [ \-f
74.IR format ]
75.RI [ file ]
76.br
77.B format
78.RB [ \-auABDET ]
79.RB [ \-f
80.IR format ]
81.RB [ \-F
82.IR format ]
83.br
84
85.RB [ \-m
86.IR file ]
87.RB [ \-o
88.IR output ]
89.RI [ file
90.RI [ message ]]
91.br
92.B encode
93.RB [ \-f
94.IR format ]
95.RB [ \-b
96.IR boundary ]
97.RB [ \-o
98.IR output ]
99.RI [ file ]
100.br
101.B decode
102.RB [ \-f
103.IR format ]
104.RB [ \-b
105.IR boundary ]
106.RB [ \-o
107.IR output ]
108.RI [ file ]
109.SH "DESCRIPTION"
110The
111.B catsign
112command signs and verifies messages. It also works as a simple PEM
113encoder and decoder. It provides a number of subcommands, by which the
114various operations may be carried out.
115.SS "Global options"
116Before the command name,
117.I "global options"
118may be given. The following global options are supported:
119.TP
120.BR "\-h, \-\-help " [ \fIcommand ...]
121Writes a brief summary of
122.BR catsign 's
123various options to standard output, and returns a successful exit
124status. With command names, gives help on those commands.
125.TP
126.B "\-v, \-\-version"
127Writes the program's version number to standard output, and returns a
128successful exit status.
129.TP
130.B "\-u, \-\-usage"
131Writes a very terse command line summary to standard output, and returns
132a successful exit status.
133.TP
134.BI "\-k, \-\-keyring " file
135Names the keyring file which
136.B key
137is to process. The default keyring, used if this option doesn't specify
138one, is the file named
139.B keyring
140in the current directory. See
141.BR key (1)
142and
143.BR keyring (5)
144for more details about keyring files.
145.SH "KEY SETUP"
146Algorithms to be used with a particular key are described by attributes
147on the key, or its type. The
148.B catsign
149command deals with signing keys. (Note that
150.B catsign
151uses signing keys in the same way as
152.BR catcrypt (1).)
153.PP
154A
155.I sigalgspec
156has the form
157.IR sig \c
158.RB [ / \c
159.IR hash ].
160If a
161.B sig
162attribute is present on the key, then it must have this form; otherwise,
163the key's type must have the form
164.BI ccsig- \c
165.IR sigalgspec .
166Algorithm selections are taken from appropriately-named attributes, or,
167failing that, from the
168.IR sigalgspec .
169.PP
170The signature algorithm is chosen according to the setting of
171.I sig
172as follows. Run
173.B catsign show sig
174for a list of supported signature algorithms.
175.TP
176.B rsapkcs1
177This is almost the same as the RSASSA-PKCS1-v1_5 algorithm described in
178RFC3447; the difference is that the hash is left bare rather than being
179wrapped in a DER-encoded
180.B DigestInfo
181structure. This doesn't affect security since the key can only be used
182with the one hash function anyway, and dropping the DER wrapping permits
183rapid adoption of new hash functions. Regardless, use of this algorithm
184is not recommended, since the padding method has been shown vulnerable
185to attack. Use the
186.B rsa
187algorithm of the
188.B key add
189command (see
190.BR key (1))
191to generate the key.
192.TP
193.B rsapss
194This is the RSASSA-PSS algorithm described in RFC3447. It is the
195preferred RSA-based signature scheme. Use the
196.B rsa
197algorithm of the
198.B key add
199command (see
200.BR key (1))
201to generate the key.
202.TP
203.B dsa
204This is the DSA algorithm described in FIPS180-1 and FIPS180-2. Use the
205.B dsa
206algorithm of the
207.B key add
208command (see
209.BR key (1))
210to generate the key.
211.TP
212.B ecdsa
213This is the ECDSA algorithm described in ANSI X9.62 and FIPS180-2. Use
214the
215.B ec
216algorithm of the
217.B key add
218command (see
219.BR key (1))
220to generate the key.
221.TP
222.B kcdsa
223This is the revised KCDSA (Korean Certificate-based Digital Signature
224Algorithm) described in
225.I The Revised Version of KCDSA
226.RB ( http://dasan.sejong.ac.kr/~chlim/pub/kcdsa1.ps ).
227Use the
228.B dh
229algorithm of the
230.B key add
231command with the
232.B \-LS
233options (see
234.BR key (1))
235to generate the key.
236.TP
237.B eckcdsa
238This is an unofficial elliptic-curve analogue of the KCDSA algorithm.
239Use the
240.B ec
241algorithm of the
242.B key add
243command (see
244.BR key (1))
245to generate the key.
246.PP
247As well as the signature algorithm itself, a hash function is used.
248This is taken from the
249.B hash
250attribute on the key, or, failing that, from the
251.I hash
252specified in the
253.IR sigalgspec ,
254or, if that is absent, determined by the signature algorithm as follows.
255.hP \*o
256For
257.BR rsapkcs1 ,
258.BR rsapss ,
259.BR dsa ,
260and
261.BR ecdsa ,
262the default hash function is
263.BR sha .
264.hP \*o
265For
266.BR kcdsa
267and
268.BR eckcdsa ,
269the default hash function is
270.BR has160 .
271.PP
272Run
273.B catsign show hash
274for a list of supported hash functions.
275.SH "ENCODINGS"
276Two encodings for the ciphertext are supported.
277.TP
278.B binary
279The raw format, which has the benefit of being smaller, but needs to be
280attached to mail messages and generally handled with care.
281.TP
282.B pem
283PEM-encapsulated Base-64 encoded text. This format can be included
284directly in email and picked out again automatically; but there is a
2854-to-3 data expansion as a result.
286.SH "SIGNATURE FORMATS"
287There are two basic signature formats understood by
288.BR catsign .
289.hP \*o
290Embedded signatures include (embed) the message they sign; hence they're
291complete in and of themselves. The
292.B catsign
293program extracts the message during signature verification.
294.hP \*o
295Detached signatures are separate from the messages they sign, and both
296the original file and the signature are required for a successful
297verification.
298.PP
299Another important distinction is whether the message data is considered
300to be plain text or raw binary data.
301.hP \*o
302When dealing with plain text,
303.B catsign
304allows a limited quantity of leeway in the messages it processes. It
305ignores trailing whitespace on a line, including stray carriage-returns,
306which may appear if Windows boxes have had their way with the data. It
307also appends a final newline if there wasn't one before. In embedded
308signatures, the text is left unencoded, so that the message is readable.
309.hP \*o
310Binary files are preserved completely, and no variation whatever is
311permitted.
312.PP
313The
314.VS
315catsign format
316.VE
317command can convert between detached and embedded signatures; it cannot
318convert between binary and text mode signatures. (The data actually
319signed includes a flag saying whether the message is textual. The
320rationale here is that what looks like an ASCII space before a newline
321may be devastatingly significant in a binary data file, and if a message
322is signed as raw binary then no changes whatever should be allowed.)
323.SH "COMMAND REFERENCE"
324.SS help
325The
326.B help
327command behaves exactly as the
328.B \-\-help
329option. With no arguments, it shows an overview of
330.BR catsign 's
331options; with arguments, it describes the named subcommands.
332.SS show
333The
334.B show
335command prints various lists of tokens understood by
336.BR catsign .
337With no arguments, it prints all of the lists; with arguments, it prints
338just the named lists, in order. The recognized lists can be enumerated
339using the
340.VS
341catsign show list
342.VE
343command. The lists are as follows.
344.TP
345.B list
346The lists which can be enumerated by the
347.B show
348command.
349.TP
350.B sig
351The signature algorithms which can be used in a signing key's
352.B sig
353attribute.
354.TP
355.B hash
356The hash functions which can be used in a key's
357.B hash
358attribute.
359.TP
360.B enc
361The encodings which can be applied to encrypted messages; see
362.B ENCODINGS
363above.
364.SS sign
365The
366.B sign
367command signs a message and writes out an appropriately-encoded
368signature. By default, it reads a message from standard input and
369writes the signature to standard output. If a filename argument is
370given, this file is read instead.
371.PP
372The following options are recognized.
373.TP
374.B "\-a, \-\-armour"
375Produce ASCII-armoured output. This is equivalent to specifying
376.BR "\-f pem" .
377The variant spelling
378.B "\-\-armor"
379is also accepted.
380.TP
381.B "\-b, \-\-binary"
382Read and sign the input as binary data. The default is to treat the
383input as text.
384.TP
385.B "\-d, \-\-detach"
386Produce a detached signature. The default is to produce a signature
387with embedded message.
388.TP
389.BI "\-f, \-\-format " format
390Produce output encoded according to
391.IR format .
392.TP
393.BI "\-k, \-\-key " tag
394Use the signing key named
395.I tag
396in the current keyring; the default key is
397.BR ccsig .
398.TP
399.BI "\-o, \-\-ouptut " file
400Write output to
401.I file
402rather than to standard output.
403.TP
404.B "\-t, \-\-text"
405Read and sign the input as text. This is the default.
406.SS verify
407The
408.B verify
409command checks a signature's validity, producing as output information
410about the signature and the signed message.
411.PP
412The first non-option argument is the name of the file containing the
413signature data; this may be omitted or
414.RB ` \- '
415to indicate that the signature be read from standard input. The second
416non-option argument, if any, is the name of the file to read the message
417from, if the signature is detached. An error is reported if a message
418file is specified but the signature contains an embedded message
419already; if the signature is detached but no filename is given, then the
420message is expected on stdin (immediately after the signature, if any).
421.TP
422.B "\-a, \-\-armour"
423Read ASCII-armoured input. This is equivalent to specifying
424.BR "\-f pem" .
425The variant spelling
426.B "\-\-armor"
427is also accepted.
428.TP
429.B "\-b, \-\-buffer"
430Buffer the message until the signature is verified. This is forced on
431if output is to stdout, but is always available as an option.
432.TP
433.BI "\-f, \-\-format " format
434Read input encoded according to
435.IR format .
436.TP
437.B "\-v, \-\-verbose"
438Produce more verbose messages. See below for the messages produced
439during decryption. The default verbosity level is 1. (Currently this
440is the most verbose setting. This might not be the case always.)
21aac40c 441.TP
fa54fe1e 442.B "\-q, \-\-quiet"
443Produce fewer messages.
444.TP
445.BI "\-k, \-\-key " tag
446Usually
447.B catsign
448uses the signature header to work out which key to use to verify a
449signature. Using this option causes verification to fail unless the
450signature header specifies the key named
451.IR tag .
452.TP
9cea6911 453.BI "\-t, \-\-freshtime " time
454Only accept signatures claiming to have been made more recently than
455.IR time .
456If
457.I time
458is
459.B always
460(the default) then any timestamp in the past is acceptable.
461.TP
fa54fe1e 462.B "\-u, \-\-utc"
463Show the datestamp in the signature in UTC rather than (your) local
464time. The synonym
465.B \-\-gmt
466is also accepted.
467.TP
468.BI "\-o, \-\-output " file
469Write the verified message to
470.IR file .
471The file is written in text or binary
472mode as appropriate. The default is to write the message to standard
473output unless verifying a detached signature, in which case nothing is
474written.
475.PP
476Output is written to standard output in a machine-readable format.
477Major problems cause the program to write a diagnostic to standard error
478and exit nonzero as usual. The quantity of output varies depending on
479the verbosity level and whether the message is also being written to
480standard output. Output lines begin with a keyword:
481.TP
482.BI "FAIL " reason
483An error prevented verification. The program will exit nonzero.
484.TP
485.BI "WARN " reason
486.B catsign
487encountered a situation which may or may not invalidate the
488verification.
489.TP
490.BI "OK " message
491Verification was successful. This is only produced if the message is
492being sent somewhere other than standard output.
493.TP
494.B "DATA"
495The message follows, starting just after the next newline character or
496sequence. This is only produced if the message is being written to
497standard output.
498.TP
499.BI "INFO " note
500Any other information.
501.PP
502The information written at the various verbosity levels is as follows.
503.hP 0.
504No output. Watch the exit status.
505.hP 1.
506All messages.
507.PP
508.B Warning!
509All output written has been checked for authenticity. However, output
510can fail madway through for many reasons, and the resulting message may
511therefore be truncated. Don't rely on the output being complete until
4224d0b9 512.B OK
513is printed or
fa54fe1e 514.B catsign verify
515exits successfully.
516.SS info
517The
518.B info
519command analyses a signature without verifying it, and prints
520interesting information about it. This might be useful for diagnostic
521purposes. No keys are needed for this operation, though you get more
522useful information if you have them.
523.PP
524If a non-option argument is given, and it is not
525.RB ` \- ',
526then it is taken to name the file containing the signature to parse;
527otherwise a signature is read from standard input.
528.PP
529The following options are recognized.
530.TP
531.B "\-a, \-\-armour"
532Read ASCII-armoured input. This is equivalent to specifying
533.BR "\-f pem" .
534The variant spelling
535.B "\-\-armor"
536is also accepted.
537.TP
538.BI "\-f, \-\-format " format
539Read input encoded according to
540.IR format .
541.TP
542.B "\-u, \-\-utc"
543Show the datestamp in the signature in UTC rather than (your) local
544time. The synonym
545.B \-\-gmt
546is also accepted.
547.PP
548A description of the signature block is produced on standard output; it
549is mostly machine-readable. The first word on each line explains what
550kind of output it is.
551.TP
552.BI "BAD " message
553The signature data is invalid and cannot be parsed.
554.TP
555.BI "WARN " message
556Something is wrong with the data, but isn't fatal.
557.TP
558.BI "NOTE " message
559An environmental problem means that the information isn't as helpful as
560it might be. For example, the keyring file can't be opened, so we don't
561know whether the verification key is there.
562.TP
563.BI "INFO flags " flags
564Describes the flags set in the signature header. The
565.I flags
566are a list of flags, one per word, preceded by a
567.RB ` ! '
568if the flag is clear.
569.TP
570.BI "INFO expected-flags " flags
571If the PEM boundary string didn't match the actual signature data then
572this line is output, listing the expected flags and their settings.
573Problems with boundary mismatches can be resolved using the
574.B format
575command.
576.TP
577.BI "INFO date " yyyy "\-" mm "\-" dd " " hh ":" mm ":" ss " " tz
578Signature was (allegedly!) made at the given time and date. If the
579.B \-u
580option was given, this will be in UTC.
581.TP
582.BI "INFO key " tag
583Signature was (allegedly!) made using the key
584.IR tag ,
585which is present in the current keyring.
586.TP
587.BI "INFO unknown-key " keyid
588Signature was (allegedly!) made using the key with id
589.IR keyid
590which is not in the current keyring (or the keyring wasn't found).
591.SS format
592The
593.B format
594command translates signatures between the various supported formats.
595This is a (slightly) more complex operation than re-encoding, though it
596does not require any cryptographic operations.
597.PP
598The first non-option argument is the name of the file containing the
599signature data; this may be omitted or
600.RB ` \- '
601to indicate that the signature be read from standard input. The second
602non-option argument, if any, is the name of the file to read the message
603from, if the signature is detached. An error is reported if a message
604file is specified but the signature contains an embedded message
605already; if the signature is detached but no filename is given, then the
606message is expected on stdin (immediately after the signature, if any).
607.PP
608The options follow a rough convention: options describing the input
609format are lower-case and options specifying the output format are
610upper-case. The following options are recognized.
0ac1f186 611.TP
612.BI "\-a, \-\-armour-in"
fa54fe1e 613Read ASCII-armoured input. This is equivalent to specifying
614.BR "\-f pem" .
615The variant spelling
616.B "\-\-armor"
617is also accepted.
0ac1f186 618.TP
619.BI "\-A, \-\-armour-out"
fa54fe1e 620Produce ASCII-armoured output. This is equivalent to specifying
621.BR "\-F pem" .
622The variant spelling
623.B "\-\-armor-out"
624is also accepted.
625.TP
626.B "\-D, \-\-detach"
627Produce a detached signature. This may be used to detach a signature
628from an embedded message.
629.TP
630.B "\-E, \-\-embed"
631Produce a signature with embedded message. This may be used to
632reattach a message to its detached signature.
633.TP
634.BI "\-f, \-\-format-in " format
635Read input encoded according to
636.IR format .
637.TP
638.BI "\-F, \-\-format-out " format
639Produce output encoded according to
640.IR format .
641.TP
642.BI "\-m, \-\-message " file
643Write the message to
644.IR file .
645If
646.I file
647is
648.RB ` \- '
649then write the message to standard output. Don't send the message and
650signature to the same place because it doesn't work.
651.TP
652.BI "\-o, \-\-output " file
653Write the signature to
654.IR file .
655If no
656.B \-m
657or
658.B \-o
659option is given, a signature is written to standard output.
e1cba07d 660.SS "encode"
661The
662.B encode
663command encodes an input file according to one of the encodings
664described above in
665.BR ENCODINGS .
666The input is read from the
667.I file
668given on the command line, or from standard input if none is specified.
669Options provided are:
670.TP
671.BI "\-f, \-\-format " format
672Produce output in
673.IR format .
674Run
65802cb1 675.B catsign show enc
e1cba07d 676for a list of encoding formats.
677.TP
678.BI "\-b, \-\-boundary " label
679Set the PEM boundary string to
680.IR label ;
681i.e., assuming we're encoding in PEM format, the output will have
682.BI "\-\-\-\-\-BEGIN " label "\-\-\-\-\-"
683at the top and
684.BI "\-\-\-\-\-END " label "\-\-\-\-\-"
685at the bottom. The default
686.I label
687is
688.BR MESSAGE .
689.TP
690.BI "\-o, \-\-output " file
691Write output to
692.I file
693instead of to standard output.
694.SS "decode"
695The
696.B decode
697command decodes an input file encoded according to one of the encodings
698described above in
699.BR ENCODINGS .
700The input is read from the
701.I file
702given on the command line, or from standard input if none is specified.
703Options provided are:
704.TP
705.BI "\-f, \-\-format " format
706Decode input in
707.IR format .
708Run
65802cb1 709.B catsign show enc
e1cba07d 710for a list of encoding formats.
711.TP
712.BI "\-b, \-\-boundary " label
713Set the PEM boundary string to
714.IR label ;
715i.e., assuming we're encoding in PEM format, start processing input
716between
717.BI "\-\-\-\-\-BEGIN " label "\-\-\-\-\-"
718and
719.BI "\-\-\-\-\-END " label "\-\-\-\-\-"
720lines. Without this option,
65802cb1 721.B catsign
e1cba07d 722will start reading at the first plausible boundary string, and continue
723processing until it reaches the matching end boundary.
724.TP
725.BI "\-o, \-\-output " file
726Write output to
727.I file
728instead of to standard output.
fa54fe1e 729.SH "BUGS"
730The trailing-whitespace deletion doesn't work for more than 32K of
731whitespace. I don't think this is a big problem, really.
732.PP
733The
734.B format
735command does something unhelpful if message and signature are sent to
736the same file.
737.SH "SEE ALSO"
738.BR key (1),
739.BR catcrypt (1),
740.BR dsig (1),
741.BR hashsum (1),
742.BR keyring (5).
743.SH AUTHOR
f387fcb1 744Mark Wooding, <mdw@distorted.org.uk>