hashsum.1: Write some notes about compatibility with GNU Coreutils.
[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
946c3f72 47.RB [ \-adtC ]
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
946c3f72 57.RB [ \-aquvC ]
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
78.RB [ \-auABDET ]
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
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
45c0fd36 151uses signing keys in the same way as
fa54fe1e 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
45c0fd36 179wrapped in a DER-encoded
fa54fe1e 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
45c0fd36 204This is the DSA algorithm described in FIPS180-1 and FIPS180-2. Use the
fa54fe1e 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.
02dfbd5b
MW
246.TP
247.B mac
248This uses a symmetric message-authentication algorithm rather than a
249digital signature. The precise message-authentication scheme used is
250determined by the
251.B mac
252attribute on the key, which defaults to
253.IB hash -hmac
254if unspecified. Use the
255.B binary
256algorithm of the
257.B key add
258command (see
259.BR key (1))
260to generate the key.
fa54fe1e 261.PP
262As well as the signature algorithm itself, a hash function is used.
263This is taken from the
264.B hash
265attribute on the key, or, failing that, from the
266.I hash
267specified in the
268.IR sigalgspec ,
269or, if that is absent, determined by the signature algorithm as follows.
270.hP \*o
271For
272.BR rsapkcs1 ,
273.BR rsapss ,
274.BR dsa ,
275and
276.BR ecdsa ,
277the default hash function is
278.BR sha .
279.hP \*o
280For
45c0fd36 281.BR kcdsa
fa54fe1e 282and
283.BR eckcdsa ,
284the default hash function is
285.BR has160 .
286.PP
287Run
288.B catsign show hash
289for a list of supported hash functions.
290.SH "ENCODINGS"
291Two encodings for the ciphertext are supported.
292.TP
293.B binary
294The raw format, which has the benefit of being smaller, but needs to be
295attached to mail messages and generally handled with care.
296.TP
297.B pem
298PEM-encapsulated Base-64 encoded text. This format can be included
299directly in email and picked out again automatically; but there is a
3004-to-3 data expansion as a result.
301.SH "SIGNATURE FORMATS"
302There are two basic signature formats understood by
303.BR catsign .
304.hP \*o
305Embedded signatures include (embed) the message they sign; hence they're
306complete in and of themselves. The
307.B catsign
308program extracts the message during signature verification.
309.hP \*o
310Detached signatures are separate from the messages they sign, and both
311the original file and the signature are required for a successful
312verification.
313.PP
314Another important distinction is whether the message data is considered
315to be plain text or raw binary data.
316.hP \*o
317When dealing with plain text,
318.B catsign
319allows a limited quantity of leeway in the messages it processes. It
320ignores trailing whitespace on a line, including stray carriage-returns,
321which may appear if Windows boxes have had their way with the data. It
322also appends a final newline if there wasn't one before. In embedded
323signatures, the text is left unencoded, so that the message is readable.
324.hP \*o
325Binary files are preserved completely, and no variation whatever is
326permitted.
327.PP
328The
329.VS
330catsign format
331.VE
332command can convert between detached and embedded signatures; it cannot
333convert between binary and text mode signatures. (The data actually
334signed includes a flag saying whether the message is textual. The
335rationale here is that what looks like an ASCII space before a newline
336may be devastatingly significant in a binary data file, and if a message
337is signed as raw binary then no changes whatever should be allowed.)
338.SH "COMMAND REFERENCE"
339.SS help
340The
341.B help
342command behaves exactly as the
343.B \-\-help
344option. With no arguments, it shows an overview of
345.BR catsign 's
346options; with arguments, it describes the named subcommands.
347.SS show
348The
349.B show
350command prints various lists of tokens understood by
351.BR catsign .
352With no arguments, it prints all of the lists; with arguments, it prints
353just the named lists, in order. The recognized lists can be enumerated
354using the
355.VS
356catsign show list
357.VE
358command. The lists are as follows.
359.TP
360.B list
361The lists which can be enumerated by the
362.B show
363command.
364.TP
365.B sig
366The signature algorithms which can be used in a signing key's
367.B sig
368attribute.
369.TP
370.B hash
371The hash functions which can be used in a key's
372.B hash
373attribute.
374.TP
375.B enc
45c0fd36 376The encodings which can be applied to encrypted messages; see
fa54fe1e 377.B ENCODINGS
378above.
379.SS sign
380The
381.B sign
382command signs a message and writes out an appropriately-encoded
383signature. By default, it reads a message from standard input and
384writes the signature to standard output. If a filename argument is
385given, this file is read instead.
386.PP
387The following options are recognized.
388.TP
389.B "\-a, \-\-armour"
390Produce ASCII-armoured output. This is equivalent to specifying
391.BR "\-f pem" .
392The variant spelling
393.B "\-\-armor"
394is also accepted.
395.TP
396.B "\-b, \-\-binary"
397Read and sign the input as binary data. The default is to treat the
398input as text.
399.TP
400.B "\-d, \-\-detach"
401Produce a detached signature. The default is to produce a signature
402with embedded message.
403.TP
404.BI "\-f, \-\-format " format
405Produce output encoded according to
406.IR format .
407.TP
408.BI "\-k, \-\-key " tag
409Use the signing key named
410.I tag
411in the current keyring; the default key is
412.BR ccsig .
413.TP
414.BI "\-o, \-\-ouptut " file
415Write output to
416.I file
417rather than to standard output.
418.TP
419.B "\-t, \-\-text"
420Read and sign the input as text. This is the default.
946c3f72 421.TP
422.B "\-C, \-\-nocheck"
423Don't check the private key for validity. This makes signing go much
424faster, but at the risk of using a duff key, and potentially leaking
425information about the private key.
fa54fe1e 426.SS verify
427The
428.B verify
429command checks a signature's validity, producing as output information
430about the signature and the signed message.
431.PP
432The first non-option argument is the name of the file containing the
45c0fd36 433signature data; this may be omitted or
fa54fe1e 434.RB ` \- '
435to indicate that the signature be read from standard input. The second
436non-option argument, if any, is the name of the file to read the message
437from, if the signature is detached. An error is reported if a message
438file is specified but the signature contains an embedded message
439already; if the signature is detached but no filename is given, then the
440message is expected on stdin (immediately after the signature, if any).
441.TP
442.B "\-a, \-\-armour"
443Read ASCII-armoured input. This is equivalent to specifying
444.BR "\-f pem" .
445The variant spelling
446.B "\-\-armor"
447is also accepted.
448.TP
449.B "\-b, \-\-buffer"
450Buffer the message until the signature is verified. This is forced on
451if output is to stdout, but is always available as an option.
452.TP
453.BI "\-f, \-\-format " format
454Read input encoded according to
455.IR format .
456.TP
457.B "\-v, \-\-verbose"
458Produce more verbose messages. See below for the messages produced
459during decryption. The default verbosity level is 1. (Currently this
460is the most verbose setting. This might not be the case always.)
21aac40c 461.TP
fa54fe1e 462.B "\-q, \-\-quiet"
463Produce fewer messages.
464.TP
465.BI "\-k, \-\-key " tag
466Usually
467.B catsign
468uses the signature header to work out which key to use to verify a
469signature. Using this option causes verification to fail unless the
470signature header specifies the key named
471.IR tag .
472.TP
9cea6911 473.BI "\-t, \-\-freshtime " time
474Only accept signatures claiming to have been made more recently than
475.IR time .
476If
477.I time
478is
479.B always
480(the default) then any timestamp in the past is acceptable.
481.TP
fa54fe1e 482.B "\-u, \-\-utc"
483Show the datestamp in the signature in UTC rather than (your) local
484time. The synonym
485.B \-\-gmt
486is also accepted.
487.TP
488.BI "\-o, \-\-output " file
489Write the verified message to
490.IR file .
491The file is written in text or binary
492mode as appropriate. The default is to write the message to standard
493output unless verifying a detached signature, in which case nothing is
494written.
946c3f72 495.TP
496.B "\-C, \-\-nocheck"
497Don't check the public key for validity. This makes verification go
498much faster, but at the risk of using a duff key, and potentially
499accepting false signatures.
fa54fe1e 500.PP
501Output is written to standard output in a machine-readable format.
502Major problems cause the program to write a diagnostic to standard error
503and exit nonzero as usual. The quantity of output varies depending on
504the verbosity level and whether the message is also being written to
505standard output. Output lines begin with a keyword:
506.TP
507.BI "FAIL " reason
508An error prevented verification. The program will exit nonzero.
509.TP
510.BI "WARN " reason
511.B catsign
512encountered a situation which may or may not invalidate the
513verification.
514.TP
515.BI "OK " message
516Verification was successful. This is only produced if the message is
517being sent somewhere other than standard output.
518.TP
519.B "DATA"
520The message follows, starting just after the next newline character or
521sequence. This is only produced if the message is being written to
522standard output.
523.TP
524.BI "INFO " note
525Any other information.
526.PP
527The information written at the various verbosity levels is as follows.
528.hP 0.
529No output. Watch the exit status.
530.hP 1.
531All messages.
532.PP
533.B Warning!
534All output written has been checked for authenticity. However, output
535can fail madway through for many reasons, and the resulting message may
45c0fd36 536therefore be truncated. Don't rely on the output being complete until
4224d0b9 537.B OK
538is printed or
fa54fe1e 539.B catsign verify
540exits successfully.
541.SS info
542The
543.B info
544command analyses a signature without verifying it, and prints
545interesting information about it. This might be useful for diagnostic
546purposes. No keys are needed for this operation, though you get more
547useful information if you have them.
548.PP
549If a non-option argument is given, and it is not
550.RB ` \- ',
551then it is taken to name the file containing the signature to parse;
552otherwise a signature is read from standard input.
553.PP
554The following options are recognized.
555.TP
556.B "\-a, \-\-armour"
557Read ASCII-armoured input. This is equivalent to specifying
558.BR "\-f pem" .
559The variant spelling
560.B "\-\-armor"
561is also accepted.
562.TP
563.BI "\-f, \-\-format " format
564Read input encoded according to
565.IR format .
566.TP
567.B "\-u, \-\-utc"
568Show the datestamp in the signature in UTC rather than (your) local
569time. The synonym
570.B \-\-gmt
571is also accepted.
572.PP
573A description of the signature block is produced on standard output; it
574is mostly machine-readable. The first word on each line explains what
575kind of output it is.
576.TP
577.BI "BAD " message
578The signature data is invalid and cannot be parsed.
579.TP
580.BI "WARN " message
581Something is wrong with the data, but isn't fatal.
582.TP
583.BI "NOTE " message
584An environmental problem means that the information isn't as helpful as
585it might be. For example, the keyring file can't be opened, so we don't
586know whether the verification key is there.
587.TP
588.BI "INFO flags " flags
589Describes the flags set in the signature header. The
590.I flags
591are a list of flags, one per word, preceded by a
592.RB ` ! '
593if the flag is clear.
594.TP
595.BI "INFO expected-flags " flags
596If the PEM boundary string didn't match the actual signature data then
597this line is output, listing the expected flags and their settings.
598Problems with boundary mismatches can be resolved using the
599.B format
600command.
601.TP
602.BI "INFO date " yyyy "\-" mm "\-" dd " " hh ":" mm ":" ss " " tz
603Signature was (allegedly!) made at the given time and date. If the
604.B \-u
605option was given, this will be in UTC.
606.TP
607.BI "INFO key " tag
608Signature was (allegedly!) made using the key
609.IR tag ,
610which is present in the current keyring.
611.TP
612.BI "INFO unknown-key " keyid
613Signature was (allegedly!) made using the key with id
614.IR keyid
615which is not in the current keyring (or the keyring wasn't found).
616.SS format
617The
618.B format
619command translates signatures between the various supported formats.
620This is a (slightly) more complex operation than re-encoding, though it
621does not require any cryptographic operations.
622.PP
623The first non-option argument is the name of the file containing the
45c0fd36 624signature data; this may be omitted or
fa54fe1e 625.RB ` \- '
626to indicate that the signature be read from standard input. The second
627non-option argument, if any, is the name of the file to read the message
628from, if the signature is detached. An error is reported if a message
629file is specified but the signature contains an embedded message
630already; if the signature is detached but no filename is given, then the
631message is expected on stdin (immediately after the signature, if any).
632.PP
633The options follow a rough convention: options describing the input
634format are lower-case and options specifying the output format are
635upper-case. The following options are recognized.
0ac1f186 636.TP
637.BI "\-a, \-\-armour-in"
fa54fe1e 638Read ASCII-armoured input. This is equivalent to specifying
639.BR "\-f pem" .
640The variant spelling
641.B "\-\-armor"
642is also accepted.
0ac1f186 643.TP
644.BI "\-A, \-\-armour-out"
fa54fe1e 645Produce ASCII-armoured output. This is equivalent to specifying
646.BR "\-F pem" .
647The variant spelling
648.B "\-\-armor-out"
649is also accepted.
650.TP
651.B "\-D, \-\-detach"
652Produce a detached signature. This may be used to detach a signature
653from an embedded message.
654.TP
655.B "\-E, \-\-embed"
656Produce a signature with embedded message. This may be used to
657reattach a message to its detached signature.
658.TP
659.BI "\-f, \-\-format-in " format
660Read input encoded according to
661.IR format .
662.TP
663.BI "\-F, \-\-format-out " format
664Produce output encoded according to
665.IR format .
666.TP
667.BI "\-m, \-\-message " file
668Write the message to
669.IR file .
670If
671.I file
672is
673.RB ` \- '
674then write the message to standard output. Don't send the message and
675signature to the same place because it doesn't work.
676.TP
677.BI "\-o, \-\-output " file
678Write the signature to
679.IR file .
680If no
681.B \-m
682or
683.B \-o
684option is given, a signature is written to standard output.
e1cba07d 685.SS "encode"
686The
687.B encode
688command encodes an input file according to one of the encodings
689described above in
690.BR ENCODINGS .
45c0fd36 691The input is read from the
e1cba07d 692.I file
693given on the command line, or from standard input if none is specified.
694Options provided are:
695.TP
696.BI "\-f, \-\-format " format
697Produce output in
698.IR format .
699Run
65802cb1 700.B catsign show enc
e1cba07d 701for a list of encoding formats.
702.TP
703.BI "\-b, \-\-boundary " label
704Set the PEM boundary string to
705.IR label ;
706i.e., assuming we're encoding in PEM format, the output will have
707.BI "\-\-\-\-\-BEGIN " label "\-\-\-\-\-"
708at the top and
709.BI "\-\-\-\-\-END " label "\-\-\-\-\-"
710at the bottom. The default
711.I label
712is
713.BR MESSAGE .
714.TP
715.BI "\-o, \-\-output " file
716Write output to
717.I file
718instead of to standard output.
719.SS "decode"
720The
721.B decode
722command decodes an input file encoded according to one of the encodings
723described above in
724.BR ENCODINGS .
45c0fd36 725The input is read from the
e1cba07d 726.I file
727given on the command line, or from standard input if none is specified.
728Options provided are:
729.TP
730.BI "\-f, \-\-format " format
731Decode input in
732.IR format .
733Run
65802cb1 734.B catsign show enc
e1cba07d 735for a list of encoding formats.
736.TP
737.BI "\-b, \-\-boundary " label
738Set the PEM boundary string to
739.IR label ;
740i.e., assuming we're encoding in PEM format, start processing input
741between
742.BI "\-\-\-\-\-BEGIN " label "\-\-\-\-\-"
45c0fd36 743and
e1cba07d 744.BI "\-\-\-\-\-END " label "\-\-\-\-\-"
745lines. Without this option,
65802cb1 746.B catsign
e1cba07d 747will start reading at the first plausible boundary string, and continue
748processing until it reaches the matching end boundary.
749.TP
750.BI "\-o, \-\-output " file
751Write output to
752.I file
753instead of to standard output.
fa54fe1e 754.SH "BUGS"
755The trailing-whitespace deletion doesn't work for more than 32K of
756whitespace. I don't think this is a big problem, really.
757.PP
758The
759.B format
760command does something unhelpful if message and signature are sent to
761the same file.
762.SH "SEE ALSO"
763.BR key (1),
764.BR catcrypt (1),
765.BR dsig (1),
766.BR hashsum (1),
767.BR keyring (5).
768.SH AUTHOR
f387fcb1 769Mark Wooding, <mdw@distorted.org.uk>