pub/, progs/: Implement Bernstein's Ed25519 signature scheme.
[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 .PP
237 Run
238 .B dsig show hash
239 for a list of supported hash functions.
240 .SH "COMMAND REFERENCE"
241 .SS help
242 The
243 .B help
244 command behaves exactly as the
245 .B \-\-help
246 option. With no arguments, it shows an overview of
247 .BR dsig 's
248 options; with arguments, it describes the named subcommands.
249 .SS show
250 The
251 .B show
252 command prints various lists of tokens understood by
253 .BR dsig .
254 With no arguments, it prints all of the lists; with arguments, it prints
255 just the named lists, in order. The recognized lists can be enumerated
256 using the
257 .VS
258 dsig show list
259 .VE
260 command. The lists are as follows.
261 .TP
262 .B list
263 The lists which can be enumerated by the
264 .B show
265 command.
266 .TP
267 .B sig
268 The signature algorithms which can be used in a key's
269 .B sig
270 attribute.
271 .TP
272 .B hash
273 The hash functions which can be used in a key's
274 .B hash
275 attribute.
276 .SS sign
277 The
278 .B sign
279 command creates a signature for a collection of files. The default
280 behaviour is to read a list of whitespace-separated file names (see
281 below for the precise format) from standard input and write the
282 an output file, containing hashes of the files and a digital signature
283 made by the key
284 .B dsig
285 in the current keyring, to standard output, in plain text with binary
286 values Base64-encoded. It is intended to be used in conjunction with
287 .BR find (1).
288 This behaviour can be modified by specifying command-line options.
289 .TP
290 .B "\-0, \-\-null"
291 Read null-terminated filenames, rather than whitespace-separated names.
292 This is the recommended mode of operation if you have a
293 .BR find (1)
294 which understands the
295 .B \-print0
296 option.
297 .TP
298 .B "\-b, \-\-binary"
299 Produce output in raw binary rather than the textual output. This isn't
300 a useful thing to do unless you're trying to debug
301 .BR dsig .
302 .TP
303 .B "\-v, \-\-verbose"
304 Makes
305 .B dsig
306 more verbose. At present, this just means that it'll print the hashes
307 of files that it comes across in hex. (Use
308 .BR hashsum (1)
309 if this is the output you actually wanted.)
310 .TP
311 .B "\-q, \-\-quiet"
312 Makes
313 .B dsig
314 less verbose.
315 .TP
316 .BI "\-c, \-\-comment " string
317 Writes
318 .I string
319 as a comment in the output file. The comment's integrity is protected
320 by the signature.
321 .TP
322 .BI "\-p, \-\-progress"
323 Write a progress meter to standard error while processing large files.
324 .TP
325 .BI "\-f, \-\-file " name
326 Read filenames from
327 .I name
328 instead of from standard input.
329 .TP
330 .BI "\-h, \-\-hashes " name
331 Rather than hashing files, read precomputed hashes from the file
332 .IR name ,
333 which should be in the format produced by
334 .BR hashsum (1).
335 .TP
336 .BI "\-o, \-\-output " name
337 Write output to
338 .I name
339 instead of to standard output.
340 .TP
341 .BI "\-k, \-\-key " tag
342 Use the key named
343 .I tag
344 rather than the default
345 .BR dsig .
346 .TP
347 .BI "\-e, \-\-expire " date
348 Set the signature to expire at
349 .IR date .
350 The default is to expire 28 days from creation. Use
351 .B forever
352 to make the signature not expire.
353 .TP
354 .B "\-C, \-\-nocheck"
355 Don't check the private key for validity. This makes signing go much
356 faster, but at the risk of using a duff key, and potentially leaking
357 information about the private key.
358 .PP
359 The whitespace-separated format for filenames allows quoting and
360 escaping of strange characters. The backslash
361 .RB ` \e '
362 can be used to escape whitespace, quotes, or other special characters
363 (including itself), and to represent special characters using the
364 standard C escape sequences
365 .RB ` \ea ',
366 .RB ` \eb ',
367 .RB ` \ef ',
368 .RB ` \en ',
369 .RB ` \et ',
370 and
371 .RB ` \eb '.
372 A filename can be quoted in
373 .BR ` ... ',
374 .BR ' ... '
375 or
376 .BR """" ... """".
377 Whitespace within quotes is part of the filename. The quotes must be at
378 the beginning and end of the name.
379 .SS verify
380 The
381 .B verify
382 command will verify signatures made by the
383 .B sign
384 command. With no arguments, it expects to read a text-format signature
385 file from standard input; with an argument, it examines the file it
386 names to see whether it's text or binary.
387 .PP
388 Command-line options provided are:
389 .TP
390 .B "\-v, \-\-verbose"
391 Produce more informational output. The default verbosity level is 1.
392 .TP
393 .B "\-q, \-\-quiet"
394 Produce less information output.
395 .TP
396 .B "\-j, \-\-junk"
397 Report files whose hashes have not been checked.
398 .TP
399 .BI "\-p, \-\-progress"
400 Write a progress meter to standard error while processing large files.
401 .TP
402 .B "\-C, \-\-nocheck"
403 Don't check the public key for validity. This makes verification go
404 much faster, but at the risk of using a duff key, and potentially
405 accepting false signatures.
406 .PP
407 Output is written to standard output in a machine-readable format.
408 Formatting errors cause the program to write a diagnostic to standard
409 error and exit nonzero as usual. Lines begin with a keyword:
410 .TP
411 .BI "FAIL " reason
412 An error prevented verification.
413 .TP
414 .BI "BAD " reason
415 The signature is bad: some file had the wrong hash or the signature is
416 invalid.
417 .TP
418 .BI "WARN " reason
419 .B dsig
420 encountered a situation which may or may not invalidate the signature.
421 .TP
422 .BI "OK " message
423 The signature verified correctly.
424 .TP
425 .BI "JUNK " type " " name
426 The file
427 .I name
428 was found (as a result of the search requested by the
429 .RB ` \-j '
430 option), but it was not mentioned in the signature file and therefore
431 has not been checked.
432 .TP
433 .BI "INFO " note
434 Any other information.
435 .PP
436 The information written at the various verbosity levels is as follows.
437 .hP 0.
438 No output. Watch the exit status.
439 .B dsig
440 exits zero if the signature was good.
441 .hP 1.
442 All
443 .BR OK ,
444 .B FAIL
445 and
446 .B WARN
447 messages are printed.
448 .hP 2.
449 As for level 1; also
450 .B BAD
451 messages are printed describing reasons why the signature verification
452 failed, and an
453 .B INFO
454 message is printed showing the signature file's comment if any.
455 .hP 3.
456 As for level 2; also
457 .B INFO
458 messages are shown listing the signing program's identification string,
459 the signing key, the signature and expiry dates, and actual signature
460 verification.
461 .hP 4.
462 As for level 3; also
463 .B INFO
464 messages are printed for each file covered, showing its name and hash.
465 .SH "OUTPUT FORMAT"
466 There are two output formats: textual and binary. The hash used in the
467 digital signature is always computed on the
468 .I binary
469 version of the data, regardless of the external representation.
470 .SS "Textual format"
471 Within the file, whitespace and comments between strings are ignored. A
472 comment begins with a hash
473 .RB (` # ')
474 and extends until the next newline.
475 .PP
476 Strings are either quoted or whitespace-delimited. A string may be
477 quoted by
478 .BR ` ... ',
479 .BR ' ... '
480 or
481 .BR """" ... """".
482 The end-quote character can be backslash-escaped within the string. An
483 occurrence of the unescaped end-quote character terminates the string.
484 A whitespace-delimited string is terminated by any unescaped whitespace
485 character. The C-language escape sequences
486 .RB ` \ea ',
487 .RB ` \eb ',
488 .RB ` \ef ',
489 .RB ` \en ',
490 .RB ` \et ',
491 and
492 .RB ` \eb '
493 are recognized within either kind of string.
494 .PP
495 Blocks within the file consist of sequences of strings. The first
496 string is a
497 .I tag
498 \(en a simple string ending in a colon
499 .RB (` : ')
500 \(en which describes the format of the remaining strings.
501 .SS "Binary format"
502 The file consists of a sequence of blocks, each of which begins with a
503 tag byte. The format of the test of the block depends on the tag.
504 Strings are null-terminated; all integers are in network byte order.
505 .PP
506 A binary file always begins with an ident block, which has a tag of 0.
507 .SS "Block types"
508 The following block types are known. They must appear in the order
509 given, and except where noted must appear exactly once each.
510 .TP
511 .BR "ident: " (0)
512 Identification string of the generating program.
513 .BR "keyid: " (1)
514 The signing key's id, as eight hex digits (text) or a 32-bit integer
515 (binary).
516 .TP
517 .BR "comment: " (2)
518 The comment string set with the
519 .B \-c
520 option to the
521 .B sign
522 command. This block need not appear.
523 .TP
524 .BR "date: " (3)
525 The date the signature was made. In a text file, this has the form
526 .IB yyyy-mm-dd
527 .IB hh:mm:ss
528 .IR timezone ;
529 in a binary file, it's a 64-bit integer representing the POSIX time.
530 .TP
531 .BR "expires: " (4)
532 The expiry time of the signature, expressed as for
533 .BR date: .
534 A non-expiring signature is represented by the string
535 .B forever
536 in text files, or all-bits-set in binary.
537 .TP
538 .BR "file: " (5)
539 A file hash. In text, this is two strings which are the Base-64-encoded
540 hash and the file name; in binary, this is a 16-bit hash length, the raw
541 hash, and the null-terminated filename. There can be any number of
542 .B file:
543 blocks.
544 .TP
545 .BR "signature: " (6)
546 The signature. In text, this is the Base-64-encoded signature; in
547 binary, it is a 16-bit length followed by the binary signature.
548 .PP
549 The signature covers the
550 .I binary
551 representations of the file's
552 .BR date: ,
553 .B expires:
554 and
555 .B file:
556 blocks.
557 .SH "SEE ALSO"
558 .BR key (1),
559 .BR hashsum (1),
560 .BR catcrypt (1),
561 .BR catsign (1),
562 .BR keyring (5).
563 .SH AUTHOR
564 Mark Wooding, <mdw@distorted.org.uk>