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