]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - secure/usr.bin/openssl/man/cms.1
Merge OpenSSL 1.0.1u.
[FreeBSD/stable/10.git] / secure / usr.bin / openssl / man / cms.1
1 .\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sp \" Vertical space (when we can't use .PP)
6 .if t .sp .5v
7 .if n .sp
8 ..
9 .de Vb \" Begin verbatim text
10 .ft CW
11 .nf
12 .ne \\$1
13 ..
14 .de Ve \" End verbatim text
15 .ft R
16 .fi
17 ..
18 .\" Set up some character translations and predefined strings.  \*(-- will
19 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
20 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
21 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
22 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
23 .\" nothing in troff, for use with C<>.
24 .tr \(*W-
25 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
26 .ie n \{\
27 .    ds -- \(*W-
28 .    ds PI pi
29 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
30 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
31 .    ds L" ""
32 .    ds R" ""
33 .    ds C` ""
34 .    ds C' ""
35 'br\}
36 .el\{\
37 .    ds -- \|\(em\|
38 .    ds PI \(*p
39 .    ds L" ``
40 .    ds R" ''
41 .    ds C`
42 .    ds C'
43 'br\}
44 .\"
45 .\" Escape single quotes in literal strings from groff's Unicode transform.
46 .ie \n(.g .ds Aq \(aq
47 .el       .ds Aq '
48 .\"
49 .\" If the F register is turned on, we'll generate index entries on stderr for
50 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
51 .\" entries marked with X<> in POD.  Of course, you'll have to process the
52 .\" output yourself in some meaningful fashion.
53 .\"
54 .\" Avoid warning from groff about undefined register 'F'.
55 .de IX
56 ..
57 .nr rF 0
58 .if \n(.g .if rF .nr rF 1
59 .if (\n(rF:(\n(.g==0)) \{
60 .    if \nF \{
61 .        de IX
62 .        tm Index:\\$1\t\\n%\t"\\$2"
63 ..
64 .        if !\nF==2 \{
65 .            nr % 0
66 .            nr F 2
67 .        \}
68 .    \}
69 .\}
70 .rr rF
71 .\"
72 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
73 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
74 .    \" fudge factors for nroff and troff
75 .if n \{\
76 .    ds #H 0
77 .    ds #V .8m
78 .    ds #F .3m
79 .    ds #[ \f1
80 .    ds #] \fP
81 .\}
82 .if t \{\
83 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
84 .    ds #V .6m
85 .    ds #F 0
86 .    ds #[ \&
87 .    ds #] \&
88 .\}
89 .    \" simple accents for nroff and troff
90 .if n \{\
91 .    ds ' \&
92 .    ds ` \&
93 .    ds ^ \&
94 .    ds , \&
95 .    ds ~ ~
96 .    ds /
97 .\}
98 .if t \{\
99 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
100 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
101 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
102 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
103 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
104 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
105 .\}
106 .    \" troff and (daisy-wheel) nroff accents
107 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
108 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
109 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
110 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
111 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
112 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
113 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
114 .ds ae a\h'-(\w'a'u*4/10)'e
115 .ds Ae A\h'-(\w'A'u*4/10)'E
116 .    \" corrections for vroff
117 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
118 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
119 .    \" for low resolution devices (crt and lpr)
120 .if \n(.H>23 .if \n(.V>19 \
121 \{\
122 .    ds : e
123 .    ds 8 ss
124 .    ds o a
125 .    ds d- d\h'-1'\(ga
126 .    ds D- D\h'-1'\(hy
127 .    ds th \o'bp'
128 .    ds Th \o'LP'
129 .    ds ae ae
130 .    ds Ae AE
131 .\}
132 .rm #[ #] #H #V #F C
133 .\" ========================================================================
134 .\"
135 .IX Title "CMS 1"
136 .TH CMS 1 "2016-09-22" "1.0.1u" "OpenSSL"
137 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
138 .\" way too many mistakes in technical documents.
139 .if n .ad l
140 .nh
141 .SH "NAME"
142 cms \- CMS utility
143 .SH "SYNOPSIS"
144 .IX Header "SYNOPSIS"
145 \&\fBopenssl\fR \fBcms\fR
146 [\fB\-encrypt\fR]
147 [\fB\-decrypt\fR]
148 [\fB\-sign\fR]
149 [\fB\-verify\fR]
150 [\fB\-cmsout\fR]
151 [\fB\-resign\fR]
152 [\fB\-data_create\fR]
153 [\fB\-data_out\fR]
154 [\fB\-digest_create\fR]
155 [\fB\-digest_verify\fR]
156 [\fB\-compress\fR]
157 [\fB\-uncompress\fR]
158 [\fB\-EncryptedData_encrypt\fR]
159 [\fB\-sign_receipt\fR]
160 [\fB\-verify_receipt receipt\fR]
161 [\fB\-in filename\fR]
162 [\fB\-inform SMIME|PEM|DER\fR]
163 [\fB\-rctform SMIME|PEM|DER\fR]
164 [\fB\-out filename\fR]
165 [\fB\-outform SMIME|PEM|DER\fR]
166 [\fB\-stream \-indef \-noindef\fR]
167 [\fB\-noindef\fR]
168 [\fB\-content filename\fR]
169 [\fB\-text\fR]
170 [\fB\-noout\fR]
171 [\fB\-print\fR]
172 [\fB\-CAfile file\fR]
173 [\fB\-CApath dir\fR]
174 [\fB\-no_alt_chains\fR]
175 [\fB\-md digest\fR]
176 [\fB\-[cipher]\fR]
177 [\fB\-nointern\fR]
178 [\fB\-no_signer_cert_verify\fR]
179 [\fB\-nocerts\fR]
180 [\fB\-noattr\fR]
181 [\fB\-nosmimecap\fR]
182 [\fB\-binary\fR]
183 [\fB\-nodetach\fR]
184 [\fB\-certfile file\fR]
185 [\fB\-certsout file\fR]
186 [\fB\-signer file\fR]
187 [\fB\-recip file\fR]
188 [\fB\-keyid\fR]
189 [\fB\-receipt_request_all \-receipt_request_first\fR]
190 [\fB\-receipt_request_from emailaddress\fR]
191 [\fB\-receipt_request_to emailaddress\fR]
192 [\fB\-receipt_request_print\fR]
193 [\fB\-secretkey key\fR]
194 [\fB\-secretkeyid id\fR]
195 [\fB\-econtent_type type\fR]
196 [\fB\-inkey file\fR]
197 [\fB\-passin arg\fR]
198 [\fB\-rand file(s)\fR]
199 [\fBcert.pem...\fR]
200 [\fB\-to addr\fR]
201 [\fB\-from addr\fR]
202 [\fB\-subject subj\fR]
203 [cert.pem]...
204 .SH "DESCRIPTION"
205 .IX Header "DESCRIPTION"
206 The \fBcms\fR command handles S/MIME v3.1 mail. It can encrypt, decrypt, sign and
207 verify, compress and uncompress S/MIME messages.
208 .SH "COMMAND OPTIONS"
209 .IX Header "COMMAND OPTIONS"
210 There are fourteen operation options that set the type of operation to be
211 performed. The meaning of the other options varies according to the operation
212 type.
213 .IP "\fB\-encrypt\fR" 4
214 .IX Item "-encrypt"
215 encrypt mail for the given recipient certificates. Input file is the message
216 to be encrypted. The output file is the encrypted mail in \s-1MIME\s0 format. The
217 actual \s-1CMS\s0 type is <B>EnvelopedData<B>.
218 .Sp
219 Note that no revocation check is done for the recipient cert, so if that
220 key has been compromised, others may be able to decrypt the text.
221 .IP "\fB\-decrypt\fR" 4
222 .IX Item "-decrypt"
223 decrypt mail using the supplied certificate and private key. Expects an
224 encrypted mail message in \s-1MIME\s0 format for the input file. The decrypted mail
225 is written to the output file.
226 .IP "\fB\-debug_decrypt\fR" 4
227 .IX Item "-debug_decrypt"
228 this option sets the \fB\s-1CMS_DEBUG_DECRYPT\s0\fR flag. This option should be used
229 with caution: see the notes section below.
230 .IP "\fB\-sign\fR" 4
231 .IX Item "-sign"
232 sign mail using the supplied certificate and private key. Input file is
233 the message to be signed. The signed message in \s-1MIME\s0 format is written
234 to the output file.
235 .IP "\fB\-verify\fR" 4
236 .IX Item "-verify"
237 verify signed mail. Expects a signed mail message on input and outputs
238 the signed data. Both clear text and opaque signing is supported.
239 .IP "\fB\-cmsout\fR" 4
240 .IX Item "-cmsout"
241 takes an input message and writes out a \s-1PEM\s0 encoded \s-1CMS\s0 structure.
242 .IP "\fB\-resign\fR" 4
243 .IX Item "-resign"
244 resign a message: take an existing message and one or more new signers.
245 .IP "\fB\-data_create\fR" 4
246 .IX Item "-data_create"
247 Create a \s-1CMS \s0\fBData\fR type.
248 .IP "\fB\-data_out\fR" 4
249 .IX Item "-data_out"
250 \&\fBData\fR type and output the content.
251 .IP "\fB\-digest_create\fR" 4
252 .IX Item "-digest_create"
253 Create a \s-1CMS \s0\fBDigestedData\fR type.
254 .IP "\fB\-digest_verify\fR" 4
255 .IX Item "-digest_verify"
256 Verify a \s-1CMS \s0\fBDigestedData\fR type and output the content.
257 .IP "\fB\-compress\fR" 4
258 .IX Item "-compress"
259 Create a \s-1CMS \s0\fBCompressedData\fR type. OpenSSL must be compiled with \fBzlib\fR
260 support for this option to work, otherwise it will output an error.
261 .IP "\fB\-uncompress\fR" 4
262 .IX Item "-uncompress"
263 Uncompress a \s-1CMS \s0\fBCompressedData\fR type and output the content. OpenSSL must be
264 compiled with \fBzlib\fR support for this option to work, otherwise it will
265 output an error.
266 .IP "\fB\-EncryptedData_encrypt\fR" 4
267 .IX Item "-EncryptedData_encrypt"
268 Encrypt content using supplied symmetric key and algorithm using a \s-1CMS
269 \&\s0\fBEncrytedData\fR type and output the content.
270 .IP "\fB\-sign_receipt\fR" 4
271 .IX Item "-sign_receipt"
272 Generate and output a signed receipt for the supplied message. The input 
273 message \fBmust\fR contain a signed receipt request. Functionality is otherwise
274 similar to the \fB\-sign\fR operation.
275 .IP "\fB\-verify_receipt receipt\fR" 4
276 .IX Item "-verify_receipt receipt"
277 Verify a signed receipt in filename \fBreceipt\fR. The input message \fBmust\fR 
278 contain the original receipt request. Functionality is otherwise similar
279 to the \fB\-verify\fR operation.
280 .IP "\fB\-in filename\fR" 4
281 .IX Item "-in filename"
282 the input message to be encrypted or signed or the message to be decrypted
283 or verified.
284 .IP "\fB\-inform SMIME|PEM|DER\fR" 4
285 .IX Item "-inform SMIME|PEM|DER"
286 this specifies the input format for the \s-1CMS\s0 structure. The default
287 is \fB\s-1SMIME\s0\fR which reads an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
288 format change this to expect \s-1PEM\s0 and \s-1DER\s0 format \s-1CMS\s0 structures
289 instead. This currently only affects the input format of the \s-1CMS\s0
290 structure, if no \s-1CMS\s0 structure is being input (for example with
291 \&\fB\-encrypt\fR or \fB\-sign\fR) this option has no effect.
292 .IP "\fB\-rctform SMIME|PEM|DER\fR" 4
293 .IX Item "-rctform SMIME|PEM|DER"
294 specify the format for a signed receipt for use with the \fB\-receipt_verify\fR
295 operation.
296 .IP "\fB\-out filename\fR" 4
297 .IX Item "-out filename"
298 the message text that has been decrypted or verified or the output \s-1MIME\s0
299 format message that has been signed or verified.
300 .IP "\fB\-outform SMIME|PEM|DER\fR" 4
301 .IX Item "-outform SMIME|PEM|DER"
302 this specifies the output format for the \s-1CMS\s0 structure. The default
303 is \fB\s-1SMIME\s0\fR which writes an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
304 format change this to write \s-1PEM\s0 and \s-1DER\s0 format \s-1CMS\s0 structures
305 instead. This currently only affects the output format of the \s-1CMS\s0
306 structure, if no \s-1CMS\s0 structure is being output (for example with
307 \&\fB\-verify\fR or \fB\-decrypt\fR) this option has no effect.
308 .IP "\fB\-stream \-indef \-noindef\fR" 4
309 .IX Item "-stream -indef -noindef"
310 the \fB\-stream\fR and \fB\-indef\fR options are equivalent and enable streaming I/O
311 for encoding operations. This permits single pass processing of data without
312 the need to hold the entire contents in memory, potentially supporting very
313 large files. Streaming is automatically set for S/MIME signing with detached
314 data if the output format is \fB\s-1SMIME\s0\fR it is currently off by default for all
315 other operations.
316 .IP "\fB\-noindef\fR" 4
317 .IX Item "-noindef"
318 disable streaming I/O where it would produce and indefinite length constructed
319 encoding. This option currently has no effect. In future streaming will be
320 enabled by default on all relevant operations and this option will disable it.
321 .IP "\fB\-content filename\fR" 4
322 .IX Item "-content filename"
323 This specifies a file containing the detached content, this is only
324 useful with the \fB\-verify\fR command. This is only usable if the \s-1CMS\s0
325 structure is using the detached signature form where the content is
326 not included. This option will override any content if the input format
327 is S/MIME and it uses the multipart/signed \s-1MIME\s0 content type.
328 .IP "\fB\-text\fR" 4
329 .IX Item "-text"
330 this option adds plain text (text/plain) \s-1MIME\s0 headers to the supplied
331 message if encrypting or signing. If decrypting or verifying it strips
332 off text headers: if the decrypted or verified message is not of \s-1MIME \s0
333 type text/plain then an error occurs.
334 .IP "\fB\-noout\fR" 4
335 .IX Item "-noout"
336 for the \fB\-cmsout\fR operation do not output the parsed \s-1CMS\s0 structure. This
337 is useful when combined with the \fB\-print\fR option or if the syntax of the \s-1CMS\s0
338 structure is being checked.
339 .IP "\fB\-print\fR" 4
340 .IX Item "-print"
341 for the \fB\-cmsout\fR operation print out all fields of the \s-1CMS\s0 structure. This
342 is mainly useful for testing purposes.
343 .IP "\fB\-CAfile file\fR" 4
344 .IX Item "-CAfile file"
345 a file containing trusted \s-1CA\s0 certificates, only used with \fB\-verify\fR.
346 .IP "\fB\-CApath dir\fR" 4
347 .IX Item "-CApath dir"
348 a directory containing trusted \s-1CA\s0 certificates, only used with
349 \&\fB\-verify\fR. This directory must be a standard certificate directory: that
350 is a hash of each subject name (using \fBx509 \-hash\fR) should be linked
351 to each certificate.
352 .IP "\fB\-md digest\fR" 4
353 .IX Item "-md digest"
354 digest algorithm to use when signing or resigning. If not present then the
355 default digest algorithm for the signing key will be used (usually \s-1SHA1\s0).
356 .IP "\fB\-[cipher]\fR" 4
357 .IX Item "-[cipher]"
358 the encryption algorithm to use. For example triple \s-1DES \s0(168 bits) \- \fB\-des3\fR
359 or 256 bit \s-1AES \- \s0\fB\-aes256\fR. Any standard algorithm name (as used by the
360 \&\fIEVP_get_cipherbyname()\fR function) can also be used preceded by a dash, for 
361 example \fB\-aes_128_cbc\fR. See \fBenc\fR for a list of ciphers
362 supported by your version of OpenSSL.
363 .Sp
364 If not specified triple \s-1DES\s0 is used. Only used with \fB\-encrypt\fR and 
365 \&\fB\-EncryptedData_create\fR commands.
366 .IP "\fB\-nointern\fR" 4
367 .IX Item "-nointern"
368 when verifying a message normally certificates (if any) included in
369 the message are searched for the signing certificate. With this option
370 only the certificates specified in the \fB\-certfile\fR option are used.
371 The supplied certificates can still be used as untrusted CAs however.
372 .IP "\fB\-no_signer_cert_verify\fR" 4
373 .IX Item "-no_signer_cert_verify"
374 do not verify the signers certificate of a signed message.
375 .IP "\fB\-nocerts\fR" 4
376 .IX Item "-nocerts"
377 when signing a message the signer's certificate is normally included
378 with this option it is excluded. This will reduce the size of the
379 signed message but the verifier must have a copy of the signers certificate
380 available locally (passed using the \fB\-certfile\fR option for example).
381 .IP "\fB\-noattr\fR" 4
382 .IX Item "-noattr"
383 normally when a message is signed a set of attributes are included which
384 include the signing time and supported symmetric algorithms. With this
385 option they are not included.
386 .IP "\fB\-nosmimecap\fR" 4
387 .IX Item "-nosmimecap"
388 exclude the list of supported algorithms from signed attributes, other options
389 such as signing time and content type are still included.
390 .IP "\fB\-binary\fR" 4
391 .IX Item "-binary"
392 normally the input message is converted to \*(L"canonical\*(R" format which is
393 effectively using \s-1CR\s0 and \s-1LF\s0 as end of line: as required by the S/MIME
394 specification. When this option is present no translation occurs. This
395 is useful when handling binary data which may not be in \s-1MIME\s0 format.
396 .IP "\fB\-nodetach\fR" 4
397 .IX Item "-nodetach"
398 when signing a message use opaque signing: this form is more resistant
399 to translation by mail relays but it cannot be read by mail agents that
400 do not support S/MIME.  Without this option cleartext signing with
401 the \s-1MIME\s0 type multipart/signed is used.
402 .IP "\fB\-certfile file\fR" 4
403 .IX Item "-certfile file"
404 allows additional certificates to be specified. When signing these will
405 be included with the message. When verifying these will be searched for
406 the signers certificates. The certificates should be in \s-1PEM\s0 format.
407 .IP "\fB\-certsout file\fR" 4
408 .IX Item "-certsout file"
409 any certificates contained in the message are written to \fBfile\fR.
410 .IP "\fB\-signer file\fR" 4
411 .IX Item "-signer file"
412 a signing certificate when signing or resigning a message, this option can be
413 used multiple times if more than one signer is required. If a message is being
414 verified then the signers certificates will be written to this file if the
415 verification was successful.
416 .IP "\fB\-recip file\fR" 4
417 .IX Item "-recip file"
418 the recipients certificate when decrypting a message. This certificate
419 must match one of the recipients of the message or an error occurs.
420 .IP "\fB\-keyid\fR" 4
421 .IX Item "-keyid"
422 use subject key identifier to identify certificates instead of issuer name and
423 serial number. The supplied certificate \fBmust\fR include a subject key
424 identifier extension. Supported by \fB\-sign\fR and \fB\-encrypt\fR options.
425 .IP "\fB\-receipt_request_all \-receipt_request_first\fR" 4
426 .IX Item "-receipt_request_all -receipt_request_first"
427 for \fB\-sign\fR option include a signed receipt request. Indicate requests should
428 be provided by all receipient or first tier recipients (those mailed directly
429 and not from a mailing list). Ignored it \fB\-receipt_request_from\fR is included.
430 .IP "\fB\-receipt_request_from emailaddress\fR" 4
431 .IX Item "-receipt_request_from emailaddress"
432 for \fB\-sign\fR option include a signed receipt request. Add an explicit email
433 address where receipts should be supplied.
434 .IP "\fB\-receipt_request_to emailaddress\fR" 4
435 .IX Item "-receipt_request_to emailaddress"
436 Add an explicit email address where signed receipts should be sent to. This 
437 option \fBmust\fR but supplied if a signed receipt it requested.
438 .IP "\fB\-receipt_request_print\fR" 4
439 .IX Item "-receipt_request_print"
440 For the \fB\-verify\fR operation print out the contents of any signed receipt
441 requests.
442 .IP "\fB\-secretkey key\fR" 4
443 .IX Item "-secretkey key"
444 specify symmetric key to use. The key must be supplied in hex format and be
445 consistent with the algorithm used. Supported by the \fB\-EncryptedData_encrypt\fR
446 \&\fB\-EncrryptedData_decrypt\fR, \fB\-encrypt\fR and \fB\-decrypt\fR options. When used
447 with \fB\-encrypt\fR or \fB\-decrypt\fR the supplied key is used to wrap or unwrap the
448 content encryption key using an \s-1AES\s0 key in the \fBKEKRecipientInfo\fR type.
449 .IP "\fB\-secretkeyid id\fR" 4
450 .IX Item "-secretkeyid id"
451 the key identifier for the supplied symmetric key for \fBKEKRecipientInfo\fR type.
452 This option \fBmust\fR be present if the \fB\-secretkey\fR option is used with
453 \&\fB\-encrypt\fR. With \fB\-decrypt\fR operations the \fBid\fR is used to locate the
454 relevant key if it is not supplied then an attempt is used to decrypt any
455 \&\fBKEKRecipientInfo\fR structures.
456 .IP "\fB\-econtent_type type\fR" 4
457 .IX Item "-econtent_type type"
458 set the encapsulated content type to \fBtype\fR if not supplied the \fBData\fR type
459 is used. The \fBtype\fR argument can be any valid \s-1OID\s0 name in either text or
460 numerical format.
461 .IP "\fB\-inkey file\fR" 4
462 .IX Item "-inkey file"
463 the private key to use when signing or decrypting. This must match the
464 corresponding certificate. If this option is not specified then the
465 private key must be included in the certificate file specified with
466 the \fB\-recip\fR or \fB\-signer\fR file. When signing this option can be used
467 multiple times to specify successive keys.
468 .IP "\fB\-passin arg\fR" 4
469 .IX Item "-passin arg"
470 the private key password source. For more information about the format of \fBarg\fR
471 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
472 .IP "\fB\-rand file(s)\fR" 4
473 .IX Item "-rand file(s)"
474 a file or files containing random data used to seed the random number
475 generator, or an \s-1EGD\s0 socket (see \fIRAND_egd\fR\|(3)).
476 Multiple files can be specified separated by a OS-dependent character.
477 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
478 all others.
479 .IP "\fBcert.pem...\fR" 4
480 .IX Item "cert.pem..."
481 one or more certificates of message recipients: used when encrypting
482 a message.
483 .IP "\fB\-to, \-from, \-subject\fR" 4
484 .IX Item "-to, -from, -subject"
485 the relevant mail headers. These are included outside the signed
486 portion of a message so they may be included manually. If signing
487 then many S/MIME mail clients check the signers certificate's email
488 address matches that specified in the From: address.
489 .IP "\fB\-purpose, \-ignore_critical, \-issuer_checks, \-crl_check, \-crl_check_all, \-policy_check, \-extended_crl, \-x509_strict, \-policy \-check_ss_sig \-no_alt_chains\fR" 4
490 .IX Item "-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig -no_alt_chains"
491 Set various certificate chain valiadition option. See the
492 \&\fBverify\fR manual page for details.
493 .SH "NOTES"
494 .IX Header "NOTES"
495 The \s-1MIME\s0 message must be sent without any blank lines between the
496 headers and the output. Some mail programs will automatically add
497 a blank line. Piping the mail directly to sendmail is one way to
498 achieve the correct format.
499 .PP
500 The supplied message to be signed or encrypted must include the
501 necessary \s-1MIME\s0 headers or many S/MIME clients wont display it
502 properly (if at all). You can use the \fB\-text\fR option to automatically
503 add plain text headers.
504 .PP
505 A \*(L"signed and encrypted\*(R" message is one where a signed message is
506 then encrypted. This can be produced by encrypting an already signed
507 message: see the examples section.
508 .PP
509 This version of the program only allows one signer per message but it
510 will verify multiple signers on received messages. Some S/MIME clients
511 choke if a message contains multiple signers. It is possible to sign
512 messages \*(L"in parallel\*(R" by signing an already signed message.
513 .PP
514 The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME
515 clients. Strictly speaking these process \s-1CMS\s0 enveloped data: \s-1CMS\s0
516 encrypted data is used for other purposes.
517 .PP
518 The \fB\-resign\fR option uses an existing message digest when adding a new
519 signer. This means that attributes must be present in at least one existing
520 signer using the same message digest or this operation will fail.
521 .PP
522 The \fB\-stream\fR and \fB\-indef\fR options enable experimental streaming I/O support.
523 As a result the encoding is \s-1BER\s0 using indefinite length constructed encoding
524 and no longer \s-1DER.\s0 Streaming is supported for the \fB\-encrypt\fR operation and the
525 \&\fB\-sign\fR operation if the content is not detached.
526 .PP
527 Streaming is always used for the \fB\-sign\fR operation with detached data but
528 since the content is no longer part of the \s-1CMS\s0 structure the encoding
529 remains \s-1DER.\s0
530 .PP
531 If the \fB\-decrypt\fR option is used without a recipient certificate then an
532 attempt is made to locate the recipient by trying each potential recipient
533 in turn using the supplied private key. To thwart the \s-1MMA\s0 attack
534 (Bleichenbacher's attack on \s-1PKCS\s0 #1 v1.5 \s-1RSA\s0 padding) all recipients are
535 tried whether they succeed or not and if no recipients match the message
536 is \*(L"decrypted\*(R" using a random key which will typically output garbage. 
537 The \fB\-debug_decrypt\fR option can be used to disable the \s-1MMA\s0 attack protection
538 and return an error if no recipient can be found: this option should be used
539 with caution. For a fuller description see \fICMS_decrypt\fR\|(3)).
540 .SH "EXIT CODES"
541 .IX Header "EXIT CODES"
542 .IP "0" 4
543 the operation was completely successfully.
544 .IP "1" 4
545 .IX Item "1"
546 an error occurred parsing the command options.
547 .IP "2" 4
548 .IX Item "2"
549 one of the input files could not be read.
550 .IP "3" 4
551 .IX Item "3"
552 an error occurred creating the \s-1CMS\s0 file or when reading the \s-1MIME\s0
553 message.
554 .IP "4" 4
555 .IX Item "4"
556 an error occurred decrypting or verifying the message.
557 .IP "5" 4
558 .IX Item "5"
559 the message was verified correctly but an error occurred writing out
560 the signers certificates.
561 .SH "COMPATIBILITY WITH PKCS#7 format."
562 .IX Header "COMPATIBILITY WITH PKCS#7 format."
563 The \fBsmime\fR utility can only process the older \fBPKCS#7\fR format. The \fBcms\fR
564 utility supports Cryptographic Message Syntax format. Use of some features
565 will result in messages which cannot be processed by applications which only
566 support the older format. These are detailed below.
567 .PP
568 The use of the \fB\-keyid\fR option with \fB\-sign\fR or \fB\-encrypt\fR.
569 .PP
570 The \fB\-outform \s-1PEM\s0\fR option uses different headers.
571 .PP
572 The \fB\-compress\fR option.
573 .PP
574 The \fB\-secretkey\fR option when used with \fB\-encrypt\fR.
575 .PP
576 Additionally the \fB\-EncryptedData_create\fR and \fB\-data_create\fR type cannot
577 be processed by the older \fBsmime\fR command.
578 .SH "EXAMPLES"
579 .IX Header "EXAMPLES"
580 Create a cleartext signed message:
581 .PP
582 .Vb 2
583 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e
584 \&        \-signer mycert.pem
585 .Ve
586 .PP
587 Create an opaque signed message
588 .PP
589 .Vb 2
590 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \-nodetach \e
591 \&        \-signer mycert.pem
592 .Ve
593 .PP
594 Create a signed message, include some additional certificates and
595 read the private key from another file:
596 .PP
597 .Vb 2
598 \& openssl cms \-sign \-in in.txt \-text \-out mail.msg \e
599 \&        \-signer mycert.pem \-inkey mykey.pem \-certfile mycerts.pem
600 .Ve
601 .PP
602 Create a signed message with two signers, use key identifier:
603 .PP
604 .Vb 2
605 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e
606 \&        \-signer mycert.pem \-signer othercert.pem \-keyid
607 .Ve
608 .PP
609 Send a signed message under Unix directly to sendmail, including headers:
610 .PP
611 .Vb 3
612 \& openssl cms \-sign \-in in.txt \-text \-signer mycert.pem \e
613 \&        \-from steve@openssl.org \-to someone@somewhere \e
614 \&        \-subject "Signed message" | sendmail someone@somewhere
615 .Ve
616 .PP
617 Verify a message and extract the signer's certificate if successful:
618 .PP
619 .Vb 1
620 \& openssl cms \-verify \-in mail.msg \-signer user.pem \-out signedtext.txt
621 .Ve
622 .PP
623 Send encrypted mail using triple \s-1DES:\s0
624 .PP
625 .Vb 3
626 \& openssl cms \-encrypt \-in in.txt \-from steve@openssl.org \e
627 \&        \-to someone@somewhere \-subject "Encrypted message" \e
628 \&        \-des3 user.pem \-out mail.msg
629 .Ve
630 .PP
631 Sign and encrypt mail:
632 .PP
633 .Vb 4
634 \& openssl cms \-sign \-in ml.txt \-signer my.pem \-text \e
635 \&        | openssl cms \-encrypt \-out mail.msg \e
636 \&        \-from steve@openssl.org \-to someone@somewhere \e
637 \&        \-subject "Signed and Encrypted message" \-des3 user.pem
638 .Ve
639 .PP
640 Note: the encryption command does not include the \fB\-text\fR option because the
641 message being encrypted already has \s-1MIME\s0 headers.
642 .PP
643 Decrypt mail:
644 .PP
645 .Vb 1
646 \& openssl cms \-decrypt \-in mail.msg \-recip mycert.pem \-inkey key.pem
647 .Ve
648 .PP
649 The output from Netscape form signing is a PKCS#7 structure with the
650 detached signature format. You can use this program to verify the
651 signature by line wrapping the base64 encoded structure and surrounding
652 it with:
653 .PP
654 .Vb 2
655 \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\-
656 \& \-\-\-\-\-END PKCS7\-\-\-\-\-
657 .Ve
658 .PP
659 and using the command,
660 .PP
661 .Vb 1
662 \& openssl cms \-verify \-inform PEM \-in signature.pem \-content content.txt
663 .Ve
664 .PP
665 alternatively you can base64 decode the signature and use
666 .PP
667 .Vb 1
668 \& openssl cms \-verify \-inform DER \-in signature.der \-content content.txt
669 .Ve
670 .PP
671 Create an encrypted message using 128 bit Camellia:
672 .PP
673 .Vb 1
674 \& openssl cms \-encrypt \-in plain.txt \-camellia128 \-out mail.msg cert.pem
675 .Ve
676 .PP
677 Add a signer to an existing message:
678 .PP
679 .Vb 1
680 \& openssl cms \-resign \-in mail.msg \-signer newsign.pem \-out mail2.msg
681 .Ve
682 .SH "BUGS"
683 .IX Header "BUGS"
684 The \s-1MIME\s0 parser isn't very clever: it seems to handle most messages that I've
685 thrown at it but it may choke on others.
686 .PP
687 The code currently will only write out the signer's certificate to a file: if
688 the signer has a separate encryption certificate this must be manually
689 extracted. There should be some heuristic that determines the correct
690 encryption certificate.
691 .PP
692 Ideally a database should be maintained of a certificates for each email
693 address.
694 .PP
695 The code doesn't currently take note of the permitted symmetric encryption
696 algorithms as supplied in the SMIMECapabilities signed attribute. this means the
697 user has to manually include the correct encryption algorithm. It should store
698 the list of permitted ciphers in a database and only use those.
699 .PP
700 No revocation checking is done on the signer's certificate.
701 .SH "HISTORY"
702 .IX Header "HISTORY"
703 The use of multiple \fB\-signer\fR options and the \fB\-resign\fR command were first
704 added in OpenSSL 1.0.0
705 .PP
706 The \-no_alt_chains options was first added to OpenSSL 1.0.1n and 1.0.2b.