72753f5f02623eb88f19fea56a4aa4b780e66b6e
[catacomb] / progs / dsig.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 dsig 1 "30 September 2004" "Straylight/Edgeware" "Catacomb cryptographic library"
28 .SH NAME
29 dsig \- compute and verify signatures on collections of files
30 .SH SYNOPSIS
31 .B dsig
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 [ \-0bpqvC ]
48 .RB [ \-c
49 .IR comment ]
50 .RB [ \-k
51 .IR tag ]
52 .RB [ \-e
53 .IR expire ]
54 .br
55 \h'8n'
56 .RB [ \-f
57 .IR file ]
58 .RB [ \-h
59 .IR file ]
60 .RB [ \-o
61 .IR output ]
62 .br
63 .B verify
64 .RB [ \-pqvjC ]
65 .RI [ file ]
66 .SH DESCRIPTION
67 The
68 .B dsig
69 command signs and verifies signatures on a collection of files. It
70 provides a number of subcommands, by which the various operations may be
71 carried out.
72 .SS "Global options"
73 Before the command name,
74 .I "global options"
75 may be given. The following global options are supported:
76 .TP
77 .BR "\-h, \-\-help " [ \fIcommand ...]
78 Writes a brief summary of
79 .BR dsig 's
80 various options to standard output, and returns a successful exit
81 status. With command names, gives help on those commands.
82 .TP
83 .B "\-v, \-\-version"
84 Writes the program's version number to standard output, and returns a
85 successful exit status.
86 .TP
87 .B "\-u, \-\-usage"
88 Writes a very terse command line summary to standard output, and returns
89 a successful exit status.
90 .TP
91 .BI "\-k, \-\-keyring " file
92 Names the keyring file which
93 .B key
94 is to process. The default keyring, used if this option doesn't specify
95 one, is the file named
96 .B keyring
97 in the current directory. See
98 .BR key (1)
99 and
100 .BR keyring (5)
101 for more details about keyring files.
102 .SH "KEY SETUP"
103 A
104 .I sigalgspec
105 has the form
106 .IR sig \c
107 .RB [ / \c
108 .IR hash ].
109 If a
110 .B sig
111 attribute is present on the key, then it must have this form; otherwise,
112 the key's type must have the form
113 .BI dsig- \c
114 .IR sigalgspec .
115 Algorithm selections are taken from appropriately-named attributes, or,
116 failing that, from the
117 .IR sigalgspec .
118 .PP
119 The signature algorithm is chosen according to the setting of
120 .I sig
121 as follows. Run
122 .B dsig show sig
123 for a list of supported signature algorithms.
124 .TP
125 .B rsapkcs1
126 This is almost the same as the RSASSA-PKCS1-v1_5 algorithm described in
127 RFC3447; the difference is that the hash is left bare rather than being
128 wrapped in a DER-encoded
129 .B DigestInfo
130 structure. This doesn't affect security since the key can only be used
131 with the one hash function anyway, and dropping the DER wrapping permits
132 rapid adoption of new hash functions. Regardless, use of this algorithm
133 is not recommended, since the padding method has been shown vulnerable
134 to attack. Use the
135 .B rsa
136 algorithm of the
137 .B key add
138 command (see
139 .BR key (1))
140 to generate the key.
141 .TP
142 .B rsapss
143 This is the RSASSA-PSS algorithm described in RFC3447. It is the
144 preferred RSA-based signature scheme. Use the
145 .B rsa
146 algorithm of the
147 .B key add
148 command (see
149 .BR key (1))
150 to generate the key.
151 .TP
152 .B dsa
153 This is the DSA algorithm described in FIPS180-1 and FIPS180-2. Use the
154 .B dsa
155 algorithm of the
156 .B key add
157 command (see
158 .BR key (1))
159 to generate the key.
160 .TP
161 .B ecdsa
162 This is the ECDSA algorithm described in ANSI X9.62 and FIPS180-2. Use
163 the
164 .B ec
165 algorithm of the
166 .B key add
167 command (see
168 .BR key (1))
169 to generate the key.
170 .TP
171 .B kcdsa
172 This is the revised KCDSA (Korean Certificate-based Digital Signature
173 Algorithm) described in
174 .I The Revised Version of KCDSA
175 .RB ( http://dasan.sejong.ac.kr/~chlim/pub/kcdsa1.ps ).
176 Use the
177 .B dh
178 algorithm of the
179 .B key add
180 command with the
181 .B \-LS
182 options (see
183 .BR key (1))
184 to generate the key.
185 .TP
186 .B eckcdsa
187 This is an unofficial elliptic-curve analogue of the KCDSA algorithm.
188 Use the
189 .B ec
190 algorithm of the
191 .B key add
192 command (see
193 .BR key (1))
194 to generate the key.
195 .TP
196 .B ed25519
197 This is Bernstein, Duif, Lange, Schwabe, and Yang's Ed25519 algorithm.
198 More specifically, this is HashEd25519
199 using the selected
200 .B hash
201 algorithm \(en by default
202 .BR sha512 .
203 Use the
204 .B ed25519
205 algorithm of the
206 .B key add
207 command
208 (see
209 .BR key (1))
210 to generate the key.
211 .PP
212 As well as the signature algorithm itself, a hash function is used.
213 This is taken from the
214 .B hash
215 attribute on the key, or, failing that, from the
216 .I hash
217 specified in the
218 .IR sigalgspec ,
219 or, if that is absent, determined by the signature algorithm as follows.
220 .hP \*o
221 For
222 .BR rsapkcs1 ,
223 .BR rsapss ,
224 .BR dsa ,
225 and
226 .BR ecdsa ,
227 the default hash function is
228 .BR sha .
229 .hP \*o
230 For
231 .BR kcdsa
232 and
233 .BR eckcdsa ,
234 the default hash function is
235 .BR has160 .
236 For
237 .BR ed25519 ,
238 the default hash function is
239 .BR sha512 .
240 .PP
241 Run
242 .B dsig show hash
243 for a list of supported hash functions.
244 .SH "COMMAND REFERENCE"
245 .SS help
246 The
247 .B help
248 command behaves exactly as the
249 .B \-\-help
250 option. With no arguments, it shows an overview of
251 .BR dsig 's
252 options; with arguments, it describes the named subcommands.
253 .SS show
254 The
255 .B show
256 command prints various lists of tokens understood by
257 .BR dsig .
258 With no arguments, it prints all of the lists; with arguments, it prints
259 just the named lists, in order. The recognized lists can be enumerated
260 using the
261 .VS
262 dsig show list
263 .VE
264 command. The lists are as follows.
265 .TP
266 .B list
267 The lists which can be enumerated by the
268 .B show
269 command.
270 .TP
271 .B sig
272 The signature algorithms which can be used in a key's
273 .B sig
274 attribute.
275 .TP
276 .B hash
277 The hash functions which can be used in a key's
278 .B hash
279 attribute.
280 .SS sign
281 The
282 .B sign
283 command creates a signature for a collection of files. The default
284 behaviour is to read a list of whitespace-separated file names (see
285 below for the precise format) from standard input and write the
286 an output file, containing hashes of the files and a digital signature
287 made by the key
288 .B dsig
289 in the current keyring, to standard output, in plain text with binary
290 values Base64-encoded. It is intended to be used in conjunction with
291 .BR find (1).
292 This behaviour can be modified by specifying command-line options.
293 .TP
294 .B "\-0, \-\-null"
295 Read null-terminated filenames, rather than whitespace-separated names.
296 This is the recommended mode of operation if you have a
297 .BR find (1)
298 which understands the
299 .B \-print0
300 option.
301 .TP
302 .B "\-b, \-\-binary"
303 Produce output in raw binary rather than the textual output. This isn't
304 a useful thing to do unless you're trying to debug
305 .BR dsig .
306 .TP
307 .B "\-v, \-\-verbose"
308 Makes
309 .B dsig
310 more verbose. At present, this just means that it'll print the hashes
311 of files that it comes across in hex. (Use
312 .BR hashsum (1)
313 if this is the output you actually wanted.)
314 .TP
315 .B "\-q, \-\-quiet"
316 Makes
317 .B dsig
318 less verbose.
319 .TP
320 .BI "\-c, \-\-comment " string
321 Writes
322 .I string
323 as a comment in the output file. The comment's integrity is protected
324 by the signature.
325 .TP
326 .BI "\-p, \-\-progress"
327 Write a progress meter to standard error while processing large files.
328 .TP
329 .BI "\-f, \-\-file " name
330 Read filenames from
331 .I name
332 instead of from standard input.
333 .TP
334 .BI "\-h, \-\-hashes " name
335 Rather than hashing files, read precomputed hashes from the file
336 .IR name ,
337 which should be in the format produced by
338 .BR hashsum (1).
339 .TP
340 .BI "\-o, \-\-output " name
341 Write output to
342 .I name
343 instead of to standard output.
344 .TP
345 .BI "\-k, \-\-key " tag
346 Use the key named
347 .I tag
348 rather than the default
349 .BR dsig .
350 .TP
351 .BI "\-e, \-\-expire " date
352 Set the signature to expire at
353 .IR date .
354 The default is to expire 28 days from creation. Use
355 .B forever
356 to make the signature not expire.
357 .TP
358 .B "\-C, \-\-nocheck"
359 Don't check the private key for validity. This makes signing go much
360 faster, but at the risk of using a duff key, and potentially leaking
361 information about the private key.
362 .PP
363 The whitespace-separated format for filenames allows quoting and
364 escaping of strange characters. The backslash
365 .RB ` \e '
366 can be used to escape whitespace, quotes, or other special characters
367 (including itself), and to represent special characters using the
368 standard C escape sequences
369 .RB ` \ea ',
370 .RB ` \eb ',
371 .RB ` \ef ',
372 .RB ` \en ',
373 .RB ` \et ',
374 and
375 .RB ` \eb '.
376 A filename can be quoted in
377 .BR ` ... ',
378 .BR ' ... '
379 or
380 .BR """" ... """".
381 Whitespace within quotes is part of the filename. The quotes must be at
382 the beginning and end of the name.
383 .SS verify
384 The
385 .B verify
386 command will verify signatures made by the
387 .B sign
388 command. With no arguments, it expects to read a text-format signature
389 file from standard input; with an argument, it examines the file it
390 names to see whether it's text or binary.
391 .PP
392 Command-line options provided are:
393 .TP
394 .B "\-v, \-\-verbose"
395 Produce more informational output. The default verbosity level is 1.
396 .TP
397 .B "\-q, \-\-quiet"
398 Produce less information output.
399 .TP
400 .B "\-j, \-\-junk"
401 Report files whose hashes have not been checked.
402 .TP
403 .BI "\-p, \-\-progress"
404 Write a progress meter to standard error while processing large files.
405 .TP
406 .B "\-C, \-\-nocheck"
407 Don't check the public key for validity. This makes verification go
408 much faster, but at the risk of using a duff key, and potentially
409 accepting false signatures.
410 .PP
411 Output is written to standard output in a machine-readable format.
412 Formatting errors cause the program to write a diagnostic to standard
413 error and exit nonzero as usual. Lines begin with a keyword:
414 .TP
415 .BI "FAIL " reason
416 An error prevented verification.
417 .TP
418 .BI "BAD " reason
419 The signature is bad: some file had the wrong hash or the signature is
420 invalid.
421 .TP
422 .BI "WARN " reason
423 .B dsig
424 encountered a situation which may or may not invalidate the signature.
425 .TP
426 .BI "OK " message
427 The signature verified correctly.
428 .TP
429 .BI "JUNK " type " " name
430 The file
431 .I name
432 was found (as a result of the search requested by the
433 .RB ` \-j '
434 option), but it was not mentioned in the signature file and therefore
435 has not been checked.
436 .TP
437 .BI "INFO " note
438 Any other information.
439 .PP
440 The information written at the various verbosity levels is as follows.
441 .hP 0.
442 No output. Watch the exit status.
443 .B dsig
444 exits zero if the signature was good.
445 .hP 1.
446 All
447 .BR OK ,
448 .B FAIL
449 and
450 .B WARN
451 messages are printed.
452 .hP 2.
453 As for level 1; also
454 .B BAD
455 messages are printed describing reasons why the signature verification
456 failed, and an
457 .B INFO
458 message is printed showing the signature file's comment if any.
459 .hP 3.
460 As for level 2; also
461 .B INFO
462 messages are shown listing the signing program's identification string,
463 the signing key, the signature and expiry dates, and actual signature
464 verification.
465 .hP 4.
466 As for level 3; also
467 .B INFO
468 messages are printed for each file covered, showing its name and hash.
469 .SH "OUTPUT FORMAT"
470 There are two output formats: textual and binary. The hash used in the
471 digital signature is always computed on the
472 .I binary
473 version of the data, regardless of the external representation.
474 .SS "Textual format"
475 Within the file, whitespace and comments between strings are ignored. A
476 comment begins with a hash
477 .RB (` # ')
478 and extends until the next newline.
479 .PP
480 Strings are either quoted or whitespace-delimited. A string may be
481 quoted by
482 .BR ` ... ',
483 .BR ' ... '
484 or
485 .BR """" ... """".
486 The end-quote character can be backslash-escaped within the string. An
487 occurrence of the unescaped end-quote character terminates the string.
488 A whitespace-delimited string is terminated by any unescaped whitespace
489 character. The C-language escape sequences
490 .RB ` \ea ',
491 .RB ` \eb ',
492 .RB ` \ef ',
493 .RB ` \en ',
494 .RB ` \et ',
495 and
496 .RB ` \eb '
497 are recognized within either kind of string.
498 .PP
499 Blocks within the file consist of sequences of strings. The first
500 string is a
501 .I tag
502 \(en a simple string ending in a colon
503 .RB (` : ')
504 \(en which describes the format of the remaining strings.
505 .SS "Binary format"
506 The file consists of a sequence of blocks, each of which begins with a
507 tag byte. The format of the test of the block depends on the tag.
508 Strings are null-terminated; all integers are in network byte order.
509 .PP
510 A binary file always begins with an ident block, which has a tag of 0.
511 .SS "Block types"
512 The following block types are known. They must appear in the order
513 given, and except where noted must appear exactly once each.
514 .TP
515 .BR "ident: " (0)
516 Identification string of the generating program.
517 .BR "keyid: " (1)
518 The signing key's id, as eight hex digits (text) or a 32-bit integer
519 (binary).
520 .TP
521 .BR "comment: " (2)
522 The comment string set with the
523 .B \-c
524 option to the
525 .B sign
526 command. This block need not appear.
527 .TP
528 .BR "date: " (3)
529 The date the signature was made. In a text file, this has the form
530 .IB yyyy-mm-dd
531 .IB hh:mm:ss
532 .IR timezone ;
533 in a binary file, it's a 64-bit integer representing the POSIX time.
534 .TP
535 .BR "expires: " (4)
536 The expiry time of the signature, expressed as for
537 .BR date: .
538 A non-expiring signature is represented by the string
539 .B forever
540 in text files, or all-bits-set in binary.
541 .TP
542 .BR "file: " (5)
543 A file hash. In text, this is two strings which are the Base-64-encoded
544 hash and the file name; in binary, this is a 16-bit hash length, the raw
545 hash, and the null-terminated filename. There can be any number of
546 .B file:
547 blocks.
548 .TP
549 .BR "signature: " (6)
550 The signature. In text, this is the Base-64-encoded signature; in
551 binary, it is a 16-bit length followed by the binary signature.
552 .PP
553 The signature covers the
554 .I binary
555 representations of the file's
556 .BR date: ,
557 .B expires:
558 and
559 .B file:
560 blocks.
561 .SH "SEE ALSO"
562 .BR key (1),
563 .BR hashsum (1),
564 .BR catcrypt (1),
565 .BR catsign (1),
566 .BR keyring (5).
567 .SH AUTHOR
568 Mark Wooding, <mdw@distorted.org.uk>