xref: /freebsd/crypto/openssl/doc/man1/openssl-cms.pod.in (revision 0d0c8621fd181e507f0fb50ffcca606faf66a8c2)
1b077aed3SPierre Pronchery=pod
2b077aed3SPierre Pronchery{- OpenSSL::safe::output_do_not_edit_headers(); -}
3b077aed3SPierre Pronchery
4b077aed3SPierre Pronchery=head1 NAME
5b077aed3SPierre Pronchery
6b077aed3SPierre Proncheryopenssl-cms - CMS command
7b077aed3SPierre Pronchery
8b077aed3SPierre Pronchery=head1 SYNOPSIS
9b077aed3SPierre Pronchery
10b077aed3SPierre ProncheryB<openssl> B<cms>
11b077aed3SPierre Pronchery[B<-help>]
12b077aed3SPierre Pronchery
13b077aed3SPierre ProncheryGeneral options:
14b077aed3SPierre Pronchery
15b077aed3SPierre Pronchery[B<-in> I<filename>]
16b077aed3SPierre Pronchery[B<-out> I<filename>]
17b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_config_synopsis -}
18b077aed3SPierre Pronchery
19b077aed3SPierre ProncheryOperation options:
20b077aed3SPierre Pronchery
21b077aed3SPierre Pronchery[B<-encrypt>]
22b077aed3SPierre Pronchery[B<-decrypt>]
23b077aed3SPierre Pronchery[B<-sign>]
24b077aed3SPierre Pronchery[B<-verify>]
25b077aed3SPierre Pronchery[B<-resign>]
26b077aed3SPierre Pronchery[B<-sign_receipt>]
27b077aed3SPierre Pronchery[B<-verify_receipt> I<receipt>]
28b077aed3SPierre Pronchery[B<-digest_create>]
29b077aed3SPierre Pronchery[B<-digest_verify>]
30b077aed3SPierre Pronchery[B<-compress>]
31b077aed3SPierre Pronchery[B<-uncompress>]
32b077aed3SPierre Pronchery[B<-EncryptedData_encrypt>]
33b077aed3SPierre Pronchery[B<-EncryptedData_decrypt>]
34b077aed3SPierre Pronchery[B<-data_create>]
35b077aed3SPierre Pronchery[B<-data_out>]
36b077aed3SPierre Pronchery[B<-cmsout>]
37b077aed3SPierre Pronchery
38b077aed3SPierre ProncheryFile format options:
39b077aed3SPierre Pronchery
40b077aed3SPierre Pronchery[B<-inform> B<DER>|B<PEM>|B<SMIME>]
41b077aed3SPierre Pronchery[B<-outform> B<DER>|B<PEM>|B<SMIME>]
42b077aed3SPierre Pronchery[B<-rctform> B<DER>|B<PEM>|B<SMIME>]
43b077aed3SPierre Pronchery[B<-stream>]
44b077aed3SPierre Pronchery[B<-indef>]
45b077aed3SPierre Pronchery[B<-noindef>]
46b077aed3SPierre Pronchery[B<-binary>]
47b077aed3SPierre Pronchery[B<-crlfeol>]
48b077aed3SPierre Pronchery[B<-asciicrlf>]
49b077aed3SPierre Pronchery
50b077aed3SPierre ProncheryKeys and password options:
51b077aed3SPierre Pronchery
52b077aed3SPierre Pronchery[B<-pwri_password> I<password>]
53b077aed3SPierre Pronchery[B<-secretkey> I<key>]
54b077aed3SPierre Pronchery[B<-secretkeyid> I<id>]
55b077aed3SPierre Pronchery[B<-inkey> I<filename>|I<uri>]
56b077aed3SPierre Pronchery[B<-passin> I<arg>]
57b077aed3SPierre Pronchery[B<-keyopt> I<name>:I<parameter>]
58b077aed3SPierre Pronchery[B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
59b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
60b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_r_synopsis -}
61b077aed3SPierre Pronchery
62b077aed3SPierre ProncheryEncryption options:
63b077aed3SPierre Pronchery
64b077aed3SPierre Pronchery[B<-originator> I<file>]
65b077aed3SPierre Pronchery[B<-recip> I<file>]
66b077aed3SPierre Pronchery[I<recipient-cert> ...]
67b077aed3SPierre Pronchery[B<-I<cipher>>]
68b077aed3SPierre Pronchery[B<-wrap> I<cipher>]
69b077aed3SPierre Pronchery[B<-aes128-wrap>]
70b077aed3SPierre Pronchery[B<-aes192-wrap>]
71b077aed3SPierre Pronchery[B<-aes256-wrap>]
72b077aed3SPierre Pronchery[B<-des3-wrap>]
73b077aed3SPierre Pronchery[B<-debug_decrypt>]
74b077aed3SPierre Pronchery
75b077aed3SPierre ProncherySigning options:
76b077aed3SPierre Pronchery
77b077aed3SPierre Pronchery[B<-md> I<digest>]
78b077aed3SPierre Pronchery[B<-signer> I<file>]
79b077aed3SPierre Pronchery[B<-certfile> I<file>]
80b077aed3SPierre Pronchery[B<-cades>]
81b077aed3SPierre Pronchery[B<-nodetach>]
82b077aed3SPierre Pronchery[B<-nocerts>]
83b077aed3SPierre Pronchery[B<-noattr>]
84b077aed3SPierre Pronchery[B<-nosmimecap>]
85b077aed3SPierre Pronchery[B<-receipt_request_all>]
86b077aed3SPierre Pronchery[B<-receipt_request_first>]
87b077aed3SPierre Pronchery[B<-receipt_request_from> I<emailaddress>]
88b077aed3SPierre Pronchery[B<-receipt_request_to> I<emailaddress>]
89b077aed3SPierre Pronchery
90b077aed3SPierre ProncheryVerification options:
91b077aed3SPierre Pronchery
92b077aed3SPierre Pronchery[B<-signer> I<file>]
93b077aed3SPierre Pronchery[B<-content> I<filename>]
94b077aed3SPierre Pronchery[B<-no_content_verify>]
95b077aed3SPierre Pronchery[B<-no_attr_verify>]
96b077aed3SPierre Pronchery[B<-nosigs>]
97b077aed3SPierre Pronchery[B<-noverify>]
98b077aed3SPierre Pronchery[B<-nointern>]
99b077aed3SPierre Pronchery[B<-cades>]
100b077aed3SPierre Pronchery[B<-verify_retcode>]
101b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_trust_synopsis -}
102b077aed3SPierre Pronchery
103b077aed3SPierre ProncheryOutput options:
104b077aed3SPierre Pronchery
105b077aed3SPierre Pronchery[B<-keyid>]
106b077aed3SPierre Pronchery[B<-econtent_type> I<type>]
107b077aed3SPierre Pronchery[B<-text>]
108b077aed3SPierre Pronchery[B<-certsout> I<file>]
109b077aed3SPierre Pronchery[B<-to> I<addr>]
110b077aed3SPierre Pronchery[B<-from> I<addr>]
111b077aed3SPierre Pronchery[B<-subject> I<subj>]
112b077aed3SPierre Pronchery
113b077aed3SPierre ProncheryPrinting options:
114b077aed3SPierre Pronchery
115b077aed3SPierre Pronchery[B<-noout>]
116b077aed3SPierre Pronchery[B<-print>]
117b077aed3SPierre Pronchery[B<-nameopt> I<option>]
118b077aed3SPierre Pronchery[B<-receipt_request_print>]
119b077aed3SPierre Pronchery
120b077aed3SPierre ProncheryValidation options:
121b077aed3SPierre Pronchery
122b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_v_synopsis -}
123b077aed3SPierre Pronchery
124b077aed3SPierre Pronchery=head1 DESCRIPTION
125b077aed3SPierre Pronchery
126b077aed3SPierre ProncheryThis command handles data in CMS format such as S/MIME v3.1 email messages.
127b077aed3SPierre ProncheryIt can encrypt, decrypt, sign, verify, compress, uncompress, and print messages.
128b077aed3SPierre Pronchery
129b077aed3SPierre Pronchery=head1 OPTIONS
130b077aed3SPierre Pronchery
131b077aed3SPierre ProncheryThere are a number of operation options that set the type of operation to be
132b077aed3SPierre Proncheryperformed: encrypt, decrypt, sign, verify, resign, sign_receipt, verify_receipt,
133b077aed3SPierre Proncherydigest_create, digest_verify, compress, uncompress,
134b077aed3SPierre ProncheryEncryptedData_encrypt, EncryptedData_decrypt, data_create, data_out, or cmsout.
135b077aed3SPierre ProncheryThe relevance of the other options depends on the operation type
136b077aed3SPierre Proncheryand their meaning may vary according to it.
137b077aed3SPierre Pronchery
138b077aed3SPierre Pronchery=over 4
139b077aed3SPierre Pronchery
140b077aed3SPierre Pronchery=item B<-help>
141b077aed3SPierre Pronchery
142b077aed3SPierre ProncheryPrint out a usage message.
143b077aed3SPierre Pronchery
144b077aed3SPierre Pronchery=back
145b077aed3SPierre Pronchery
146b077aed3SPierre Pronchery=head2 General options
147b077aed3SPierre Pronchery
148b077aed3SPierre Pronchery=over 4
149b077aed3SPierre Pronchery
150b077aed3SPierre Pronchery=item B<-in> I<filename>
151b077aed3SPierre Pronchery
152b077aed3SPierre ProncheryThe input message to be encrypted or signed or the message to be decrypted
153b077aed3SPierre Proncheryor verified.
154b077aed3SPierre Pronchery
155b077aed3SPierre Pronchery=item B<-out> I<filename>
156b077aed3SPierre Pronchery
157b077aed3SPierre ProncheryThe message text that has been decrypted or verified or the output MIME
158b077aed3SPierre Proncheryformat message that has been signed or verified.
159b077aed3SPierre Pronchery
160b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_config_item -}
161b077aed3SPierre Pronchery
162b077aed3SPierre Pronchery=back
163b077aed3SPierre Pronchery
164b077aed3SPierre Pronchery=head2 Operation options
165b077aed3SPierre Pronchery
166b077aed3SPierre Pronchery=over 4
167b077aed3SPierre Pronchery
168b077aed3SPierre Pronchery=item B<-encrypt>
169b077aed3SPierre Pronchery
170b077aed3SPierre ProncheryEncrypt data for the given recipient certificates. Input file is the message
171b077aed3SPierre Proncheryto be encrypted. The output file is the encrypted data in MIME format. The
172b077aed3SPierre Proncheryactual CMS type is B<EnvelopedData>.
173b077aed3SPierre Pronchery
174b077aed3SPierre ProncheryNote that no revocation check is done for the recipient cert, so if that
175b077aed3SPierre Proncherykey has been compromised, others may be able to decrypt the text.
176b077aed3SPierre Pronchery
177b077aed3SPierre Pronchery=item B<-decrypt>
178b077aed3SPierre Pronchery
179b077aed3SPierre ProncheryDecrypt data using the supplied certificate and private key. Expects
180b077aed3SPierre Proncheryencrypted datain MIME format for the input file. The decrypted data
181b077aed3SPierre Proncheryis written to the output file.
182b077aed3SPierre Pronchery
183b077aed3SPierre Pronchery=item B<-sign>
184b077aed3SPierre Pronchery
185b077aed3SPierre ProncherySign data using the supplied certificate and private key. Input file is
186b077aed3SPierre Proncherythe message to be signed. The signed data in MIME format is written
187b077aed3SPierre Proncheryto the output file.
188b077aed3SPierre Pronchery
189b077aed3SPierre Pronchery=item B<-verify>
190b077aed3SPierre Pronchery
191b077aed3SPierre ProncheryVerify signed data. Expects a signed data on input and outputs
192b077aed3SPierre Proncherythe signed data. Both clear text and opaque signing is supported.
193b077aed3SPierre Pronchery
194*0d0c8621SEnji CooperBy default, validation of signer certificates and their chain
195*0d0c8621SEnji Cooperis done w.r.t. the S/MIME signing (C<smimesign>) purpose.
196*0d0c8621SEnji CooperFor details see L<openssl-verification-options(1)/Certificate Extensions>.
197*0d0c8621SEnji Cooper
198b077aed3SPierre Pronchery=item B<-resign>
199b077aed3SPierre Pronchery
200b077aed3SPierre ProncheryResign a message: take an existing message and one or more new signers.
201b077aed3SPierre Pronchery
202b077aed3SPierre Pronchery=item B<-sign_receipt>
203b077aed3SPierre Pronchery
204b077aed3SPierre ProncheryGenerate and output a signed receipt for the supplied message. The input
205b077aed3SPierre Proncherymessage B<must> contain a signed receipt request. Functionality is otherwise
206b077aed3SPierre Proncherysimilar to the B<-sign> operation.
207b077aed3SPierre Pronchery
208b077aed3SPierre Pronchery=item B<-verify_receipt> I<receipt>
209b077aed3SPierre Pronchery
210b077aed3SPierre ProncheryVerify a signed receipt in filename B<receipt>. The input message B<must>
211b077aed3SPierre Proncherycontain the original receipt request. Functionality is otherwise similar
212b077aed3SPierre Proncheryto the B<-verify> operation.
213b077aed3SPierre Pronchery
214b077aed3SPierre Pronchery=item B<-digest_create>
215b077aed3SPierre Pronchery
216b077aed3SPierre ProncheryCreate a CMS B<DigestedData> type.
217b077aed3SPierre Pronchery
218b077aed3SPierre Pronchery=item B<-digest_verify>
219b077aed3SPierre Pronchery
220b077aed3SPierre ProncheryVerify a CMS B<DigestedData> type and output the content.
221b077aed3SPierre Pronchery
222b077aed3SPierre Pronchery=item B<-compress>
223b077aed3SPierre Pronchery
224b077aed3SPierre ProncheryCreate a CMS B<CompressedData> type. OpenSSL must be compiled with B<zlib>
225b077aed3SPierre Proncherysupport for this option to work, otherwise it will output an error.
226b077aed3SPierre Pronchery
227b077aed3SPierre Pronchery=item B<-uncompress>
228b077aed3SPierre Pronchery
229b077aed3SPierre ProncheryUncompress a CMS B<CompressedData> type and output the content. OpenSSL must be
230b077aed3SPierre Proncherycompiled with B<zlib> support for this option to work, otherwise it will
231b077aed3SPierre Proncheryoutput an error.
232b077aed3SPierre Pronchery
233b077aed3SPierre Pronchery=item B<-EncryptedData_encrypt>
234b077aed3SPierre Pronchery
235b077aed3SPierre ProncheryEncrypt content using supplied symmetric key and algorithm using a CMS
236b077aed3SPierre ProncheryB<EncryptedData> type and output the content.
237b077aed3SPierre Pronchery
238b077aed3SPierre Pronchery=item B<-EncryptedData_decrypt>
239b077aed3SPierre Pronchery
240b077aed3SPierre ProncheryDecrypt content using supplied symmetric key and algorithm using a CMS
241b077aed3SPierre ProncheryB<EncryptedData> type and output the content.
242b077aed3SPierre Pronchery
243b077aed3SPierre Pronchery=item B<-data_create>
244b077aed3SPierre Pronchery
245b077aed3SPierre ProncheryCreate a CMS B<Data> type.
246b077aed3SPierre Pronchery
247b077aed3SPierre Pronchery=item B<-data_out>
248b077aed3SPierre Pronchery
249b077aed3SPierre ProncheryB<Data> type and output the content.
250b077aed3SPierre Pronchery
251b077aed3SPierre Pronchery=item B<-cmsout>
252b077aed3SPierre Pronchery
253b077aed3SPierre ProncheryTakes an input message and writes out a PEM encoded CMS structure.
254b077aed3SPierre Pronchery
255b077aed3SPierre Pronchery=back
256b077aed3SPierre Pronchery
257b077aed3SPierre Pronchery=head2 File format options
258b077aed3SPierre Pronchery
259b077aed3SPierre Pronchery=over 4
260b077aed3SPierre Pronchery
261b077aed3SPierre Pronchery=item B<-inform> B<DER>|B<PEM>|B<SMIME>
262b077aed3SPierre Pronchery
263b077aed3SPierre ProncheryThe input format of the CMS structure (if one is being read);
264b077aed3SPierre Proncherythe default is B<SMIME>.
265b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
266b077aed3SPierre Pronchery
267b077aed3SPierre Pronchery=item B<-outform> B<DER>|B<PEM>|B<SMIME>
268b077aed3SPierre Pronchery
269b077aed3SPierre ProncheryThe output format of the CMS structure (if one is being written);
270b077aed3SPierre Proncherythe default is B<SMIME>.
271b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
272b077aed3SPierre Pronchery
273b077aed3SPierre Pronchery=item B<-rctform> B<DER>|B<PEM>|B<SMIME>
274b077aed3SPierre Pronchery
275b077aed3SPierre ProncheryThe signed receipt format for use with the B<-receipt_verify>; the default
276b077aed3SPierre Proncheryis B<SMIME>.
277b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
278b077aed3SPierre Pronchery
279b077aed3SPierre Pronchery=item B<-stream>, B<-indef>
280b077aed3SPierre Pronchery
281b077aed3SPierre ProncheryThe B<-stream> and B<-indef> options are equivalent and enable streaming I/O
282b077aed3SPierre Proncheryfor encoding operations. This permits single pass processing of data without
283b077aed3SPierre Proncherythe need to hold the entire contents in memory, potentially supporting very
284b077aed3SPierre Proncherylarge files. Streaming is automatically set for S/MIME signing with detached
285b077aed3SPierre Proncherydata if the output format is B<SMIME> it is currently off by default for all
286b077aed3SPierre Proncheryother operations.
287b077aed3SPierre Pronchery
288b077aed3SPierre Pronchery=item B<-noindef>
289b077aed3SPierre Pronchery
290b077aed3SPierre ProncheryDisable streaming I/O where it would produce and indefinite length constructed
291b077aed3SPierre Proncheryencoding. This option currently has no effect. In future streaming will be
292b077aed3SPierre Proncheryenabled by default on all relevant operations and this option will disable it.
293b077aed3SPierre Pronchery
294b077aed3SPierre Pronchery=item B<-binary>
295b077aed3SPierre Pronchery
296b077aed3SPierre ProncheryNormally the input message is converted to "canonical" format which is
297b077aed3SPierre Proncheryeffectively using CR and LF as end of line: as required by the S/MIME
298b077aed3SPierre Proncheryspecification. When this option is present no translation occurs. This
299b077aed3SPierre Proncheryis useful when handling binary data which may not be in MIME format.
300b077aed3SPierre Pronchery
301b077aed3SPierre Pronchery=item B<-crlfeol>
302b077aed3SPierre Pronchery
303b077aed3SPierre ProncheryNormally the output file uses a single B<LF> as end of line. When this
304b077aed3SPierre Proncheryoption is present B<CRLF> is used instead.
305b077aed3SPierre Pronchery
306b077aed3SPierre Pronchery=item B<-asciicrlf>
307b077aed3SPierre Pronchery
308b077aed3SPierre ProncheryWhen signing use ASCII CRLF format canonicalisation. This strips trailing
309b077aed3SPierre Proncherywhitespace from all lines, deletes trailing blank lines at EOF and sets
310b077aed3SPierre Proncherythe encapsulated content type. This option is normally used with detached
311b077aed3SPierre Proncherycontent and an output signature format of DER. This option is not normally
312b077aed3SPierre Proncheryneeded when verifying as it is enabled automatically if the encapsulated
313b077aed3SPierre Proncherycontent format is detected.
314b077aed3SPierre Pronchery
315b077aed3SPierre Pronchery=back
316b077aed3SPierre Pronchery
317b077aed3SPierre Pronchery=head2 Keys and password options
318b077aed3SPierre Pronchery
319b077aed3SPierre Pronchery=over 4
320b077aed3SPierre Pronchery
321b077aed3SPierre Pronchery=item B<-pwri_password> I<password>
322b077aed3SPierre Pronchery
323b077aed3SPierre ProncherySpecify password for recipient.
324b077aed3SPierre Pronchery
325b077aed3SPierre Pronchery=item B<-secretkey> I<key>
326b077aed3SPierre Pronchery
327b077aed3SPierre ProncherySpecify symmetric key to use. The key must be supplied in hex format and be
328b077aed3SPierre Proncheryconsistent with the algorithm used. Supported by the B<-EncryptedData_encrypt>
329b077aed3SPierre ProncheryB<-EncryptedData_decrypt>, B<-encrypt> and B<-decrypt> options. When used
330b077aed3SPierre Proncherywith B<-encrypt> or B<-decrypt> the supplied key is used to wrap or unwrap the
331b077aed3SPierre Proncherycontent encryption key using an AES key in the B<KEKRecipientInfo> type.
332b077aed3SPierre Pronchery
333b077aed3SPierre Pronchery=item B<-secretkeyid> I<id>
334b077aed3SPierre Pronchery
335b077aed3SPierre ProncheryThe key identifier for the supplied symmetric key for B<KEKRecipientInfo> type.
336b077aed3SPierre ProncheryThis option B<must> be present if the B<-secretkey> option is used with
337b077aed3SPierre ProncheryB<-encrypt>. With B<-decrypt> operations the I<id> is used to locate the
338b077aed3SPierre Proncheryrelevant key if it is not supplied then an attempt is used to decrypt any
339b077aed3SPierre ProncheryB<KEKRecipientInfo> structures.
340b077aed3SPierre Pronchery
341b077aed3SPierre Pronchery=item B<-inkey> I<filename>|I<uri>
342b077aed3SPierre Pronchery
343b077aed3SPierre ProncheryThe private key to use when signing or decrypting. This must match the
344b077aed3SPierre Proncherycorresponding certificate. If this option is not specified then the
345b077aed3SPierre Proncheryprivate key must be included in the certificate file specified with
346b077aed3SPierre Proncherythe B<-recip> or B<-signer> file. When signing this option can be used
347b077aed3SPierre Proncherymultiple times to specify successive keys.
348b077aed3SPierre Pronchery
349b077aed3SPierre Pronchery=item B<-passin> I<arg>
350b077aed3SPierre Pronchery
351b077aed3SPierre ProncheryThe private key password source. For more information about the format of B<arg>
352b077aed3SPierre Proncherysee L<openssl-passphrase-options(1)>.
353b077aed3SPierre Pronchery
354b077aed3SPierre Pronchery=item B<-keyopt> I<name>:I<parameter>
355b077aed3SPierre Pronchery
356b077aed3SPierre ProncheryFor signing and encryption this option can be used multiple times to
357b077aed3SPierre Proncheryset customised parameters for the preceding key or certificate. It can
358b077aed3SPierre Proncherycurrently be used to set RSA-PSS for signing, RSA-OAEP for encryption
359b077aed3SPierre Proncheryor to modify default parameters for ECDH.
360b077aed3SPierre Pronchery
361b077aed3SPierre Pronchery=item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
362b077aed3SPierre Pronchery
363b077aed3SPierre ProncheryThe format of the private key file; unspecified by default.
364b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details.
365b077aed3SPierre Pronchery
366b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_engine_item -}
367b077aed3SPierre Pronchery
368b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_provider_item -}
369b077aed3SPierre Pronchery
370b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_r_item -}
371b077aed3SPierre Pronchery
372b077aed3SPierre Pronchery=back
373b077aed3SPierre Pronchery
374b077aed3SPierre Pronchery=head2 Encryption and decryption options
375b077aed3SPierre Pronchery
376b077aed3SPierre Pronchery=over 4
377b077aed3SPierre Pronchery
378b077aed3SPierre Pronchery=item B<-originator> I<file>
379b077aed3SPierre Pronchery
380b077aed3SPierre ProncheryA certificate of the originator of the encrypted message. Necessary for
381*0d0c8621SEnji Cooperdecryption when Key Agreement is in use for a shared key. Currently, not
382*0d0c8621SEnji Cooperallowed for encryption.
383b077aed3SPierre Pronchery
384b077aed3SPierre Pronchery=item B<-recip> I<file>
385b077aed3SPierre Pronchery
386b077aed3SPierre ProncheryWhen decrypting a message this specifies the certificate of the recipient.
387b077aed3SPierre ProncheryThe certificate must match one of the recipients of the message.
388b077aed3SPierre Pronchery
389b077aed3SPierre ProncheryWhen encrypting a message this option may be used multiple times to specify
390b077aed3SPierre Proncheryeach recipient. This form B<must> be used if customised parameters are
391b077aed3SPierre Proncheryrequired (for example to specify RSA-OAEP).
392b077aed3SPierre Pronchery
393b077aed3SPierre ProncheryOnly certificates carrying RSA, Diffie-Hellman or EC keys are supported by this
394b077aed3SPierre Proncheryoption.
395b077aed3SPierre Pronchery
396b077aed3SPierre Pronchery=item I<recipient-cert> ...
397b077aed3SPierre Pronchery
398b077aed3SPierre ProncheryThis is an alternative to using the B<-recip> option when encrypting a message.
3996f1af0d7SPierre ProncheryOne or more certificate filenames may be given.
400b077aed3SPierre Pronchery
401b077aed3SPierre Pronchery=item B<-I<cipher>>
402b077aed3SPierre Pronchery
403b077aed3SPierre ProncheryThe encryption algorithm to use. For example triple DES (168 bits) - B<-des3>
404b077aed3SPierre Proncheryor 256 bit AES - B<-aes256>. Any standard algorithm name (as used by the
405b077aed3SPierre ProncheryEVP_get_cipherbyname() function) can also be used preceded by a dash, for
406b077aed3SPierre Proncheryexample B<-aes-128-cbc>. See L<openssl-enc(1)> for a list of ciphers
407b077aed3SPierre Proncherysupported by your version of OpenSSL.
408b077aed3SPierre Pronchery
409b077aed3SPierre ProncheryCurrently the AES variants with GCM mode are the only supported AEAD
410b077aed3SPierre Proncheryalgorithms.
411b077aed3SPierre Pronchery
412b077aed3SPierre ProncheryIf not specified triple DES is used. Only used with B<-encrypt> and
413b077aed3SPierre ProncheryB<-EncryptedData_create> commands.
414b077aed3SPierre Pronchery
415b077aed3SPierre Pronchery=item B<-wrap> I<cipher>
416b077aed3SPierre Pronchery
417b077aed3SPierre ProncheryCipher algorithm to use for key wrap when encrypting the message using Key
418b077aed3SPierre ProncheryAgreement for key transport. The algorithm specified should be suitable for key
419b077aed3SPierre Proncherywrap.
420b077aed3SPierre Pronchery
421b077aed3SPierre Pronchery=item B<-aes128-wrap>, B<-aes192-wrap>, B<-aes256-wrap>, B<-des3-wrap>
422b077aed3SPierre Pronchery
423b077aed3SPierre ProncheryUse AES128, AES192, AES256, or 3DES-EDE, respectively, to wrap key.
424b077aed3SPierre ProncheryDepending on the OpenSSL build options used, B<-des3-wrap> may not be supported.
425b077aed3SPierre Pronchery
426b077aed3SPierre Pronchery=item B<-debug_decrypt>
427b077aed3SPierre Pronchery
428b077aed3SPierre ProncheryThis option sets the B<CMS_DEBUG_DECRYPT> flag. This option should be used
429b077aed3SPierre Proncherywith caution: see the notes section below.
430b077aed3SPierre Pronchery
431b077aed3SPierre Pronchery=back
432b077aed3SPierre Pronchery
433b077aed3SPierre Pronchery=head2 Signing options
434b077aed3SPierre Pronchery
435b077aed3SPierre Pronchery=over 4
436b077aed3SPierre Pronchery
437b077aed3SPierre Pronchery=item B<-md> I<digest>
438b077aed3SPierre Pronchery
439b077aed3SPierre ProncheryDigest algorithm to use when signing or resigning. If not present then the
440b077aed3SPierre Proncherydefault digest algorithm for the signing key will be used (usually SHA1).
441b077aed3SPierre Pronchery
442b077aed3SPierre Pronchery=item B<-signer> I<file>
443b077aed3SPierre Pronchery
444b077aed3SPierre ProncheryA signing certificate.  When signing or resigning a message, this option can be
445b077aed3SPierre Proncheryused multiple times if more than one signer is required.
446b077aed3SPierre Pronchery
447b077aed3SPierre Pronchery=item B<-certfile> I<file>
448b077aed3SPierre Pronchery
449b077aed3SPierre ProncheryAllows additional certificates to be specified. When signing these will
450b077aed3SPierre Proncherybe included with the message. When verifying these will be searched for
451b077aed3SPierre Proncherythe signers certificates.
452b077aed3SPierre ProncheryThe input can be in PEM, DER, or PKCS#12 format.
453b077aed3SPierre Pronchery
454b077aed3SPierre Pronchery=item B<-cades>
455b077aed3SPierre Pronchery
456b077aed3SPierre ProncheryWhen used with B<-sign>,
457b077aed3SPierre Proncheryadd an ESS signingCertificate or ESS signingCertificateV2 signed-attribute
458b077aed3SPierre Proncheryto the SignerInfo, in order to make the signature comply with the requirements
459b077aed3SPierre Proncheryfor a CAdES Basic Electronic Signature (CAdES-BES).
460b077aed3SPierre Pronchery
461b077aed3SPierre Pronchery=item B<-nodetach>
462b077aed3SPierre Pronchery
463b077aed3SPierre ProncheryWhen signing a message use opaque signing: this form is more resistant
464b077aed3SPierre Proncheryto translation by mail relays but it cannot be read by mail agents that
465b077aed3SPierre Proncherydo not support S/MIME.  Without this option cleartext signing with
466b077aed3SPierre Proncherythe MIME type multipart/signed is used.
467b077aed3SPierre Pronchery
468b077aed3SPierre Pronchery=item B<-nocerts>
469b077aed3SPierre Pronchery
470b077aed3SPierre ProncheryWhen signing a message the signer's certificate is normally included
471b077aed3SPierre Proncherywith this option it is excluded. This will reduce the size of the
472b077aed3SPierre Proncherysigned message but the verifier must have a copy of the signers certificate
473b077aed3SPierre Proncheryavailable locally (passed using the B<-certfile> option for example).
474b077aed3SPierre Pronchery
475b077aed3SPierre Pronchery=item B<-noattr>
476b077aed3SPierre Pronchery
477b077aed3SPierre ProncheryNormally when a message is signed a set of attributes are included which
478b077aed3SPierre Proncheryinclude the signing time and supported symmetric algorithms. With this
479b077aed3SPierre Proncheryoption they are not included.
480b077aed3SPierre Pronchery
481b077aed3SPierre Pronchery=item B<-nosmimecap>
482b077aed3SPierre Pronchery
483b077aed3SPierre ProncheryExclude the list of supported algorithms from signed attributes, other options
484b077aed3SPierre Proncherysuch as signing time and content type are still included.
485b077aed3SPierre Pronchery
486b077aed3SPierre Pronchery=item B<-receipt_request_all>, B<-receipt_request_first>
487b077aed3SPierre Pronchery
488b077aed3SPierre ProncheryFor B<-sign> option include a signed receipt request. Indicate requests should
489b077aed3SPierre Proncherybe provided by all recipient or first tier recipients (those mailed directly
490b077aed3SPierre Proncheryand not from a mailing list). Ignored it B<-receipt_request_from> is included.
491b077aed3SPierre Pronchery
492b077aed3SPierre Pronchery=item B<-receipt_request_from> I<emailaddress>
493b077aed3SPierre Pronchery
494b077aed3SPierre ProncheryFor B<-sign> option include a signed receipt request. Add an explicit email
495b077aed3SPierre Proncheryaddress where receipts should be supplied.
496b077aed3SPierre Pronchery
497b077aed3SPierre Pronchery=item B<-receipt_request_to> I<emailaddress>
498b077aed3SPierre Pronchery
499b077aed3SPierre ProncheryAdd an explicit email address where signed receipts should be sent to. This
500b077aed3SPierre Proncheryoption B<must> but supplied if a signed receipt is requested.
501b077aed3SPierre Pronchery
502b077aed3SPierre Pronchery=back
503b077aed3SPierre Pronchery
504b077aed3SPierre Pronchery=head2 Verification options
505b077aed3SPierre Pronchery
506b077aed3SPierre Pronchery=over 4
507b077aed3SPierre Pronchery
508b077aed3SPierre Pronchery=item B<-signer> I<file>
509b077aed3SPierre Pronchery
510b077aed3SPierre ProncheryIf a message has been verified successfully then the signers certificate(s)
511b077aed3SPierre Proncherywill be written to this file if the verification was successful.
512b077aed3SPierre Pronchery
513b077aed3SPierre Pronchery=item B<-content> I<filename>
514b077aed3SPierre Pronchery
515b077aed3SPierre ProncheryThis specifies a file containing the detached content for operations taking
516b077aed3SPierre ProncheryS/MIME input, such as the B<-verify> command. This is only usable if the CMS
517b077aed3SPierre Proncherystructure is using the detached signature form where the content is
518b077aed3SPierre Proncherynot included. This option will override any content if the input format
519b077aed3SPierre Proncheryis S/MIME and it uses the multipart/signed MIME content type.
520b077aed3SPierre Pronchery
521b077aed3SPierre Pronchery=item B<-no_content_verify>
522b077aed3SPierre Pronchery
523b077aed3SPierre ProncheryDo not verify signed content signatures.
524b077aed3SPierre Pronchery
525b077aed3SPierre Pronchery=item B<-no_attr_verify>
526b077aed3SPierre Pronchery
527b077aed3SPierre ProncheryDo not verify signed attribute signatures.
528b077aed3SPierre Pronchery
529b077aed3SPierre Pronchery=item B<-nosigs>
530b077aed3SPierre Pronchery
531b077aed3SPierre ProncheryDon't verify message signature.
532b077aed3SPierre Pronchery
533b077aed3SPierre Pronchery=item B<-noverify>
534b077aed3SPierre Pronchery
535b077aed3SPierre ProncheryDo not verify the signers certificate of a signed message.
536b077aed3SPierre Pronchery
537b077aed3SPierre Pronchery=item B<-nointern>
538b077aed3SPierre Pronchery
539b077aed3SPierre ProncheryWhen verifying a message normally certificates (if any) included in
540b077aed3SPierre Proncherythe message are searched for the signing certificate. With this option
541b077aed3SPierre Proncheryonly the certificates specified in the B<-certfile> option are used.
542b077aed3SPierre ProncheryThe supplied certificates can still be used as untrusted CAs however.
543b077aed3SPierre Pronchery
544b077aed3SPierre Pronchery=item B<-cades>
545b077aed3SPierre Pronchery
546b077aed3SPierre ProncheryWhen used with B<-verify>, require and check signer certificate digest.
547b077aed3SPierre ProncherySee the NOTES section for more details.
548b077aed3SPierre Pronchery
549b077aed3SPierre Pronchery=item B<-verify_retcode>
550b077aed3SPierre Pronchery
551b077aed3SPierre ProncheryExit nonzero on verification failure.
552b077aed3SPierre Pronchery
553b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_trust_item -}
554b077aed3SPierre Pronchery
555b077aed3SPierre Pronchery=back
556b077aed3SPierre Pronchery
557b077aed3SPierre Pronchery=head2 Output options
558b077aed3SPierre Pronchery
559b077aed3SPierre Pronchery=over 4
560b077aed3SPierre Pronchery
561b077aed3SPierre Pronchery=item B<-keyid>
562b077aed3SPierre Pronchery
563b077aed3SPierre ProncheryUse subject key identifier to identify certificates instead of issuer name and
564b077aed3SPierre Proncheryserial number. The supplied certificate B<must> include a subject key
565b077aed3SPierre Proncheryidentifier extension. Supported by B<-sign> and B<-encrypt> options.
566b077aed3SPierre Pronchery
567b077aed3SPierre Pronchery=item B<-econtent_type> I<type>
568b077aed3SPierre Pronchery
569b077aed3SPierre ProncherySet the encapsulated content type to I<type> if not supplied the B<Data> type
570b077aed3SPierre Proncheryis used. The I<type> argument can be any valid OID name in either text or
571b077aed3SPierre Proncherynumerical format.
572b077aed3SPierre Pronchery
573b077aed3SPierre Pronchery=item B<-text>
574b077aed3SPierre Pronchery
575b077aed3SPierre ProncheryThis option adds plain text (text/plain) MIME headers to the supplied
576b077aed3SPierre Proncherymessage if encrypting or signing. If decrypting or verifying it strips
577b077aed3SPierre Proncheryoff text headers: if the decrypted or verified message is not of MIME
578b077aed3SPierre Proncherytype text/plain then an error occurs.
579b077aed3SPierre Pronchery
580b077aed3SPierre Pronchery=item B<-certsout> I<file>
581b077aed3SPierre Pronchery
582b077aed3SPierre ProncheryAny certificates contained in the input message are written to I<file>.
583b077aed3SPierre Pronchery
584b077aed3SPierre Pronchery=item B<-to>, B<-from>, B<-subject>
585b077aed3SPierre Pronchery
586b077aed3SPierre ProncheryThe relevant email headers. These are included outside the signed
587b077aed3SPierre Proncheryportion of a message so they may be included manually. If signing
588b077aed3SPierre Proncherythen many S/MIME mail clients check the signers certificate's email
589b077aed3SPierre Proncheryaddress matches that specified in the From: address.
590b077aed3SPierre Pronchery
591b077aed3SPierre Pronchery=back
592b077aed3SPierre Pronchery
593b077aed3SPierre Pronchery=head2 Printing options
594b077aed3SPierre Pronchery
595b077aed3SPierre Pronchery=over 4
596b077aed3SPierre Pronchery
597b077aed3SPierre Pronchery=item B<-noout>
598b077aed3SPierre Pronchery
599b077aed3SPierre ProncheryFor the B<-cmsout> operation do not output the parsed CMS structure.
600b077aed3SPierre ProncheryThis is useful if the syntax of the CMS structure is being checked.
601b077aed3SPierre Pronchery
602b077aed3SPierre Pronchery=item B<-print>
603b077aed3SPierre Pronchery
604b077aed3SPierre ProncheryFor the B<-cmsout> operation print out all fields of the CMS structure.
605b077aed3SPierre ProncheryThis implies B<-noout>.
606b077aed3SPierre ProncheryThis is mainly useful for testing purposes.
607b077aed3SPierre Pronchery
608b077aed3SPierre Pronchery=item B<-nameopt> I<option>
609b077aed3SPierre Pronchery
610b077aed3SPierre ProncheryFor the B<-cmsout> operation when B<-print> option is in use, specifies
611b077aed3SPierre Proncheryprinting options for string fields. For most cases B<utf8> is reasonable value.
612b077aed3SPierre ProncherySee L<openssl-namedisplay-options(1)> for details.
613b077aed3SPierre Pronchery
614b077aed3SPierre Pronchery=item B<-receipt_request_print>
615b077aed3SPierre Pronchery
616b077aed3SPierre ProncheryFor the B<-verify> operation print out the contents of any signed receipt
617b077aed3SPierre Proncheryrequests.
618b077aed3SPierre Pronchery
619b077aed3SPierre Pronchery=back
620b077aed3SPierre Pronchery
621b077aed3SPierre Pronchery=head2 Validation options
622b077aed3SPierre Pronchery
623b077aed3SPierre Pronchery=over 4
624b077aed3SPierre Pronchery
625b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_v_item -}
626b077aed3SPierre Pronchery
627b077aed3SPierre ProncheryAny validation errors cause the command to exit.
628b077aed3SPierre Pronchery
629b077aed3SPierre Pronchery=back
630b077aed3SPierre Pronchery
631b077aed3SPierre Pronchery=head1 NOTES
632b077aed3SPierre Pronchery
633b077aed3SPierre ProncheryThe MIME message must be sent without any blank lines between the
634b077aed3SPierre Proncheryheaders and the output. Some mail programs will automatically add
635b077aed3SPierre Proncherya blank line. Piping the mail directly to sendmail is one way to
636b077aed3SPierre Proncheryachieve the correct format.
637b077aed3SPierre Pronchery
638b077aed3SPierre ProncheryThe supplied message to be signed or encrypted must include the
639b077aed3SPierre Proncherynecessary MIME headers or many S/MIME clients won't display it
640b077aed3SPierre Proncheryproperly (if at all). You can use the B<-text> option to automatically
641b077aed3SPierre Proncheryadd plain text headers.
642b077aed3SPierre Pronchery
643b077aed3SPierre ProncheryA "signed and encrypted" message is one where a signed message is
644b077aed3SPierre Proncherythen encrypted. This can be produced by encrypting an already signed
645b077aed3SPierre Proncherymessage: see the examples section.
646b077aed3SPierre Pronchery
647b077aed3SPierre ProncheryThis version of the program only allows one signer per message but it
648b077aed3SPierre Proncherywill verify multiple signers on received messages. Some S/MIME clients
649b077aed3SPierre Proncherychoke if a message contains multiple signers. It is possible to sign
650b077aed3SPierre Proncherymessages "in parallel" by signing an already signed message.
651b077aed3SPierre Pronchery
652b077aed3SPierre ProncheryThe options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME
653b077aed3SPierre Proncheryclients. Strictly speaking these process CMS enveloped data: CMS
654b077aed3SPierre Proncheryencrypted data is used for other purposes.
655b077aed3SPierre Pronchery
656b077aed3SPierre ProncheryThe B<-resign> option uses an existing message digest when adding a new
657b077aed3SPierre Proncherysigner. This means that attributes must be present in at least one existing
658b077aed3SPierre Proncherysigner using the same message digest or this operation will fail.
659b077aed3SPierre Pronchery
660b077aed3SPierre ProncheryThe B<-stream> and B<-indef> options enable streaming I/O support.
661b077aed3SPierre ProncheryAs a result the encoding is BER using indefinite length constructed encoding
662b077aed3SPierre Proncheryand no longer DER. Streaming is supported for the B<-encrypt> operation and the
663b077aed3SPierre ProncheryB<-sign> operation if the content is not detached.
664b077aed3SPierre Pronchery
665b077aed3SPierre ProncheryStreaming is always used for the B<-sign> operation with detached data but
666b077aed3SPierre Proncherysince the content is no longer part of the CMS structure the encoding
667b077aed3SPierre Proncheryremains DER.
668b077aed3SPierre Pronchery
669b077aed3SPierre ProncheryIf the B<-decrypt> option is used without a recipient certificate then an
670b077aed3SPierre Proncheryattempt is made to locate the recipient by trying each potential recipient
671b077aed3SPierre Proncheryin turn using the supplied private key. To thwart the MMA attack
672b077aed3SPierre Pronchery(Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) all recipients are
673b077aed3SPierre Proncherytried whether they succeed or not and if no recipients match the message
674b077aed3SPierre Proncheryis "decrypted" using a random key which will typically output garbage.
675b077aed3SPierre ProncheryThe B<-debug_decrypt> option can be used to disable the MMA attack protection
676b077aed3SPierre Proncheryand return an error if no recipient can be found: this option should be used
677b077aed3SPierre Proncherywith caution. For a fuller description see L<CMS_decrypt(3)>).
678b077aed3SPierre Pronchery
679b077aed3SPierre Pronchery=head1 CADES BASIC ELECTRONIC SIGNATURE (CADES-BES)
680b077aed3SPierre Pronchery
681b077aed3SPierre ProncheryA CAdES Basic Electronic Signature (CAdES-BES),
682b077aed3SPierre Proncheryas defined in the European Standard ETSI EN 319 122-1 V1.1.1, contains:
683b077aed3SPierre Pronchery
684b077aed3SPierre Pronchery=over 4
685b077aed3SPierre Pronchery
686b077aed3SPierre Pronchery=item *
687b077aed3SPierre Pronchery
688b077aed3SPierre ProncheryThe signed user data as defined in CMS (RFC 3852);
689b077aed3SPierre Pronchery
690b077aed3SPierre Pronchery=item *
691b077aed3SPierre Pronchery
692b077aed3SPierre ProncheryContent-type of the EncapsulatedContentInfo value being signed;
693b077aed3SPierre Pronchery
694b077aed3SPierre Pronchery=item *
695b077aed3SPierre Pronchery
696b077aed3SPierre ProncheryMessage-digest of the eContent OCTET STRING within encapContentInfo being signed;
697b077aed3SPierre Pronchery
698b077aed3SPierre Pronchery=item *
699b077aed3SPierre Pronchery
700b077aed3SPierre ProncheryAn ESS signingCertificate or ESS signingCertificateV2 attribute,
701b077aed3SPierre Proncheryas defined in Enhanced Security Services (ESS), RFC 2634 and RFC 5035.
702b077aed3SPierre ProncheryAn ESS signingCertificate attribute only allows for SHA-1 as digest algorithm.
703b077aed3SPierre ProncheryAn ESS signingCertificateV2 attribute allows for any digest algorithm.
704b077aed3SPierre Pronchery
705b077aed3SPierre Pronchery=item *
706b077aed3SPierre Pronchery
707b077aed3SPierre ProncheryThe digital signature value computed on the user data and, when present, on the signed attributes.
708b077aed3SPierre Pronchery
709b077aed3SPierre ProncheryNOTE that the B<-cades> option applies to the B<-sign> or B<-verify> operations.
710b077aed3SPierre ProncheryWith this option, the B<-verify> operation also requires that the
711b077aed3SPierre ProncherysigningCertificate attribute is present and checks that the given identifiers
712b077aed3SPierre Proncherymatch the verification trust chain built during the verification process.
713b077aed3SPierre Pronchery
714b077aed3SPierre Pronchery=back
715b077aed3SPierre Pronchery
716b077aed3SPierre Pronchery=head1 EXIT CODES
717b077aed3SPierre Pronchery
718b077aed3SPierre Pronchery=over 4
719b077aed3SPierre Pronchery
720b077aed3SPierre Pronchery=item Z<>0
721b077aed3SPierre Pronchery
722b077aed3SPierre ProncheryThe operation was completely successfully.
723b077aed3SPierre Pronchery
724b077aed3SPierre Pronchery=item Z<>1
725b077aed3SPierre Pronchery
726b077aed3SPierre ProncheryAn error occurred parsing the command options.
727b077aed3SPierre Pronchery
728b077aed3SPierre Pronchery=item Z<>2
729b077aed3SPierre Pronchery
730b077aed3SPierre ProncheryOne of the input files could not be read.
731b077aed3SPierre Pronchery
732b077aed3SPierre Pronchery=item Z<>3
733b077aed3SPierre Pronchery
734b077aed3SPierre ProncheryAn error occurred creating the CMS file or when reading the MIME
735b077aed3SPierre Proncherymessage.
736b077aed3SPierre Pronchery
737b077aed3SPierre Pronchery=item Z<>4
738b077aed3SPierre Pronchery
739b077aed3SPierre ProncheryAn error occurred decrypting or verifying the message.
740b077aed3SPierre Pronchery
741b077aed3SPierre Pronchery=item Z<>5
742b077aed3SPierre Pronchery
743b077aed3SPierre ProncheryThe message was verified correctly but an error occurred writing out
744b077aed3SPierre Proncherythe signers certificates.
745b077aed3SPierre Pronchery
746b077aed3SPierre Pronchery=back
747b077aed3SPierre Pronchery
748b077aed3SPierre Pronchery=head1 COMPATIBILITY WITH PKCS#7 FORMAT
749b077aed3SPierre Pronchery
750b077aed3SPierre ProncheryL<openssl-smime(1)> can only process the older B<PKCS#7> format.
751b077aed3SPierre ProncheryB<openssl cms> supports Cryptographic Message Syntax format.
752b077aed3SPierre ProncheryUse of some features will result in messages which cannot be processed by
753b077aed3SPierre Proncheryapplications which only support the older format. These are detailed below.
754b077aed3SPierre Pronchery
755b077aed3SPierre ProncheryThe use of the B<-keyid> option with B<-sign> or B<-encrypt>.
756b077aed3SPierre Pronchery
757b077aed3SPierre ProncheryThe B<-outform> I<PEM> option uses different headers.
758b077aed3SPierre Pronchery
759b077aed3SPierre ProncheryThe B<-compress> option.
760b077aed3SPierre Pronchery
761b077aed3SPierre ProncheryThe B<-secretkey> option when used with B<-encrypt>.
762b077aed3SPierre Pronchery
763b077aed3SPierre ProncheryThe use of PSS with B<-sign>.
764b077aed3SPierre Pronchery
765b077aed3SPierre ProncheryThe use of OAEP or non-RSA keys with B<-encrypt>.
766b077aed3SPierre Pronchery
767b077aed3SPierre ProncheryAdditionally the B<-EncryptedData_create> and B<-data_create> type cannot
768b077aed3SPierre Proncherybe processed by the older L<openssl-smime(1)> command.
769b077aed3SPierre Pronchery
770b077aed3SPierre Pronchery=head1 EXAMPLES
771b077aed3SPierre Pronchery
772b077aed3SPierre ProncheryCreate a cleartext signed message:
773b077aed3SPierre Pronchery
774b077aed3SPierre Pronchery openssl cms -sign -in message.txt -text -out mail.msg \
775b077aed3SPierre Pronchery        -signer mycert.pem
776b077aed3SPierre Pronchery
777b077aed3SPierre ProncheryCreate an opaque signed message
778b077aed3SPierre Pronchery
779b077aed3SPierre Pronchery openssl cms -sign -in message.txt -text -out mail.msg -nodetach \
780b077aed3SPierre Pronchery        -signer mycert.pem
781b077aed3SPierre Pronchery
782b077aed3SPierre ProncheryCreate a signed message, include some additional certificates and
783b077aed3SPierre Proncheryread the private key from another file:
784b077aed3SPierre Pronchery
785b077aed3SPierre Pronchery openssl cms -sign -in in.txt -text -out mail.msg \
786b077aed3SPierre Pronchery        -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
787b077aed3SPierre Pronchery
788b077aed3SPierre ProncheryCreate a signed message with two signers, use key identifier:
789b077aed3SPierre Pronchery
790b077aed3SPierre Pronchery openssl cms -sign -in message.txt -text -out mail.msg \
791b077aed3SPierre Pronchery        -signer mycert.pem -signer othercert.pem -keyid
792b077aed3SPierre Pronchery
793b077aed3SPierre ProncherySend a signed message under Unix directly to sendmail, including headers:
794b077aed3SPierre Pronchery
795b077aed3SPierre Pronchery openssl cms -sign -in in.txt -text -signer mycert.pem \
796b077aed3SPierre Pronchery        -from steve@openssl.org -to someone@somewhere \
797b077aed3SPierre Pronchery        -subject "Signed message" | sendmail someone@somewhere
798b077aed3SPierre Pronchery
799b077aed3SPierre ProncheryVerify a message and extract the signer's certificate if successful:
800b077aed3SPierre Pronchery
801b077aed3SPierre Pronchery openssl cms -verify -in mail.msg -signer user.pem -out signedtext.txt
802b077aed3SPierre Pronchery
803b077aed3SPierre ProncherySend encrypted mail using triple DES:
804b077aed3SPierre Pronchery
805b077aed3SPierre Pronchery openssl cms -encrypt -in in.txt -from steve@openssl.org \
806b077aed3SPierre Pronchery        -to someone@somewhere -subject "Encrypted message" \
807b077aed3SPierre Pronchery        -des3 user.pem -out mail.msg
808b077aed3SPierre Pronchery
809b077aed3SPierre ProncherySign and encrypt mail:
810b077aed3SPierre Pronchery
811b077aed3SPierre Pronchery openssl cms -sign -in ml.txt -signer my.pem -text \
812b077aed3SPierre Pronchery        | openssl cms -encrypt -out mail.msg \
813b077aed3SPierre Pronchery        -from steve@openssl.org -to someone@somewhere \
814b077aed3SPierre Pronchery        -subject "Signed and Encrypted message" -des3 user.pem
815b077aed3SPierre Pronchery
816b077aed3SPierre ProncheryNote: the encryption command does not include the B<-text> option because the
817b077aed3SPierre Proncherymessage being encrypted already has MIME headers.
818b077aed3SPierre Pronchery
819b077aed3SPierre ProncheryDecrypt a message:
820b077aed3SPierre Pronchery
821b077aed3SPierre Pronchery openssl cms -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
822b077aed3SPierre Pronchery
823b077aed3SPierre ProncheryThe output from Netscape form signing is a PKCS#7 structure with the
824b077aed3SPierre Proncherydetached signature format. You can use this program to verify the
825b077aed3SPierre Proncherysignature by line wrapping the base64 encoded structure and surrounding
826b077aed3SPierre Proncheryit with:
827b077aed3SPierre Pronchery
828b077aed3SPierre Pronchery -----BEGIN PKCS7-----
829b077aed3SPierre Pronchery -----END PKCS7-----
830b077aed3SPierre Pronchery
831b077aed3SPierre Proncheryand using the command,
832b077aed3SPierre Pronchery
833b077aed3SPierre Pronchery openssl cms -verify -inform PEM -in signature.pem -content content.txt
834b077aed3SPierre Pronchery
835b077aed3SPierre Proncheryalternatively you can base64 decode the signature and use
836b077aed3SPierre Pronchery
837b077aed3SPierre Pronchery openssl cms -verify -inform DER -in signature.der -content content.txt
838b077aed3SPierre Pronchery
839b077aed3SPierre ProncheryCreate an encrypted message using 128 bit Camellia:
840b077aed3SPierre Pronchery
841b077aed3SPierre Pronchery openssl cms -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem
842b077aed3SPierre Pronchery
843b077aed3SPierre ProncheryAdd a signer to an existing message:
844b077aed3SPierre Pronchery
845b077aed3SPierre Pronchery openssl cms -resign -in mail.msg -signer newsign.pem -out mail2.msg
846b077aed3SPierre Pronchery
847b077aed3SPierre ProncherySign a message using RSA-PSS:
848b077aed3SPierre Pronchery
849b077aed3SPierre Pronchery openssl cms -sign -in message.txt -text -out mail.msg \
850b077aed3SPierre Pronchery        -signer mycert.pem -keyopt rsa_padding_mode:pss
851b077aed3SPierre Pronchery
852b077aed3SPierre ProncheryCreate an encrypted message using RSA-OAEP:
853b077aed3SPierre Pronchery
854b077aed3SPierre Pronchery openssl cms -encrypt -in plain.txt -out mail.msg \
855b077aed3SPierre Pronchery        -recip cert.pem -keyopt rsa_padding_mode:oaep
856b077aed3SPierre Pronchery
857b077aed3SPierre ProncheryUse SHA256 KDF with an ECDH certificate:
858b077aed3SPierre Pronchery
859b077aed3SPierre Pronchery openssl cms -encrypt -in plain.txt -out mail.msg \
860b077aed3SPierre Pronchery        -recip ecdhcert.pem -keyopt ecdh_kdf_md:sha256
861b077aed3SPierre Pronchery
862b077aed3SPierre ProncheryPrint CMS signed binary data in human-readable form:
863b077aed3SPierre Pronchery
864b077aed3SPierre Proncheryopenssl cms -in signed.cms -binary -inform DER -cmsout -print
865b077aed3SPierre Pronchery
866b077aed3SPierre Pronchery=head1 BUGS
867b077aed3SPierre Pronchery
868b077aed3SPierre ProncheryThe MIME parser isn't very clever: it seems to handle most messages that I've
869b077aed3SPierre Proncherythrown at it but it may choke on others.
870b077aed3SPierre Pronchery
871b077aed3SPierre ProncheryThe code currently will only write out the signer's certificate to a file: if
872b077aed3SPierre Proncherythe signer has a separate encryption certificate this must be manually
873b077aed3SPierre Proncheryextracted. There should be some heuristic that determines the correct
874b077aed3SPierre Proncheryencryption certificate.
875b077aed3SPierre Pronchery
876b077aed3SPierre ProncheryIdeally a database should be maintained of a certificates for each email
877b077aed3SPierre Proncheryaddress.
878b077aed3SPierre Pronchery
879b077aed3SPierre ProncheryThe code doesn't currently take note of the permitted symmetric encryption
880b077aed3SPierre Proncheryalgorithms as supplied in the SMIMECapabilities signed attribute. this means the
881b077aed3SPierre Proncheryuser has to manually include the correct encryption algorithm. It should store
882b077aed3SPierre Proncherythe list of permitted ciphers in a database and only use those.
883b077aed3SPierre Pronchery
884b077aed3SPierre ProncheryNo revocation checking is done on the signer's certificate.
885b077aed3SPierre Pronchery
886b077aed3SPierre Pronchery=head1 SEE ALSO
887b077aed3SPierre Pronchery
888b077aed3SPierre ProncheryL<ossl_store-file(7)>
889b077aed3SPierre Pronchery
890b077aed3SPierre Pronchery=head1 HISTORY
891b077aed3SPierre Pronchery
892b077aed3SPierre ProncheryThe use of multiple B<-signer> options and the B<-resign> command were first
893b077aed3SPierre Proncheryadded in OpenSSL 1.0.0.
894b077aed3SPierre Pronchery
895b077aed3SPierre ProncheryThe B<-keyopt> option was added in OpenSSL 1.0.2.
896b077aed3SPierre Pronchery
897b077aed3SPierre ProncherySupport for RSA-OAEP and RSA-PSS was added in OpenSSL 1.0.2.
898b077aed3SPierre Pronchery
899b077aed3SPierre ProncheryThe use of non-RSA keys with B<-encrypt> and B<-decrypt>
900b077aed3SPierre Proncherywas added in OpenSSL 1.0.2.
901b077aed3SPierre Pronchery
902b077aed3SPierre ProncheryThe -no_alt_chains option was added in OpenSSL 1.0.2b.
903b077aed3SPierre Pronchery
904b077aed3SPierre ProncheryThe B<-nameopt> option was added in OpenSSL 3.0.0.
905b077aed3SPierre Pronchery
906b077aed3SPierre ProncheryThe B<-engine> option was deprecated in OpenSSL 3.0.
907b077aed3SPierre Pronchery
908b077aed3SPierre Pronchery=head1 COPYRIGHT
909b077aed3SPierre Pronchery
910*0d0c8621SEnji CooperCopyright 2008-2025 The OpenSSL Project Authors. All Rights Reserved.
911b077aed3SPierre Pronchery
912b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
913b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
914b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
915b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
916b077aed3SPierre Pronchery
917b077aed3SPierre Pronchery=cut
918