]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - secure/usr.bin/openssl/man/cms.1
MFC: r340705, r340708
[FreeBSD/FreeBSD.git] / secure / usr.bin / openssl / man / cms.1
1 .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
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 >0, 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 .if !\nF .nr F 0
58 .if \nF>0 \{\
59 .    de IX
60 .    tm Index:\\$1\t\\n%\t"\\$2"
61 ..
62 .    if !\nF==2 \{\
63 .        nr % 0
64 .        nr F 2
65 .    \}
66 .\}
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "CMS 1"
132 .TH CMS 1 "2018-11-20" "1.1.1a" "OpenSSL"
133 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
134 .\" way too many mistakes in technical documents.
135 .if n .ad l
136 .nh
137 .SH "NAME"
138 openssl\-cms, cms \- CMS utility
139 .SH "SYNOPSIS"
140 .IX Header "SYNOPSIS"
141 \&\fBopenssl\fR \fBcms\fR
142 [\fB\-help\fR]
143 [\fB\-encrypt\fR]
144 [\fB\-decrypt\fR]
145 [\fB\-sign\fR]
146 [\fB\-verify\fR]
147 [\fB\-cmsout\fR]
148 [\fB\-resign\fR]
149 [\fB\-data_create\fR]
150 [\fB\-data_out\fR]
151 [\fB\-digest_create\fR]
152 [\fB\-digest_verify\fR]
153 [\fB\-compress\fR]
154 [\fB\-uncompress\fR]
155 [\fB\-EncryptedData_encrypt\fR]
156 [\fB\-sign_receipt\fR]
157 [\fB\-verify_receipt receipt\fR]
158 [\fB\-in filename\fR]
159 [\fB\-inform SMIME|PEM|DER\fR]
160 [\fB\-rctform SMIME|PEM|DER\fR]
161 [\fB\-out filename\fR]
162 [\fB\-outform SMIME|PEM|DER\fR]
163 [\fB\-stream \-indef \-noindef\fR]
164 [\fB\-noindef\fR]
165 [\fB\-content filename\fR]
166 [\fB\-text\fR]
167 [\fB\-noout\fR]
168 [\fB\-print\fR]
169 [\fB\-CAfile file\fR]
170 [\fB\-CApath dir\fR]
171 [\fB\-no\-CAfile\fR]
172 [\fB\-no\-CApath\fR]
173 [\fB\-attime timestamp\fR]
174 [\fB\-check_ss_sig\fR]
175 [\fB\-crl_check\fR]
176 [\fB\-crl_check_all\fR]
177 [\fB\-explicit_policy\fR]
178 [\fB\-extended_crl\fR]
179 [\fB\-ignore_critical\fR]
180 [\fB\-inhibit_any\fR]
181 [\fB\-inhibit_map\fR]
182 [\fB\-no_check_time\fR]
183 [\fB\-partial_chain\fR]
184 [\fB\-policy arg\fR]
185 [\fB\-policy_check\fR]
186 [\fB\-policy_print\fR]
187 [\fB\-purpose purpose\fR]
188 [\fB\-suiteB_128\fR]
189 [\fB\-suiteB_128_only\fR]
190 [\fB\-suiteB_192\fR]
191 [\fB\-trusted_first\fR]
192 [\fB\-no_alt_chains\fR]
193 [\fB\-use_deltas\fR]
194 [\fB\-auth_level num\fR]
195 [\fB\-verify_depth num\fR]
196 [\fB\-verify_email email\fR]
197 [\fB\-verify_hostname hostname\fR]
198 [\fB\-verify_ip ip\fR]
199 [\fB\-verify_name name\fR]
200 [\fB\-x509_strict\fR]
201 [\fB\-md digest\fR]
202 [\fB\-\f(BIcipher\fB\fR]
203 [\fB\-nointern\fR]
204 [\fB\-noverify\fR]
205 [\fB\-nocerts\fR]
206 [\fB\-noattr\fR]
207 [\fB\-nosmimecap\fR]
208 [\fB\-binary\fR]
209 [\fB\-crlfeol\fR]
210 [\fB\-asciicrlf\fR]
211 [\fB\-nodetach\fR]
212 [\fB\-certfile file\fR]
213 [\fB\-certsout file\fR]
214 [\fB\-signer file\fR]
215 [\fB\-recip file\fR]
216 [\fB\-keyid\fR]
217 [\fB\-receipt_request_all\fR]
218 [\fB\-receipt_request_first\fR]
219 [\fB\-receipt_request_from emailaddress\fR]
220 [\fB\-receipt_request_to emailaddress\fR]
221 [\fB\-receipt_request_print\fR]
222 [\fB\-secretkey key\fR]
223 [\fB\-secretkeyid id\fR]
224 [\fB\-econtent_type type\fR]
225 [\fB\-inkey file\fR]
226 [\fB\-keyopt name:parameter\fR]
227 [\fB\-passin arg\fR]
228 [\fB\-rand file...\fR]
229 [\fB\-writerand file\fR]
230 [\fBcert.pem...\fR]
231 [\fB\-to addr\fR]
232 [\fB\-from addr\fR]
233 [\fB\-subject subj\fR]
234 [cert.pem]...
235 .SH "DESCRIPTION"
236 .IX Header "DESCRIPTION"
237 The \fBcms\fR command handles S/MIME v3.1 mail. It can encrypt, decrypt, sign and
238 verify, compress and uncompress S/MIME messages.
239 .SH "OPTIONS"
240 .IX Header "OPTIONS"
241 There are fourteen operation options that set the type of operation to be
242 performed. The meaning of the other options varies according to the operation
243 type.
244 .IP "\fB\-help\fR" 4
245 .IX Item "-help"
246 Print out a usage message.
247 .IP "\fB\-encrypt\fR" 4
248 .IX Item "-encrypt"
249 Encrypt mail for the given recipient certificates. Input file is the message
250 to be encrypted. The output file is the encrypted mail in \s-1MIME\s0 format. The
251 actual \s-1CMS\s0 type is <B>EnvelopedData<B>.
252 .Sp
253 Note that no revocation check is done for the recipient cert, so if that
254 key has been compromised, others may be able to decrypt the text.
255 .IP "\fB\-decrypt\fR" 4
256 .IX Item "-decrypt"
257 Decrypt mail using the supplied certificate and private key. Expects an
258 encrypted mail message in \s-1MIME\s0 format for the input file. The decrypted mail
259 is written to the output file.
260 .IP "\fB\-debug_decrypt\fR" 4
261 .IX Item "-debug_decrypt"
262 This option sets the \fB\s-1CMS_DEBUG_DECRYPT\s0\fR flag. This option should be used
263 with caution: see the notes section below.
264 .IP "\fB\-sign\fR" 4
265 .IX Item "-sign"
266 Sign mail using the supplied certificate and private key. Input file is
267 the message to be signed. The signed message in \s-1MIME\s0 format is written
268 to the output file.
269 .IP "\fB\-verify\fR" 4
270 .IX Item "-verify"
271 Verify signed mail. Expects a signed mail message on input and outputs
272 the signed data. Both clear text and opaque signing is supported.
273 .IP "\fB\-cmsout\fR" 4
274 .IX Item "-cmsout"
275 Takes an input message and writes out a \s-1PEM\s0 encoded \s-1CMS\s0 structure.
276 .IP "\fB\-resign\fR" 4
277 .IX Item "-resign"
278 Resign a message: take an existing message and one or more new signers.
279 .IP "\fB\-data_create\fR" 4
280 .IX Item "-data_create"
281 Create a \s-1CMS\s0 \fBData\fR type.
282 .IP "\fB\-data_out\fR" 4
283 .IX Item "-data_out"
284 \&\fBData\fR type and output the content.
285 .IP "\fB\-digest_create\fR" 4
286 .IX Item "-digest_create"
287 Create a \s-1CMS\s0 \fBDigestedData\fR type.
288 .IP "\fB\-digest_verify\fR" 4
289 .IX Item "-digest_verify"
290 Verify a \s-1CMS\s0 \fBDigestedData\fR type and output the content.
291 .IP "\fB\-compress\fR" 4
292 .IX Item "-compress"
293 Create a \s-1CMS\s0 \fBCompressedData\fR type. OpenSSL must be compiled with \fBzlib\fR
294 support for this option to work, otherwise it will output an error.
295 .IP "\fB\-uncompress\fR" 4
296 .IX Item "-uncompress"
297 Uncompress a \s-1CMS\s0 \fBCompressedData\fR type and output the content. OpenSSL must be
298 compiled with \fBzlib\fR support for this option to work, otherwise it will
299 output an error.
300 .IP "\fB\-EncryptedData_encrypt\fR" 4
301 .IX Item "-EncryptedData_encrypt"
302 Encrypt content using supplied symmetric key and algorithm using a \s-1CMS\s0
303 \&\fBEncryptedData\fR type and output the content.
304 .IP "\fB\-sign_receipt\fR" 4
305 .IX Item "-sign_receipt"
306 Generate and output a signed receipt for the supplied message. The input
307 message \fBmust\fR contain a signed receipt request. Functionality is otherwise
308 similar to the \fB\-sign\fR operation.
309 .IP "\fB\-verify_receipt receipt\fR" 4
310 .IX Item "-verify_receipt receipt"
311 Verify a signed receipt in filename \fBreceipt\fR. The input message \fBmust\fR
312 contain the original receipt request. Functionality is otherwise similar
313 to the \fB\-verify\fR operation.
314 .IP "\fB\-in filename\fR" 4
315 .IX Item "-in filename"
316 The input message to be encrypted or signed or the message to be decrypted
317 or verified.
318 .IP "\fB\-inform SMIME|PEM|DER\fR" 4
319 .IX Item "-inform SMIME|PEM|DER"
320 This specifies the input format for the \s-1CMS\s0 structure. The default
321 is \fB\s-1SMIME\s0\fR which reads an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
322 format change this to expect \s-1PEM\s0 and \s-1DER\s0 format \s-1CMS\s0 structures
323 instead. This currently only affects the input format of the \s-1CMS\s0
324 structure, if no \s-1CMS\s0 structure is being input (for example with
325 \&\fB\-encrypt\fR or \fB\-sign\fR) this option has no effect.
326 .IP "\fB\-rctform SMIME|PEM|DER\fR" 4
327 .IX Item "-rctform SMIME|PEM|DER"
328 Specify the format for a signed receipt for use with the \fB\-receipt_verify\fR
329 operation.
330 .IP "\fB\-out filename\fR" 4
331 .IX Item "-out filename"
332 The message text that has been decrypted or verified or the output \s-1MIME\s0
333 format message that has been signed or verified.
334 .IP "\fB\-outform SMIME|PEM|DER\fR" 4
335 .IX Item "-outform SMIME|PEM|DER"
336 This specifies the output format for the \s-1CMS\s0 structure. The default
337 is \fB\s-1SMIME\s0\fR which writes an S/MIME format message. \fB\s-1PEM\s0\fR and \fB\s-1DER\s0\fR
338 format change this to write \s-1PEM\s0 and \s-1DER\s0 format \s-1CMS\s0 structures
339 instead. This currently only affects the output format of the \s-1CMS\s0
340 structure, if no \s-1CMS\s0 structure is being output (for example with
341 \&\fB\-verify\fR or \fB\-decrypt\fR) this option has no effect.
342 .IP "\fB\-stream \-indef \-noindef\fR" 4
343 .IX Item "-stream -indef -noindef"
344 The \fB\-stream\fR and \fB\-indef\fR options are equivalent and enable streaming I/O
345 for encoding operations. This permits single pass processing of data without
346 the need to hold the entire contents in memory, potentially supporting very
347 large files. Streaming is automatically set for S/MIME signing with detached
348 data if the output format is \fB\s-1SMIME\s0\fR it is currently off by default for all
349 other operations.
350 .IP "\fB\-noindef\fR" 4
351 .IX Item "-noindef"
352 Disable streaming I/O where it would produce and indefinite length constructed
353 encoding. This option currently has no effect. In future streaming will be
354 enabled by default on all relevant operations and this option will disable it.
355 .IP "\fB\-content filename\fR" 4
356 .IX Item "-content filename"
357 This specifies a file containing the detached content, this is only
358 useful with the \fB\-verify\fR command. This is only usable if the \s-1CMS\s0
359 structure is using the detached signature form where the content is
360 not included. This option will override any content if the input format
361 is S/MIME and it uses the multipart/signed \s-1MIME\s0 content type.
362 .IP "\fB\-text\fR" 4
363 .IX Item "-text"
364 This option adds plain text (text/plain) \s-1MIME\s0 headers to the supplied
365 message if encrypting or signing. If decrypting or verifying it strips
366 off text headers: if the decrypted or verified message is not of \s-1MIME\s0
367 type text/plain then an error occurs.
368 .IP "\fB\-noout\fR" 4
369 .IX Item "-noout"
370 For the \fB\-cmsout\fR operation do not output the parsed \s-1CMS\s0 structure. This
371 is useful when combined with the \fB\-print\fR option or if the syntax of the \s-1CMS\s0
372 structure is being checked.
373 .IP "\fB\-print\fR" 4
374 .IX Item "-print"
375 For the \fB\-cmsout\fR operation print out all fields of the \s-1CMS\s0 structure. This
376 is mainly useful for testing purposes.
377 .IP "\fB\-CAfile file\fR" 4
378 .IX Item "-CAfile file"
379 A file containing trusted \s-1CA\s0 certificates, only used with \fB\-verify\fR.
380 .IP "\fB\-CApath dir\fR" 4
381 .IX Item "-CApath dir"
382 A directory containing trusted \s-1CA\s0 certificates, only used with
383 \&\fB\-verify\fR. This directory must be a standard certificate directory: that
384 is a hash of each subject name (using \fBx509 \-hash\fR) should be linked
385 to each certificate.
386 .IP "\fB\-no\-CAfile\fR" 4
387 .IX Item "-no-CAfile"
388 Do not load the trusted \s-1CA\s0 certificates from the default file location
389 .IP "\fB\-no\-CApath\fR" 4
390 .IX Item "-no-CApath"
391 Do not load the trusted \s-1CA\s0 certificates from the default directory location
392 .IP "\fB\-md digest\fR" 4
393 .IX Item "-md digest"
394 Digest algorithm to use when signing or resigning. If not present then the
395 default digest algorithm for the signing key will be used (usually \s-1SHA1\s0).
396 .IP "\fB\-\f(BIcipher\fB\fR" 4
397 .IX Item "-cipher"
398 The encryption algorithm to use. For example triple \s-1DES\s0 (168 bits) \- \fB\-des3\fR
399 or 256 bit \s-1AES\s0 \- \fB\-aes256\fR. Any standard algorithm name (as used by the
400 \&\fIEVP_get_cipherbyname()\fR function) can also be used preceded by a dash, for
401 example \fB\-aes\-128\-cbc\fR. See \fIenc\fR\|(1) for a list of ciphers
402 supported by your version of OpenSSL.
403 .Sp
404 If not specified triple \s-1DES\s0 is used. Only used with \fB\-encrypt\fR and
405 \&\fB\-EncryptedData_create\fR commands.
406 .IP "\fB\-nointern\fR" 4
407 .IX Item "-nointern"
408 When verifying a message normally certificates (if any) included in
409 the message are searched for the signing certificate. With this option
410 only the certificates specified in the \fB\-certfile\fR option are used.
411 The supplied certificates can still be used as untrusted CAs however.
412 .IP "\fB\-noverify\fR" 4
413 .IX Item "-noverify"
414 Do not verify the signers certificate of a signed message.
415 .IP "\fB\-nocerts\fR" 4
416 .IX Item "-nocerts"
417 When signing a message the signer's certificate is normally included
418 with this option it is excluded. This will reduce the size of the
419 signed message but the verifier must have a copy of the signers certificate
420 available locally (passed using the \fB\-certfile\fR option for example).
421 .IP "\fB\-noattr\fR" 4
422 .IX Item "-noattr"
423 Normally when a message is signed a set of attributes are included which
424 include the signing time and supported symmetric algorithms. With this
425 option they are not included.
426 .IP "\fB\-nosmimecap\fR" 4
427 .IX Item "-nosmimecap"
428 Exclude the list of supported algorithms from signed attributes, other options
429 such as signing time and content type are still included.
430 .IP "\fB\-binary\fR" 4
431 .IX Item "-binary"
432 Normally the input message is converted to \*(L"canonical\*(R" format which is
433 effectively using \s-1CR\s0 and \s-1LF\s0 as end of line: as required by the S/MIME
434 specification. When this option is present no translation occurs. This
435 is useful when handling binary data which may not be in \s-1MIME\s0 format.
436 .IP "\fB\-crlfeol\fR" 4
437 .IX Item "-crlfeol"
438 Normally the output file uses a single \fB\s-1LF\s0\fR as end of line. When this
439 option is present \fB\s-1CRLF\s0\fR is used instead.
440 .IP "\fB\-asciicrlf\fR" 4
441 .IX Item "-asciicrlf"
442 When signing use \s-1ASCII CRLF\s0 format canonicalisation. This strips trailing
443 whitespace from all lines, deletes trailing blank lines at \s-1EOF\s0 and sets
444 the encapsulated content type. This option is normally used with detached
445 content and an output signature format of \s-1DER.\s0 This option is not normally
446 needed when verifying as it is enabled automatically if the encapsulated
447 content format is detected.
448 .IP "\fB\-nodetach\fR" 4
449 .IX Item "-nodetach"
450 When signing a message use opaque signing: this form is more resistant
451 to translation by mail relays but it cannot be read by mail agents that
452 do not support S/MIME.  Without this option cleartext signing with
453 the \s-1MIME\s0 type multipart/signed is used.
454 .IP "\fB\-certfile file\fR" 4
455 .IX Item "-certfile file"
456 Allows additional certificates to be specified. When signing these will
457 be included with the message. When verifying these will be searched for
458 the signers certificates. The certificates should be in \s-1PEM\s0 format.
459 .IP "\fB\-certsout file\fR" 4
460 .IX Item "-certsout file"
461 Any certificates contained in the message are written to \fBfile\fR.
462 .IP "\fB\-signer file\fR" 4
463 .IX Item "-signer file"
464 A signing certificate when signing or resigning a message, this option can be
465 used multiple times if more than one signer is required. If a message is being
466 verified then the signers certificates will be written to this file if the
467 verification was successful.
468 .IP "\fB\-recip file\fR" 4
469 .IX Item "-recip file"
470 When decrypting a message this specifies the recipients certificate. The
471 certificate must match one of the recipients of the message or an error
472 occurs.
473 .Sp
474 When encrypting a message this option may be used multiple times to specify
475 each recipient. This form \fBmust\fR be used if customised parameters are
476 required (for example to specify RSA-OAEP).
477 .Sp
478 Only certificates carrying \s-1RSA,\s0 Diffie-Hellman or \s-1EC\s0 keys are supported by this
479 option.
480 .IP "\fB\-keyid\fR" 4
481 .IX Item "-keyid"
482 Use subject key identifier to identify certificates instead of issuer name and
483 serial number. The supplied certificate \fBmust\fR include a subject key
484 identifier extension. Supported by \fB\-sign\fR and \fB\-encrypt\fR options.
485 .IP "\fB\-receipt_request_all\fR, \fB\-receipt_request_first\fR" 4
486 .IX Item "-receipt_request_all, -receipt_request_first"
487 For \fB\-sign\fR option include a signed receipt request. Indicate requests should
488 be provided by all recipient or first tier recipients (those mailed directly
489 and not from a mailing list). Ignored it \fB\-receipt_request_from\fR is included.
490 .IP "\fB\-receipt_request_from emailaddress\fR" 4
491 .IX Item "-receipt_request_from emailaddress"
492 For \fB\-sign\fR option include a signed receipt request. Add an explicit email
493 address where receipts should be supplied.
494 .IP "\fB\-receipt_request_to emailaddress\fR" 4
495 .IX Item "-receipt_request_to emailaddress"
496 Add an explicit email address where signed receipts should be sent to. This
497 option \fBmust\fR but supplied if a signed receipt it requested.
498 .IP "\fB\-receipt_request_print\fR" 4
499 .IX Item "-receipt_request_print"
500 For the \fB\-verify\fR operation print out the contents of any signed receipt
501 requests.
502 .IP "\fB\-secretkey key\fR" 4
503 .IX Item "-secretkey key"
504 Specify symmetric key to use. The key must be supplied in hex format and be
505 consistent with the algorithm used. Supported by the \fB\-EncryptedData_encrypt\fR
506 \&\fB\-EncryptedData_decrypt\fR, \fB\-encrypt\fR and \fB\-decrypt\fR options. When used
507 with \fB\-encrypt\fR or \fB\-decrypt\fR the supplied key is used to wrap or unwrap the
508 content encryption key using an \s-1AES\s0 key in the \fBKEKRecipientInfo\fR type.
509 .IP "\fB\-secretkeyid id\fR" 4
510 .IX Item "-secretkeyid id"
511 The key identifier for the supplied symmetric key for \fBKEKRecipientInfo\fR type.
512 This option \fBmust\fR be present if the \fB\-secretkey\fR option is used with
513 \&\fB\-encrypt\fR. With \fB\-decrypt\fR operations the \fBid\fR is used to locate the
514 relevant key if it is not supplied then an attempt is used to decrypt any
515 \&\fBKEKRecipientInfo\fR structures.
516 .IP "\fB\-econtent_type type\fR" 4
517 .IX Item "-econtent_type type"
518 Set the encapsulated content type to \fBtype\fR if not supplied the \fBData\fR type
519 is used. The \fBtype\fR argument can be any valid \s-1OID\s0 name in either text or
520 numerical format.
521 .IP "\fB\-inkey file\fR" 4
522 .IX Item "-inkey file"
523 The private key to use when signing or decrypting. This must match the
524 corresponding certificate. If this option is not specified then the
525 private key must be included in the certificate file specified with
526 the \fB\-recip\fR or \fB\-signer\fR file. When signing this option can be used
527 multiple times to specify successive keys.
528 .IP "\fB\-keyopt name:opt\fR" 4
529 .IX Item "-keyopt name:opt"
530 For signing and encryption this option can be used multiple times to
531 set customised parameters for the preceding key or certificate. It can
532 currently be used to set RSA-PSS for signing, RSA-OAEP for encryption
533 or to modify default parameters for \s-1ECDH.\s0
534 .IP "\fB\-passin arg\fR" 4
535 .IX Item "-passin arg"
536 The private key password source. For more information about the format of \fBarg\fR
537 see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
538 .IP "\fB\-rand file...\fR" 4
539 .IX Item "-rand file..."
540 A file or files containing random data used to seed the random number
541 generator.
542 Multiple files can be specified separated by an OS-dependent character.
543 The separator is \fB;\fR for MS-Windows, \fB,\fR for OpenVMS, and \fB:\fR for
544 all others.
545 .IP "[\fB\-writerand file\fR]" 4
546 .IX Item "[-writerand file]"
547 Writes random data to the specified \fIfile\fR upon exit.
548 This can be used with a subsequent \fB\-rand\fR flag.
549 .IP "\fBcert.pem...\fR" 4
550 .IX Item "cert.pem..."
551 One or more certificates of message recipients: used when encrypting
552 a message.
553 .IP "\fB\-to, \-from, \-subject\fR" 4
554 .IX Item "-to, -from, -subject"
555 The relevant mail headers. These are included outside the signed
556 portion of a message so they may be included manually. If signing
557 then many S/MIME mail clients check the signers certificate's email
558 address matches that specified in the From: address.
559 .IP "\fB\-attime\fR, \fB\-check_ss_sig\fR, \fB\-crl_check\fR, \fB\-crl_check_all\fR, \fB\-explicit_policy\fR, \fB\-extended_crl\fR, \fB\-ignore_critical\fR, \fB\-inhibit_any\fR, \fB\-inhibit_map\fR, \fB\-no_alt_chains\fR, \fB\-no_check_time\fR, \fB\-partial_chain\fR, \fB\-policy\fR, \fB\-policy_check\fR, \fB\-policy_print\fR, \fB\-purpose\fR, \fB\-suiteB_128\fR, \fB\-suiteB_128_only\fR, \fB\-suiteB_192\fR, \fB\-trusted_first\fR, \fB\-use_deltas\fR, \fB\-auth_level\fR, \fB\-verify_depth\fR, \fB\-verify_email\fR, \fB\-verify_hostname\fR, \fB\-verify_ip\fR, \fB\-verify_name\fR, \fB\-x509_strict\fR" 4
560 .IX Item "-attime, -check_ss_sig, -crl_check, -crl_check_all, -explicit_policy, -extended_crl, -ignore_critical, -inhibit_any, -inhibit_map, -no_alt_chains, -no_check_time, -partial_chain, -policy, -policy_check, -policy_print, -purpose, -suiteB_128, -suiteB_128_only, -suiteB_192, -trusted_first, -use_deltas, -auth_level, -verify_depth, -verify_email, -verify_hostname, -verify_ip, -verify_name, -x509_strict"
561 Set various certificate chain validation options. See the
562 \&\fIverify\fR\|(1) manual page for details.
563 .SH "NOTES"
564 .IX Header "NOTES"
565 The \s-1MIME\s0 message must be sent without any blank lines between the
566 headers and the output. Some mail programs will automatically add
567 a blank line. Piping the mail directly to sendmail is one way to
568 achieve the correct format.
569 .PP
570 The supplied message to be signed or encrypted must include the
571 necessary \s-1MIME\s0 headers or many S/MIME clients won't display it
572 properly (if at all). You can use the \fB\-text\fR option to automatically
573 add plain text headers.
574 .PP
575 A \*(L"signed and encrypted\*(R" message is one where a signed message is
576 then encrypted. This can be produced by encrypting an already signed
577 message: see the examples section.
578 .PP
579 This version of the program only allows one signer per message but it
580 will verify multiple signers on received messages. Some S/MIME clients
581 choke if a message contains multiple signers. It is possible to sign
582 messages \*(L"in parallel\*(R" by signing an already signed message.
583 .PP
584 The options \fB\-encrypt\fR and \fB\-decrypt\fR reflect common usage in S/MIME
585 clients. Strictly speaking these process \s-1CMS\s0 enveloped data: \s-1CMS\s0
586 encrypted data is used for other purposes.
587 .PP
588 The \fB\-resign\fR option uses an existing message digest when adding a new
589 signer. This means that attributes must be present in at least one existing
590 signer using the same message digest or this operation will fail.
591 .PP
592 The \fB\-stream\fR and \fB\-indef\fR options enable streaming I/O support.
593 As a result the encoding is \s-1BER\s0 using indefinite length constructed encoding
594 and no longer \s-1DER.\s0 Streaming is supported for the \fB\-encrypt\fR operation and the
595 \&\fB\-sign\fR operation if the content is not detached.
596 .PP
597 Streaming is always used for the \fB\-sign\fR operation with detached data but
598 since the content is no longer part of the \s-1CMS\s0 structure the encoding
599 remains \s-1DER.\s0
600 .PP
601 If the \fB\-decrypt\fR option is used without a recipient certificate then an
602 attempt is made to locate the recipient by trying each potential recipient
603 in turn using the supplied private key. To thwart the \s-1MMA\s0 attack
604 (Bleichenbacher's attack on \s-1PKCS\s0 #1 v1.5 \s-1RSA\s0 padding) all recipients are
605 tried whether they succeed or not and if no recipients match the message
606 is \*(L"decrypted\*(R" using a random key which will typically output garbage.
607 The \fB\-debug_decrypt\fR option can be used to disable the \s-1MMA\s0 attack protection
608 and return an error if no recipient can be found: this option should be used
609 with caution. For a fuller description see \fICMS_decrypt\fR\|(3)).
610 .SH "EXIT CODES"
611 .IX Header "EXIT CODES"
612 .IP "0" 4
613 The operation was completely successfully.
614 .IP "1" 4
615 .IX Item "1"
616 An error occurred parsing the command options.
617 .IP "2" 4
618 .IX Item "2"
619 One of the input files could not be read.
620 .IP "3" 4
621 .IX Item "3"
622 An error occurred creating the \s-1CMS\s0 file or when reading the \s-1MIME\s0
623 message.
624 .IP "4" 4
625 .IX Item "4"
626 An error occurred decrypting or verifying the message.
627 .IP "5" 4
628 .IX Item "5"
629 The message was verified correctly but an error occurred writing out
630 the signers certificates.
631 .SH "COMPATIBILITY WITH PKCS#7 format."
632 .IX Header "COMPATIBILITY WITH PKCS#7 format."
633 The \fBsmime\fR utility can only process the older \fBPKCS#7\fR format. The \fBcms\fR
634 utility supports Cryptographic Message Syntax format. Use of some features
635 will result in messages which cannot be processed by applications which only
636 support the older format. These are detailed below.
637 .PP
638 The use of the \fB\-keyid\fR option with \fB\-sign\fR or \fB\-encrypt\fR.
639 .PP
640 The \fB\-outform \s-1PEM\s0\fR option uses different headers.
641 .PP
642 The \fB\-compress\fR option.
643 .PP
644 The \fB\-secretkey\fR option when used with \fB\-encrypt\fR.
645 .PP
646 The use of \s-1PSS\s0 with \fB\-sign\fR.
647 .PP
648 The use of \s-1OAEP\s0 or non-RSA keys with \fB\-encrypt\fR.
649 .PP
650 Additionally the \fB\-EncryptedData_create\fR and \fB\-data_create\fR type cannot
651 be processed by the older \fBsmime\fR command.
652 .SH "EXAMPLES"
653 .IX Header "EXAMPLES"
654 Create a cleartext signed message:
655 .PP
656 .Vb 2
657 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e
658 \&        \-signer mycert.pem
659 .Ve
660 .PP
661 Create an opaque signed message
662 .PP
663 .Vb 2
664 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \-nodetach \e
665 \&        \-signer mycert.pem
666 .Ve
667 .PP
668 Create a signed message, include some additional certificates and
669 read the private key from another file:
670 .PP
671 .Vb 2
672 \& openssl cms \-sign \-in in.txt \-text \-out mail.msg \e
673 \&        \-signer mycert.pem \-inkey mykey.pem \-certfile mycerts.pem
674 .Ve
675 .PP
676 Create a signed message with two signers, use key identifier:
677 .PP
678 .Vb 2
679 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e
680 \&        \-signer mycert.pem \-signer othercert.pem \-keyid
681 .Ve
682 .PP
683 Send a signed message under Unix directly to sendmail, including headers:
684 .PP
685 .Vb 3
686 \& openssl cms \-sign \-in in.txt \-text \-signer mycert.pem \e
687 \&        \-from steve@openssl.org \-to someone@somewhere \e
688 \&        \-subject "Signed message" | sendmail someone@somewhere
689 .Ve
690 .PP
691 Verify a message and extract the signer's certificate if successful:
692 .PP
693 .Vb 1
694 \& openssl cms \-verify \-in mail.msg \-signer user.pem \-out signedtext.txt
695 .Ve
696 .PP
697 Send encrypted mail using triple \s-1DES:\s0
698 .PP
699 .Vb 3
700 \& openssl cms \-encrypt \-in in.txt \-from steve@openssl.org \e
701 \&        \-to someone@somewhere \-subject "Encrypted message" \e
702 \&        \-des3 user.pem \-out mail.msg
703 .Ve
704 .PP
705 Sign and encrypt mail:
706 .PP
707 .Vb 4
708 \& openssl cms \-sign \-in ml.txt \-signer my.pem \-text \e
709 \&        | openssl cms \-encrypt \-out mail.msg \e
710 \&        \-from steve@openssl.org \-to someone@somewhere \e
711 \&        \-subject "Signed and Encrypted message" \-des3 user.pem
712 .Ve
713 .PP
714 Note: the encryption command does not include the \fB\-text\fR option because the
715 message being encrypted already has \s-1MIME\s0 headers.
716 .PP
717 Decrypt mail:
718 .PP
719 .Vb 1
720 \& openssl cms \-decrypt \-in mail.msg \-recip mycert.pem \-inkey key.pem
721 .Ve
722 .PP
723 The output from Netscape form signing is a PKCS#7 structure with the
724 detached signature format. You can use this program to verify the
725 signature by line wrapping the base64 encoded structure and surrounding
726 it with:
727 .PP
728 .Vb 2
729 \& \-\-\-\-\-BEGIN PKCS7\-\-\-\-\-
730 \& \-\-\-\-\-END PKCS7\-\-\-\-\-
731 .Ve
732 .PP
733 and using the command,
734 .PP
735 .Vb 1
736 \& openssl cms \-verify \-inform PEM \-in signature.pem \-content content.txt
737 .Ve
738 .PP
739 alternatively you can base64 decode the signature and use
740 .PP
741 .Vb 1
742 \& openssl cms \-verify \-inform DER \-in signature.der \-content content.txt
743 .Ve
744 .PP
745 Create an encrypted message using 128 bit Camellia:
746 .PP
747 .Vb 1
748 \& openssl cms \-encrypt \-in plain.txt \-camellia128 \-out mail.msg cert.pem
749 .Ve
750 .PP
751 Add a signer to an existing message:
752 .PP
753 .Vb 1
754 \& openssl cms \-resign \-in mail.msg \-signer newsign.pem \-out mail2.msg
755 .Ve
756 .PP
757 Sign mail using RSA-PSS:
758 .PP
759 .Vb 2
760 \& openssl cms \-sign \-in message.txt \-text \-out mail.msg \e
761 \&        \-signer mycert.pem \-keyopt rsa_padding_mode:pss
762 .Ve
763 .PP
764 Create encrypted mail using RSA-OAEP:
765 .PP
766 .Vb 2
767 \& openssl cms \-encrypt \-in plain.txt \-out mail.msg \e
768 \&        \-recip cert.pem \-keyopt rsa_padding_mode:oaep
769 .Ve
770 .PP
771 Use \s-1SHA256 KDF\s0 with an \s-1ECDH\s0 certificate:
772 .PP
773 .Vb 2
774 \& openssl cms \-encrypt \-in plain.txt \-out mail.msg \e
775 \&        \-recip ecdhcert.pem \-keyopt ecdh_kdf_md:sha256
776 .Ve
777 .SH "BUGS"
778 .IX Header "BUGS"
779 The \s-1MIME\s0 parser isn't very clever: it seems to handle most messages that I've
780 thrown at it but it may choke on others.
781 .PP
782 The code currently will only write out the signer's certificate to a file: if
783 the signer has a separate encryption certificate this must be manually
784 extracted. There should be some heuristic that determines the correct
785 encryption certificate.
786 .PP
787 Ideally a database should be maintained of a certificates for each email
788 address.
789 .PP
790 The code doesn't currently take note of the permitted symmetric encryption
791 algorithms as supplied in the SMIMECapabilities signed attribute. this means the
792 user has to manually include the correct encryption algorithm. It should store
793 the list of permitted ciphers in a database and only use those.
794 .PP
795 No revocation checking is done on the signer's certificate.
796 .SH "HISTORY"
797 .IX Header "HISTORY"
798 The use of multiple \fB\-signer\fR options and the \fB\-resign\fR command were first
799 added in OpenSSL 1.0.0.
800 .PP
801 The \fBkeyopt\fR option was first added in OpenSSL 1.0.2.
802 .PP
803 Support for RSA-OAEP and RSA-PSS was first added to OpenSSL 1.0.2.
804 .PP
805 The use of non-RSA keys with \fB\-encrypt\fR and \fB\-decrypt\fR was first added
806 to OpenSSL 1.0.2.
807 .PP
808 The \-no_alt_chains options was first added to OpenSSL 1.0.2b.
809 .SH "COPYRIGHT"
810 .IX Header "COPYRIGHT"
811 Copyright 2008\-2018 The OpenSSL Project Authors. All Rights Reserved.
812 .PP
813 Licensed under the OpenSSL license (the \*(L"License\*(R").  You may not use
814 this file except in compliance with the License.  You can obtain a copy
815 in the file \s-1LICENSE\s0 in the source distribution or at
816 <https://www.openssl.org/source/license.html>.