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