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