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