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