math/Makefile.am, symm/Makefile.am: Use `--no-install' on oddball tests.
[catacomb] / progs / catcrypt.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 catcrypt 1 "30 September 2004" "Straylight/Edgeware" "Catacomb cryptographic library"
28 .SH NAME
29 catcrypt \- encrypt and decrypt messages
30 .SH SYNOPSIS
31 .B catcrypt
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 encrypt
47 .RB [ \-apC ]
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 decrypt
57 .RB [ \-apqvC ]
58 .RB [ \-f
59 .IR format ]
60 .RB [ \-o
61 .IR output ]
62 .RI [ file ]
63 .br
64 .B encode
65 .RB [ \-p ]
66 .RB [ \-f
67 .IR format ]
68 .RB [ \-b
69 .IR boundary ]
70 .RB [ \-o
71 .IR output ]
72 .RI [ file ]
73 .br
74 .B decode
75 .RB [ \-p ]
76 .RB [ \-f
77 .IR format ]
78 .RB [ \-b
79 .IR boundary ]
80 .RB [ \-o
81 .IR output ]
82 .RI [ file ]
83 .SH "DESCRIPTION"
84 The
85 .B catcrypt
86 command encrypts and decrypts messages. It also works as a simple PEM
87 encoder and decoder. It provides a number of subcommands, by which the
88 various operations may be carried out.
89 .SS "Global options"
90 Before the command name,
91 .I "global options"
92 may be given. The following global options are supported:
93 .TP
94 .BR "\-h, \-\-help " [ \fIcommand ...]
95 Writes a brief summary of
96 .BR catcrypt 's
97 various options to standard output, and returns a successful exit
98 status. With command names, gives help on those commands.
99 .TP
100 .B "\-v, \-\-version"
101 Writes the program's version number to standard output, and returns a
102 successful exit status.
103 .TP
104 .B "\-u, \-\-usage"
105 Writes a very terse command line summary to standard output, and returns
106 a successful exit status.
107 .TP
108 .BI "\-k, \-\-keyring " file
109 Names the keyring file which
110 .B key
111 is to process. The default keyring, used if this option doesn't specify
112 one, is the file named
113 .B keyring
114 in the current directory. See
115 .BR key (1)
116 and
117 .BR keyring (5)
118 for more details about keyring files.
119 .SH "KEY SETUP"
120 Algorithms to be used with a particular key are described by attributes
121 on the key, or its type. The
122 .B catcrypt
123 command deals with both signing and key-encapsulation keys. (Note that
124 .B catcrypt
125 uses signing keys in the same way as
126 .BR catsign (1).)
127 .SS "Key-encapsulation keys"
128 (Key encapsulation is a means of transmitting a short, known, random
129 secret to a recipient. It differs from encryption in technical ways
130 which are largely uninteresting at this point.)
131 .PP
132 A
133 .I kemalgspec
134 has the syntax
135 .IR kem \c
136 .RB [ / \c
137 .IR bulk \c
138 .RB [ \- \c
139 .IR cipher ] \c
140 .RB [ / \c
141 .IR hash ]]
142 or
143 .IR kem \c
144 .RB [ / \c
145 .IR cipher \c
146 .RB [ / \c
147 .IR hash ]].
148 If a
149 .B kem
150 attribute is present on the key, then it must have this form; otherwise,
151 the key's type must have the form
152 .BR cckem- \c
153 .IR kemalgspec .
154 Algorithm selections are taken from appropriately-named attributes, or,
155 failing that, from the
156 .IR kemalgspec .
157 .PP
158 The key-encapsulation mechanism is chosen according to the setting of
159 .I kem
160 as follows. Run
161 .B catcrypt show kem
162 for a list of supported KEMs.
163 .TP
164 .B rsa
165 This is Shoup's RSA-KEM (formerly Simple RSA); see
166 .I
167 A proposal for an ISO standard for public key encryption (version 2.0)
168 available at
169 .BR http://eprint.iacr.org/2000/060/ .
170 Use the
171 .B rsa
172 algorithm of the
173 .B key add
174 command (see
175 .BR key (1))
176 to generate the key.
177 .TP
178 .B dh
179 This is standard Diffie-Hellman key exchange, hashing the resulting
180 shared secret to form the key, as used in, e.g., DLIES (P1363a).
181 Use the
182 .B dh
183 algorithm of the
184 .B key add
185 command, preferably with the
186 .B \-LS
187 options, to generate the key.
188 .TP
189 .B ec
190 This is the elliptic-curve analogue of
191 .BR dh .
192 Use the
193 .B ec
194 algorithm of the
195 .BR key (1))
196 command to generate the key.
197 .TP
198 .B symm
199 This is a simple symmetric encapsulation scheme. It works by hashing a
200 binary key with a randomly-generated salt. Use the
201 .B binary
202 algorithm of the
203 .B key add
204 command (see
205 .BR key (1))
206 to generate the key.
207 .TP
208 .B x25519
209 This is Bernstein's Curve25519, a fast Diffie-Hellman using a specific
210 elliptic curve.
211 Use the
212 .B x25519
213 algorithm of the
214 .B key add
215 command
216 (see
217 .BR key (1))
218 to generate the key.
219 .TP
220 .B x448
221 This is Hamburg's Curve25519, a strong Diffie-Hellman using a specific
222 elliptic curve.
223 Use the
224 .B x448
225 algorithm of the
226 .B key add
227 command
228 (see
229 .BR key (1))
230 to generate the key.
231 .PP
232 The bulk crypto transform is chosen based on the
233 .B bulk
234 attribute on the key, or, failing that,
235 from the
236 .I bulk
237 stated in the
238 .IR kemalgspec .
239 Run
240 .B catcrypt show bulk
241 for a list of supported bulk crypto transforms.
242 .TP
243 .B gencomp
244 A generic composition of
245 a cipher secure against chosen-plaintext attack,
246 and a message authentication code.
247 Makes use of
248 .B cipher
249 and
250 .B mac
251 attributes.
252 This is the default transform.
253 .TP
254 .B naclbox
255 Use Salsa20 or ChaCha and Poly1305 to secure the bulk data.
256 This is nearly the same as the NaCl
257 .B crypto_secretbox
258 construction,
259 except that
260 .B catcrypt
261 uses Salsa20 or ChaCha rather than XSalsa20,
262 because it doesn't need the latter's extended nonce.
263 The
264 .B cipher
265 attribute may be set to one of
266 .BR salsa20 ,
267 .BR salsa20/12 ,
268 .BR salsa20/8 ,
269 .BR chacha20 ,
270 .BR chacha12 ,
271 or
272 .BR chacha8 ;
273 the default is
274 .BR salsa20 .
275 .PP
276 As well as the KEM itself, a number of supporting algorithms are used.
277 These are taken from appropriately named attributes on the key or,
278 failing that, derived from other attributes as described below.
279 .TP
280 .B cipher
281 This is the symmetric encryption algorithm
282 used by the bulk data transform.
283 If there is no
284 .B cipher
285 attribute then the
286 .I bulk
287 in the
288 .I kemalgspec
289 is used; if that it absent, then the default of
290 .B blowfish-cbc
291 is used. Run
292 .B catcrypt show cipher
293 for a list of supported symmetric encryption algorithms.
294 .TP
295 .B hash
296 This is the hash function used to distil entropy from the shared secret
297 constructed by the raw KEM. If there is no
298 .B hash
299 attribute then the
300 .I hash
301 in the
302 .I kemalgspec
303 is used; if that is absent then the default of
304 .B rmd160
305 is used. Run
306 .B catcrypt show hash
307 for a list of supported symmetric encryption algorithms.
308 .TP
309 .B mac
310 This is the message authentication algorithm
311 used by the
312 .B gencomp
313 bulk data transform
314 to ensure integrity of the encrypted message and
315 defend against chosen-ciphertext attacks.
316 If there is no
317 .B mac
318 attribute then
319 .IB hash -hmac
320 is chosen as a default. Run
321 .B catcrypt show mac
322 for a list of supported message authentication algorithms.
323 .TP
324 .B kdf
325 This is the key derivation function used to stretch the hashed shared
326 secret to a sufficient length to select symmetric encryption and
327 authentication keys, initialization vectors and other necessary
328 pseudorandom quantities. If there is no
329 .B kdf
330 attribute then
331 .IB hash -mgf
332 is chosen as a default. Run
333 .B catcrypt show kdf
334 for a list of supported key derivation functions.
335 .B Caution!
336 Not all supported functions have the required security features: don't
337 override the default choice unless you know what you're doing.
338 .SS "Signing keys"
339 A
340 .I sigalgspec
341 has the form
342 .IR sig \c
343 .RB [ / \c
344 .IR hash ].
345 If a
346 .B sig
347 attribute is present on the key, then it must have this form; otherwise,
348 the key's type must have the form
349 .BI ccsig- \c
350 .IR sigalgspec .
351 Algorithm selections are taken from appropriately-named attributes, or,
352 failing that, from the
353 .IR sigalgspec .
354 .PP
355 The signature algorithm is chosen according to the setting of
356 .I sig
357 as follows. Run
358 .B catcrypt show sig
359 for a list of supported signature algorithms.
360 .TP
361 .B rsapkcs1
362 This is almost the same as the RSASSA-PKCS1-v1_5 algorithm described in
363 RFC3447; the difference is that the hash is left bare rather than being
364 wrapped in a DER-encoded
365 .B DigestInfo
366 structure. This doesn't affect security since the key can only be used
367 with the one hash function anyway, and dropping the DER wrapping permits
368 rapid adoption of new hash functions. Regardless, use of this algorithm
369 is not recommended, since the padding method has been shown vulnerable
370 to attack. Use the
371 .B rsa
372 algorithm of the
373 .B key add
374 command (see
375 .BR key (1))
376 to generate the key.
377 .TP
378 .B rsapss
379 This is the RSASSA-PSS algorithm described in RFC3447. It is the
380 preferred RSA-based signature scheme. Use the
381 .B rsa
382 algorithm of the
383 .B key add
384 command (see
385 .BR key (1))
386 to generate the key.
387 .TP
388 .B dsa
389 This is the DSA algorithm described in FIPS180-1 and FIPS180-2. Use the
390 .B dsa
391 algorithm of the
392 .B key add
393 command (see
394 .BR key (1))
395 to generate the key.
396 .TP
397 .B ecdsa
398 This is the ECDSA algorithm described in ANSI X9.62 and FIPS180-2. Use
399 the
400 .B ec
401 algorithm of the
402 .B key add
403 command (see
404 .BR key (1))
405 to generate the key.
406 .TP
407 .B kcdsa
408 This is the revised KCDSA (Korean Certificate-based Digital Signature
409 Algorithm) described in
410 .I The Revised Version of KCDSA
411 .RB ( http://dasan.sejong.ac.kr/~chlim/pub/kcdsa1.ps ).
412 Use the
413 .B dh
414 algorithm of the
415 .B key add
416 command with the
417 .B \-LS
418 options (see
419 .BR key (1))
420 to generate the key.
421 .TP
422 .B eckcdsa
423 This is an unofficial elliptic-curve analogue of the KCDSA algorithm.
424 Use the
425 .B ec
426 algorithm of the
427 .B key add
428 command (see
429 .BR key (1))
430 to generate the key.
431 .TP
432 .B ed25519
433 This is Bernstein, Duif, Lange, Schwabe, and Yang's Ed25519 algorithm.
434 More specifically, this is HashEd25519
435 using the selected
436 .B hash
437 algorithm \(en by default
438 .BR sha512 .
439 Use the
440 .B ed25519
441 algorithm of the
442 .B key add
443 command
444 (see
445 .BR key (1))
446 to generate the key.
447 .TP
448 .B ed448
449 This is Bernstein, Duif, Lange, Schwabe, and Yang's EdDSA algorithm,
450 using Hamburg's Ed448-Goldilocks elliptic curve,
451 as specified in RFC8032.
452 More specifically, this is HashEd448
453 using the selected
454 .B hash
455 algorithm \(en by default
456 .BR sha3-512 .
457 Use the
458 .B ed448
459 algorithm of the
460 .B key add
461 command
462 (see
463 .BR key (1))
464 to generate the key.
465 .TP
466 .B mac
467 This uses a symmetric message-authentication algorithm rather than a
468 digital signature. The precise message-authentication scheme used is
469 determined by the
470 .B mac
471 attribute on the key, which defaults to
472 .IB hash -hmac
473 if unspecified. Use the
474 .B binary
475 algorithm of the
476 .B key add
477 command (see
478 .BR key (1))
479 to generate the key.
480 .PP
481 As well as the signature algorithm itself, a hash function is used.
482 This is taken from the
483 .B hash
484 attribute on the key, or, failing that, from the
485 .I hash
486 specified in the
487 .IR sigalgspec ,
488 or, if that is absent, determined by the signature algorithm as follows.
489 .hP \*o
490 For
491 .BR rsapkcs1 ,
492 .BR rsapss ,
493 .BR dsa ,
494 and
495 .BR ecdsa ,
496 the default hash function is
497 .BR sha .
498 .hP \*o
499 For
500 .BR kcdsa
501 and
502 .BR eckcdsa ,
503 the default hash function is
504 .BR has160 .
505 For
506 .BR ed25519 ,
507 the default hash function is
508 .BR sha512 .
509 For
510 .BR ed448 ,
511 the default hash function is
512 .BR shake256 .
513 .PP
514 Run
515 .B catcrypt show hash
516 for a list of supported hash functions.
517 .SH "ENCODINGS"
518 Two encodings for the ciphertext are supported.
519 .TP
520 .B binary
521 The raw format, which has the benefit of being smaller, but needs to be
522 attached to mail messages and generally handled with care.
523 .TP
524 .B pem
525 PEM-encapsulated Base-64 encoded text. This format can be included
526 directly in email and picked out again automatically; but there is a
527 4-to-3 data expansion as a result.
528 .SH "COMMAND REFERENCE"
529 .SS help
530 The
531 .B help
532 command behaves exactly as the
533 .B \-\-help
534 option. With no arguments, it shows an overview of
535 .BR catcrypt 's
536 options; with arguments, it describes the named subcommands.
537 .SS show
538 The
539 .B show
540 command prints various lists of tokens understood by
541 .BR catcrypt .
542 With no arguments, it prints all of the lists; with arguments, it prints
543 just the named lists, in order. The recognized lists can be enumerated
544 using the
545 .VS
546 catcrypt show list
547 .VE
548 command. The lists are as follows.
549 .TP
550 .B list
551 The lists which can be enumerated by the
552 .B show
553 command.
554 .TP
555 .B kem
556 The key-encapsulation algorithms which can be used in a
557 key-encapsulation key's
558 .B kem
559 attribute.
560 .TP
561 .B cipher
562 The symmetric encryption algorithms which can be used in a
563 key-encapsulation key's
564 .B cipher
565 attribute.
566 .TP
567 .B mac
568 The message authentication algorithms which can be used in a
569 key-encapsulation key's
570 .B mac
571 attribute.
572 .TP
573 .B sig
574 The signature algorithms which can be used in a signing key's
575 .B sig
576 attribute.
577 .TP
578 .B hash
579 The hash functions which can be used in a key's
580 .B hash
581 attribute.
582 .TP
583 .B enc
584 The encodings which can be applied to encrypted messages; see
585 .B ENCODINGS
586 above.
587 .SS encrypt
588 The
589 .B encrypt
590 command encrypts a file and writes out the appropriately-encoded
591 ciphertext. By default, it reads from standard input and writes to
592 standard output. If a filename argument is given, this file is read
593 instead (as binary data).
594 .PP
595 The following options are recognized.
596 .TP
597 .B "\-a, \-\-armour"
598 Produce ASCII-armoured output. This is equivalent to specifying
599 .BR "\-f pem" .
600 The variant spelling
601 .B "\-\-armor"
602 is also accepted.
603 .TP
604 .BI "\-f, \-\-format " format
605 Produce output encoded according to
606 .IR format .
607 .TP
608 .BI "\-k, \-\-key " tag
609 Use the key-encapsulation key named
610 .I tag
611 in the current keyring; the default key is
612 .BR ccrypt .
613 .TP
614 .BI "\-p, \-\-progress"
615 Write a progress meter to standard error while processing large files.
616 .TP
617 .BI "\-s, \-\-sign-key " tag
618 Use the signature key named
619 .I tag
620 in the current keyring; the default is not to sign the ciphertext.
621 .TP
622 .BI "\-o, \-\-ouptut " file
623 Write output to
624 .I file
625 rather than to standard output.
626 .TP
627 .B "\-C, \-\-nocheck"
628 Don't check the public key for validity. This makes encryption go much
629 faster, but at the risk of using a duff key.
630 .SS decrypt
631 The
632 .B decrypt
633 command decrypts a ciphertext and writes out the plaintext. By default,
634 it reads from standard input and writes to standard output. If a
635 filename argument is given, this file is read instead.
636 .PP
637 The following options are recognized.
638 .TP
639 .B "\-a, \-\-armour"
640 Read ASCII-armoured input. This is equivalent to specifying
641 .BR "\-f pem" .
642 The variant spelling
643 .B "\-\-armor"
644 is also accepted.
645 .TP
646 .B "\-b, \-\-buffer"
647 Buffer plaintext data until we're sure we've got it all. This is forced
648 on if output is to stdout, but is always available as an option.
649 .TP
650 .BI "\-f, \-\-format " format
651 Read input encoded according to
652 .IR format .
653 .TP
654 .BI "\-p, \-\-progress"
655 Write a progress meter to standard error while processing large files.
656 .TP
657 .B "\-v, \-\-verbose"
658 Produce more verbose messages. See below for the messages produced
659 during decryption. The default verbosity level is 1. (Currently this
660 is the most verbose setting. This might not be the case always.)
661 .TP
662 .B "\-q, \-\-quiet"
663 Produce fewer messages.
664 .TP
665 .BI "\-o, \-\-output " file
666 Write output to
667 .I file
668 instead of to standard output. The file is written in binary mode.
669 Fixing line-end conventions is your problem; there are lots of good
670 tools for dealing with it.
671 .TP
672 .B "\-C, \-\-nocheck"
673 Don't check the private key for validity. This makes decryption go much
674 faster, but at the risk of using a duff key, and possibly leaking
675 information about the private key.
676 .PP
677 Output is written to standard output in a machine-readable format.
678 Major problems cause the program to write a diagnostic to standard error
679 and exit nonzero as usual. The quantity of output varies depending on
680 the verbosity level and whether the plaintext is also being written to
681 standard output. Output lines begin with a keyword:
682 .TP
683 .BI "FAIL " reason
684 An error prevented decryption. The program will exit nonzero.
685 .TP
686 .BI "WARN " reason
687 .B catcrypt
688 encountered a situation which may or may not invalidate the decryption.
689 .TP
690 .BI "OK " message
691 Decryption was successful. This is only produced if main output is
692 being sent somewhere other than standard output.
693 .TP
694 .B "DATA"
695 The plaintext follows, starting just after the next newline character or
696 sequence. This is only produced if main output is also being sent to
697 standard output.
698 .TP
699 .BI "INFO " note
700 Any other information.
701 .PP
702 The information written at the various verbosity levels is as follows.
703 .hP 0.
704 No output. Watch the exit status.
705 .hP 1.
706 All messages.
707 .PP
708 .B Warning!
709 All output written has been checked for authenticity. However, output
710 can fail midway through for many reasons, and the resulting message may
711 therefore be truncated. Don't rely on the output being complete until
712 .B OK
713 is printed or
714 .B catcrypt decrypt
715 exits successfully.
716 .SS "encode"
717 The
718 .B encode
719 command encodes an input file according to one of the encodings
720 described above in
721 .BR ENCODINGS .
722 The input is read from the
723 .I file
724 given on the command line, or from standard input if none is specified.
725 Options provided are:
726 .TP
727 .BI "\-p, \-\-progress"
728 Write a progress meter to standard error while processing large files.
729 .TP
730 .BI "\-f, \-\-format " format
731 Produce output in
732 .IR format .
733 Run
734 .B catcrypt show enc
735 for a list of encoding formats.
736 .TP
737 .BI "\-b, \-\-boundary " label
738 Set the PEM boundary string to
739 .IR label ;
740 i.e., assuming we're encoding in PEM format, the output will have
741 .BI "\-\-\-\-\-BEGIN " label "\-\-\-\-\-"
742 at the top and
743 .BI "\-\-\-\-\-END " label "\-\-\-\-\-"
744 at the bottom. The default
745 .I label
746 is
747 .BR MESSAGE .
748 .TP
749 .BI "\-o, \-\-output " file
750 Write output to
751 .I file
752 instead of to standard output.
753 .SS "decode"
754 The
755 .B decode
756 command decodes an input file encoded according to one of the encodings
757 described above in
758 .BR ENCODINGS .
759 The input is read from the
760 .I file
761 given on the command line, or from standard input if none is specified.
762 Options provided are:
763 .TP
764 .BI "\-f, \-\-format " format
765 Decode input in
766 .IR format .
767 Run
768 .B catcrypt show enc
769 for a list of encoding formats.
770 .TP
771 .BI "\-b, \-\-boundary " label
772 Set the PEM boundary string to
773 .IR label ;
774 i.e., assuming we're encoding in PEM format, start processing input
775 between
776 .BI "\-\-\-\-\-BEGIN " label "\-\-\-\-\-"
777 and
778 .BI "\-\-\-\-\-END " label "\-\-\-\-\-"
779 lines. Without this option,
780 .B catcrypt
781 will start reading at the first plausible boundary string, and continue
782 processing until it reaches the matching end boundary.
783 .TP
784 .BI "\-p, \-\-progress"
785 Write a progress meter to standard error while processing large files.
786 .TP
787 .BI "\-o, \-\-output " file
788 Write output to
789 .I file
790 instead of to standard output.
791 .SH "SECURITY PROPERTIES"
792 Assuming the security of the underlying primitive algorithms, the
793 following security properties of the ciphertext hold.
794 .hP \*o
795 An adversary given the public key-encapsulation key and capable of
796 requesting encryption of arbitrary plaintexts of his own devising is
797 unable to decide whether he is given ciphertexts corresponding to his
798 chosen plaintexts or random plaintexts of the same length. This holds
799 even if the adversary is permitted to request decryption of any
800 ciphertext other than one produced as a result of an encryption request.
801 This property is called
802 .BR IND-CCA2 .
803 .hP \*o
804 An adversary given the public key-encapsulation and verification keys,
805 and capable of requesting encryption of arbitrary plaintext of his own
806 devising is unable to produce a new ciphertext which will be accepted as
807 genuine. This property is called
808 .BR INT-CTXT .
809 .hP \*o
810 An adversary given the public key-encapsulation and verification keys,
811 and capable of requesting encryption of arbitrary plaintext of his own
812 devising is unable to decide whether the ciphertexts he is given are
813 correctly signed. This property doesn't seem to have a name.
814 .PP
815 Not all is rosy. If you leak intermediate values during decryption then
816 an adversary can construct a new correctly-signed message. Don't do
817 that, then \(en leaking intermediate values often voids security
818 warranties. But it does avoid the usual problem with separate signing
819 and encryption that a careful leak by the recipient can produce evidence
820 that you signed some incriminating message.
821 .PP
822 Note that
823 .BR catcrypt 's
824 signatures do
825 .I not
826 provide `non-repudiation' in any useful way. This is deliberate: the
827 purpose of signing is to convince the recipient of the sender's
828 identity, rather than to allow the recipient to persuade anyone else.
829 Indeed, given an encrypted and signed message, the recipient can
830 straightforwardly construct a new message, apparently from the same
831 sender, and whose signature still verifies, but with arbitrarily chosen
832 content.
833 .SH "CRYPTOGRAPHIC THEORY"
834 Encryption of a message proceeds as follows.
835 .hP 0.
836 Emit a header packet containing the key-ids for the key-encapsulation
837 key, and signature key if any.
838 .hP 1.
839 Use the KEM to produce a public value and a shared secret the recipient
840 will be able to extract from the public value using his private key.
841 Emit a packet containing the public value.
842 .hP 2.
843 Hash the shared secret. Use the KDF to produce a pseudorandom keystream
844 of indefinite length.
845 .hP 3.
846 Use the first bits of the keystream to key a symmetric encryption
847 scheme; use the next bits to key a message authentication code.
848 .hP 4.
849 If we're signing the message then extract 1024 bytes from the keystream,
850 sign the header and public value, and the keystream bytes; emit a packet
851 containing the signature. The signature packet doesn't contain the
852 signed message, just the signature.
853 .hP 5.
854 Split the message into blocks. For each block, pick a random IV from
855 the keystream, encrypt the block and emit a packet containing the
856 IV, ciphertext, and a MAC tag over the ciphertext and a sequence number.
857 .hP 6.
858 The last chunk is the encryption of an empty plaintext block. No
859 previous plaintext block is empty. This lets us determine the
860 difference between a complete file and one that's been maliciously
861 truncated.
862 .PP
863 That's it. Nothing terribly controversial, really.
864 .SH "SEE ALSO"
865 .BR key (1),
866 .BR catsign (1),
867 .BR dsig (1),
868 .BR hashsum (1),
869 .BR keyring (5).
870 .SH AUTHOR
871 Mark Wooding, <mdw@distorted.org.uk>