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