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