1ebfedea0SLionel Sambuc=pod 2ebfedea0SLionel Sambuc 3ebfedea0SLionel Sambuc=head1 NAME 4ebfedea0SLionel Sambuc 5ebfedea0SLionel Sambuccms - CMS utility 6ebfedea0SLionel Sambuc 7ebfedea0SLionel Sambuc=head1 SYNOPSIS 8ebfedea0SLionel Sambuc 9ebfedea0SLionel SambucB<openssl> B<cms> 10ebfedea0SLionel Sambuc[B<-encrypt>] 11ebfedea0SLionel Sambuc[B<-decrypt>] 12ebfedea0SLionel Sambuc[B<-sign>] 13ebfedea0SLionel Sambuc[B<-verify>] 14ebfedea0SLionel Sambuc[B<-cmsout>] 15ebfedea0SLionel Sambuc[B<-resign>] 16ebfedea0SLionel Sambuc[B<-data_create>] 17ebfedea0SLionel Sambuc[B<-data_out>] 18ebfedea0SLionel Sambuc[B<-digest_create>] 19ebfedea0SLionel Sambuc[B<-digest_verify>] 20ebfedea0SLionel Sambuc[B<-compress>] 21ebfedea0SLionel Sambuc[B<-uncompress>] 22ebfedea0SLionel Sambuc[B<-EncryptedData_encrypt>] 23ebfedea0SLionel Sambuc[B<-sign_receipt>] 24ebfedea0SLionel Sambuc[B<-verify_receipt receipt>] 25ebfedea0SLionel Sambuc[B<-in filename>] 26ebfedea0SLionel Sambuc[B<-inform SMIME|PEM|DER>] 27ebfedea0SLionel Sambuc[B<-rctform SMIME|PEM|DER>] 28ebfedea0SLionel Sambuc[B<-out filename>] 29ebfedea0SLionel Sambuc[B<-outform SMIME|PEM|DER>] 30ebfedea0SLionel Sambuc[B<-stream -indef -noindef>] 31ebfedea0SLionel Sambuc[B<-noindef>] 32ebfedea0SLionel Sambuc[B<-content filename>] 33ebfedea0SLionel Sambuc[B<-text>] 34ebfedea0SLionel Sambuc[B<-noout>] 35ebfedea0SLionel Sambuc[B<-print>] 36ebfedea0SLionel Sambuc[B<-CAfile file>] 37ebfedea0SLionel Sambuc[B<-CApath dir>] 38*0a6a1f1dSLionel Sambuc[B<-no_alt_chains>] 39ebfedea0SLionel Sambuc[B<-md digest>] 40ebfedea0SLionel Sambuc[B<-[cipher]>] 41ebfedea0SLionel Sambuc[B<-nointern>] 42ebfedea0SLionel Sambuc[B<-no_signer_cert_verify>] 43ebfedea0SLionel Sambuc[B<-nocerts>] 44ebfedea0SLionel Sambuc[B<-noattr>] 45ebfedea0SLionel Sambuc[B<-nosmimecap>] 46ebfedea0SLionel Sambuc[B<-binary>] 47ebfedea0SLionel Sambuc[B<-nodetach>] 48ebfedea0SLionel Sambuc[B<-certfile file>] 49ebfedea0SLionel Sambuc[B<-certsout file>] 50ebfedea0SLionel Sambuc[B<-signer file>] 51ebfedea0SLionel Sambuc[B<-recip file>] 52ebfedea0SLionel Sambuc[B<-keyid>] 53ebfedea0SLionel Sambuc[B<-receipt_request_all -receipt_request_first>] 54ebfedea0SLionel Sambuc[B<-receipt_request_from emailaddress>] 55ebfedea0SLionel Sambuc[B<-receipt_request_to emailaddress>] 56ebfedea0SLionel Sambuc[B<-receipt_request_print>] 57ebfedea0SLionel Sambuc[B<-secretkey key>] 58ebfedea0SLionel Sambuc[B<-secretkeyid id>] 59ebfedea0SLionel Sambuc[B<-econtent_type type>] 60ebfedea0SLionel Sambuc[B<-inkey file>] 61ebfedea0SLionel Sambuc[B<-passin arg>] 62ebfedea0SLionel Sambuc[B<-rand file(s)>] 63ebfedea0SLionel Sambuc[B<cert.pem...>] 64ebfedea0SLionel Sambuc[B<-to addr>] 65ebfedea0SLionel Sambuc[B<-from addr>] 66ebfedea0SLionel Sambuc[B<-subject subj>] 67ebfedea0SLionel Sambuc[cert.pem]... 68ebfedea0SLionel Sambuc 69ebfedea0SLionel Sambuc=head1 DESCRIPTION 70ebfedea0SLionel Sambuc 71ebfedea0SLionel SambucThe B<cms> command handles S/MIME v3.1 mail. It can encrypt, decrypt, sign and 72ebfedea0SLionel Sambucverify, compress and uncompress S/MIME messages. 73ebfedea0SLionel Sambuc 74ebfedea0SLionel Sambuc=head1 COMMAND OPTIONS 75ebfedea0SLionel Sambuc 76ebfedea0SLionel SambucThere are fourteen operation options that set the type of operation to be 77ebfedea0SLionel Sambucperformed. The meaning of the other options varies according to the operation 78ebfedea0SLionel Sambuctype. 79ebfedea0SLionel Sambuc 80ebfedea0SLionel Sambuc=over 4 81ebfedea0SLionel Sambuc 82ebfedea0SLionel Sambuc=item B<-encrypt> 83ebfedea0SLionel Sambuc 84ebfedea0SLionel Sambucencrypt mail for the given recipient certificates. Input file is the message 85ebfedea0SLionel Sambucto be encrypted. The output file is the encrypted mail in MIME format. The 86ebfedea0SLionel Sambucactual CMS type is <B>EnvelopedData<B>. 87ebfedea0SLionel Sambuc 88ebfedea0SLionel Sambuc=item B<-decrypt> 89ebfedea0SLionel Sambuc 90ebfedea0SLionel Sambucdecrypt mail using the supplied certificate and private key. Expects an 91ebfedea0SLionel Sambucencrypted mail message in MIME format for the input file. The decrypted mail 92ebfedea0SLionel Sambucis written to the output file. 93ebfedea0SLionel Sambuc 94*0a6a1f1dSLionel Sambuc=item B<-debug_decrypt> 95*0a6a1f1dSLionel Sambuc 96*0a6a1f1dSLionel Sambucthis option sets the B<CMS_DEBUG_DECRYPT> flag. This option should be used 97*0a6a1f1dSLionel Sambucwith caution: see the notes section below. 98*0a6a1f1dSLionel Sambuc 99ebfedea0SLionel Sambuc=item B<-sign> 100ebfedea0SLionel Sambuc 101ebfedea0SLionel Sambucsign mail using the supplied certificate and private key. Input file is 102ebfedea0SLionel Sambucthe message to be signed. The signed message in MIME format is written 103ebfedea0SLionel Sambucto the output file. 104ebfedea0SLionel Sambuc 105ebfedea0SLionel Sambuc=item B<-verify> 106ebfedea0SLionel Sambuc 107ebfedea0SLionel Sambucverify signed mail. Expects a signed mail message on input and outputs 108ebfedea0SLionel Sambucthe signed data. Both clear text and opaque signing is supported. 109ebfedea0SLionel Sambuc 110ebfedea0SLionel Sambuc=item B<-cmsout> 111ebfedea0SLionel Sambuc 112ebfedea0SLionel Sambuctakes an input message and writes out a PEM encoded CMS structure. 113ebfedea0SLionel Sambuc 114ebfedea0SLionel Sambuc=item B<-resign> 115ebfedea0SLionel Sambuc 116ebfedea0SLionel Sambucresign a message: take an existing message and one or more new signers. 117ebfedea0SLionel Sambuc 118ebfedea0SLionel Sambuc=item B<-data_create> 119ebfedea0SLionel Sambuc 120ebfedea0SLionel SambucCreate a CMS B<Data> type. 121ebfedea0SLionel Sambuc 122ebfedea0SLionel Sambuc=item B<-data_out> 123ebfedea0SLionel Sambuc 124ebfedea0SLionel SambucB<Data> type and output the content. 125ebfedea0SLionel Sambuc 126ebfedea0SLionel Sambuc=item B<-digest_create> 127ebfedea0SLionel Sambuc 128ebfedea0SLionel SambucCreate a CMS B<DigestedData> type. 129ebfedea0SLionel Sambuc 130ebfedea0SLionel Sambuc=item B<-digest_verify> 131ebfedea0SLionel Sambuc 132ebfedea0SLionel SambucVerify a CMS B<DigestedData> type and output the content. 133ebfedea0SLionel Sambuc 134ebfedea0SLionel Sambuc=item B<-compress> 135ebfedea0SLionel Sambuc 136ebfedea0SLionel SambucCreate a CMS B<CompressedData> type. OpenSSL must be compiled with B<zlib> 137ebfedea0SLionel Sambucsupport for this option to work, otherwise it will output an error. 138ebfedea0SLionel Sambuc 139ebfedea0SLionel Sambuc=item B<-uncompress> 140ebfedea0SLionel Sambuc 141ebfedea0SLionel SambucUncompress a CMS B<CompressedData> type and output the content. OpenSSL must be 142ebfedea0SLionel Sambuccompiled with B<zlib> support for this option to work, otherwise it will 143ebfedea0SLionel Sambucoutput an error. 144ebfedea0SLionel Sambuc 145ebfedea0SLionel Sambuc=item B<-EncryptedData_encrypt> 146ebfedea0SLionel Sambuc 147*0a6a1f1dSLionel SambucEncrypt content using supplied symmetric key and algorithm using a CMS 148ebfedea0SLionel SambucB<EncrytedData> type and output the content. 149ebfedea0SLionel Sambuc 150ebfedea0SLionel Sambuc=item B<-sign_receipt> 151ebfedea0SLionel Sambuc 152ebfedea0SLionel SambucGenerate and output a signed receipt for the supplied message. The input 153ebfedea0SLionel Sambucmessage B<must> contain a signed receipt request. Functionality is otherwise 154ebfedea0SLionel Sambucsimilar to the B<-sign> operation. 155ebfedea0SLionel Sambuc 156ebfedea0SLionel Sambuc=item B<-verify_receipt receipt> 157ebfedea0SLionel Sambuc 158ebfedea0SLionel SambucVerify a signed receipt in filename B<receipt>. The input message B<must> 159ebfedea0SLionel Sambuccontain the original receipt request. Functionality is otherwise similar 160ebfedea0SLionel Sambucto the B<-verify> operation. 161ebfedea0SLionel Sambuc 162ebfedea0SLionel Sambuc=item B<-in filename> 163ebfedea0SLionel Sambuc 164ebfedea0SLionel Sambucthe input message to be encrypted or signed or the message to be decrypted 165ebfedea0SLionel Sambucor verified. 166ebfedea0SLionel Sambuc 167ebfedea0SLionel Sambuc=item B<-inform SMIME|PEM|DER> 168ebfedea0SLionel Sambuc 169ebfedea0SLionel Sambucthis specifies the input format for the CMS structure. The default 170ebfedea0SLionel Sambucis B<SMIME> which reads an S/MIME format message. B<PEM> and B<DER> 171ebfedea0SLionel Sambucformat change this to expect PEM and DER format CMS structures 172ebfedea0SLionel Sambucinstead. This currently only affects the input format of the CMS 173ebfedea0SLionel Sambucstructure, if no CMS structure is being input (for example with 174ebfedea0SLionel SambucB<-encrypt> or B<-sign>) this option has no effect. 175ebfedea0SLionel Sambuc 176ebfedea0SLionel Sambuc=item B<-rctform SMIME|PEM|DER> 177ebfedea0SLionel Sambuc 178ebfedea0SLionel Sambucspecify the format for a signed receipt for use with the B<-receipt_verify> 179ebfedea0SLionel Sambucoperation. 180ebfedea0SLionel Sambuc 181ebfedea0SLionel Sambuc=item B<-out filename> 182ebfedea0SLionel Sambuc 183ebfedea0SLionel Sambucthe message text that has been decrypted or verified or the output MIME 184ebfedea0SLionel Sambucformat message that has been signed or verified. 185ebfedea0SLionel Sambuc 186ebfedea0SLionel Sambuc=item B<-outform SMIME|PEM|DER> 187ebfedea0SLionel Sambuc 188ebfedea0SLionel Sambucthis specifies the output format for the CMS structure. The default 189ebfedea0SLionel Sambucis B<SMIME> which writes an S/MIME format message. B<PEM> and B<DER> 190ebfedea0SLionel Sambucformat change this to write PEM and DER format CMS structures 191ebfedea0SLionel Sambucinstead. This currently only affects the output format of the CMS 192ebfedea0SLionel Sambucstructure, if no CMS structure is being output (for example with 193ebfedea0SLionel SambucB<-verify> or B<-decrypt>) this option has no effect. 194ebfedea0SLionel Sambuc 195ebfedea0SLionel Sambuc=item B<-stream -indef -noindef> 196ebfedea0SLionel Sambuc 197ebfedea0SLionel Sambucthe B<-stream> and B<-indef> options are equivalent and enable streaming I/O 198ebfedea0SLionel Sambucfor encoding operations. This permits single pass processing of data without 199ebfedea0SLionel Sambucthe need to hold the entire contents in memory, potentially supporting very 200ebfedea0SLionel Sambuclarge files. Streaming is automatically set for S/MIME signing with detached 201ebfedea0SLionel Sambucdata if the output format is B<SMIME> it is currently off by default for all 202ebfedea0SLionel Sambucother operations. 203ebfedea0SLionel Sambuc 204ebfedea0SLionel Sambuc=item B<-noindef> 205ebfedea0SLionel Sambuc 206ebfedea0SLionel Sambucdisable streaming I/O where it would produce and indefinite length constructed 207ebfedea0SLionel Sambucencoding. This option currently has no effect. In future streaming will be 208ebfedea0SLionel Sambucenabled by default on all relevant operations and this option will disable it. 209ebfedea0SLionel Sambuc 210ebfedea0SLionel Sambuc=item B<-content filename> 211ebfedea0SLionel Sambuc 212ebfedea0SLionel SambucThis specifies a file containing the detached content, this is only 213ebfedea0SLionel Sambucuseful with the B<-verify> command. This is only usable if the CMS 214ebfedea0SLionel Sambucstructure is using the detached signature form where the content is 215ebfedea0SLionel Sambucnot included. This option will override any content if the input format 216ebfedea0SLionel Sambucis S/MIME and it uses the multipart/signed MIME content type. 217ebfedea0SLionel Sambuc 218ebfedea0SLionel Sambuc=item B<-text> 219ebfedea0SLionel Sambuc 220ebfedea0SLionel Sambucthis option adds plain text (text/plain) MIME headers to the supplied 221ebfedea0SLionel Sambucmessage if encrypting or signing. If decrypting or verifying it strips 222ebfedea0SLionel Sambucoff text headers: if the decrypted or verified message is not of MIME 223ebfedea0SLionel Sambuctype text/plain then an error occurs. 224ebfedea0SLionel Sambuc 225ebfedea0SLionel Sambuc=item B<-noout> 226ebfedea0SLionel Sambuc 227ebfedea0SLionel Sambucfor the B<-cmsout> operation do not output the parsed CMS structure. This 228ebfedea0SLionel Sambucis useful when combined with the B<-print> option or if the syntax of the CMS 229ebfedea0SLionel Sambucstructure is being checked. 230ebfedea0SLionel Sambuc 231ebfedea0SLionel Sambuc=item B<-print> 232ebfedea0SLionel Sambuc 233ebfedea0SLionel Sambucfor the B<-cmsout> operation print out all fields of the CMS structure. This 234ebfedea0SLionel Sambucis mainly useful for testing purposes. 235ebfedea0SLionel Sambuc 236ebfedea0SLionel Sambuc=item B<-CAfile file> 237ebfedea0SLionel Sambuc 238ebfedea0SLionel Sambuca file containing trusted CA certificates, only used with B<-verify>. 239ebfedea0SLionel Sambuc 240ebfedea0SLionel Sambuc=item B<-CApath dir> 241ebfedea0SLionel Sambuc 242ebfedea0SLionel Sambuca directory containing trusted CA certificates, only used with 243ebfedea0SLionel SambucB<-verify>. This directory must be a standard certificate directory: that 244ebfedea0SLionel Sambucis a hash of each subject name (using B<x509 -hash>) should be linked 245ebfedea0SLionel Sambucto each certificate. 246ebfedea0SLionel Sambuc 247ebfedea0SLionel Sambuc=item B<-md digest> 248ebfedea0SLionel Sambuc 249ebfedea0SLionel Sambucdigest algorithm to use when signing or resigning. If not present then the 250ebfedea0SLionel Sambucdefault digest algorithm for the signing key will be used (usually SHA1). 251ebfedea0SLionel Sambuc 252ebfedea0SLionel Sambuc=item B<-[cipher]> 253ebfedea0SLionel Sambuc 254ebfedea0SLionel Sambucthe encryption algorithm to use. For example triple DES (168 bits) - B<-des3> 255ebfedea0SLionel Sambucor 256 bit AES - B<-aes256>. Any standard algorithm name (as used by the 256ebfedea0SLionel SambucEVP_get_cipherbyname() function) can also be used preceded by a dash, for 257ebfedea0SLionel Sambucexample B<-aes_128_cbc>. See L<B<enc>|enc(1)> for a list of ciphers 258ebfedea0SLionel Sambucsupported by your version of OpenSSL. 259ebfedea0SLionel Sambuc 260ebfedea0SLionel SambucIf not specified triple DES is used. Only used with B<-encrypt> and 261ebfedea0SLionel SambucB<-EncryptedData_create> commands. 262ebfedea0SLionel Sambuc 263ebfedea0SLionel Sambuc=item B<-nointern> 264ebfedea0SLionel Sambuc 265ebfedea0SLionel Sambucwhen verifying a message normally certificates (if any) included in 266ebfedea0SLionel Sambucthe message are searched for the signing certificate. With this option 267ebfedea0SLionel Sambuconly the certificates specified in the B<-certfile> option are used. 268ebfedea0SLionel SambucThe supplied certificates can still be used as untrusted CAs however. 269ebfedea0SLionel Sambuc 270ebfedea0SLionel Sambuc=item B<-no_signer_cert_verify> 271ebfedea0SLionel Sambuc 272ebfedea0SLionel Sambucdo not verify the signers certificate of a signed message. 273ebfedea0SLionel Sambuc 274ebfedea0SLionel Sambuc=item B<-nocerts> 275ebfedea0SLionel Sambuc 276ebfedea0SLionel Sambucwhen signing a message the signer's certificate is normally included 277ebfedea0SLionel Sambucwith this option it is excluded. This will reduce the size of the 278ebfedea0SLionel Sambucsigned message but the verifier must have a copy of the signers certificate 279ebfedea0SLionel Sambucavailable locally (passed using the B<-certfile> option for example). 280ebfedea0SLionel Sambuc 281ebfedea0SLionel Sambuc=item B<-noattr> 282ebfedea0SLionel Sambuc 283ebfedea0SLionel Sambucnormally when a message is signed a set of attributes are included which 284ebfedea0SLionel Sambucinclude the signing time and supported symmetric algorithms. With this 285ebfedea0SLionel Sambucoption they are not included. 286ebfedea0SLionel Sambuc 287ebfedea0SLionel Sambuc=item B<-nosmimecap> 288ebfedea0SLionel Sambuc 289ebfedea0SLionel Sambucexclude the list of supported algorithms from signed attributes, other options 290ebfedea0SLionel Sambucsuch as signing time and content type are still included. 291ebfedea0SLionel Sambuc 292ebfedea0SLionel Sambuc=item B<-binary> 293ebfedea0SLionel Sambuc 294ebfedea0SLionel Sambucnormally the input message is converted to "canonical" format which is 295ebfedea0SLionel Sambuceffectively using CR and LF as end of line: as required by the S/MIME 296ebfedea0SLionel Sambucspecification. When this option is present no translation occurs. This 297ebfedea0SLionel Sambucis useful when handling binary data which may not be in MIME format. 298ebfedea0SLionel Sambuc 299ebfedea0SLionel Sambuc=item B<-nodetach> 300ebfedea0SLionel Sambuc 301ebfedea0SLionel Sambucwhen signing a message use opaque signing: this form is more resistant 302ebfedea0SLionel Sambucto translation by mail relays but it cannot be read by mail agents that 303ebfedea0SLionel Sambucdo not support S/MIME. Without this option cleartext signing with 304ebfedea0SLionel Sambucthe MIME type multipart/signed is used. 305ebfedea0SLionel Sambuc 306ebfedea0SLionel Sambuc=item B<-certfile file> 307ebfedea0SLionel Sambuc 308ebfedea0SLionel Sambucallows additional certificates to be specified. When signing these will 309ebfedea0SLionel Sambucbe included with the message. When verifying these will be searched for 310ebfedea0SLionel Sambucthe signers certificates. The certificates should be in PEM format. 311ebfedea0SLionel Sambuc 312ebfedea0SLionel Sambuc=item B<-certsout file> 313ebfedea0SLionel Sambuc 314ebfedea0SLionel Sambucany certificates contained in the message are written to B<file>. 315ebfedea0SLionel Sambuc 316ebfedea0SLionel Sambuc=item B<-signer file> 317ebfedea0SLionel Sambuc 318ebfedea0SLionel Sambuca signing certificate when signing or resigning a message, this option can be 319ebfedea0SLionel Sambucused multiple times if more than one signer is required. If a message is being 320ebfedea0SLionel Sambucverified then the signers certificates will be written to this file if the 321ebfedea0SLionel Sambucverification was successful. 322ebfedea0SLionel Sambuc 323ebfedea0SLionel Sambuc=item B<-recip file> 324ebfedea0SLionel Sambuc 325ebfedea0SLionel Sambucthe recipients certificate when decrypting a message. This certificate 326ebfedea0SLionel Sambucmust match one of the recipients of the message or an error occurs. 327ebfedea0SLionel Sambuc 328ebfedea0SLionel Sambuc=item B<-keyid> 329ebfedea0SLionel Sambuc 330ebfedea0SLionel Sambucuse subject key identifier to identify certificates instead of issuer name and 331ebfedea0SLionel Sambucserial number. The supplied certificate B<must> include a subject key 332ebfedea0SLionel Sambucidentifier extension. Supported by B<-sign> and B<-encrypt> options. 333ebfedea0SLionel Sambuc 334ebfedea0SLionel Sambuc=item B<-receipt_request_all -receipt_request_first> 335ebfedea0SLionel Sambuc 336ebfedea0SLionel Sambucfor B<-sign> option include a signed receipt request. Indicate requests should 337ebfedea0SLionel Sambucbe provided by all receipient or first tier recipients (those mailed directly 338ebfedea0SLionel Sambucand not from a mailing list). Ignored it B<-receipt_request_from> is included. 339ebfedea0SLionel Sambuc 340ebfedea0SLionel Sambuc=item B<-receipt_request_from emailaddress> 341ebfedea0SLionel Sambuc 342ebfedea0SLionel Sambucfor B<-sign> option include a signed receipt request. Add an explicit email 343ebfedea0SLionel Sambucaddress where receipts should be supplied. 344ebfedea0SLionel Sambuc 345ebfedea0SLionel Sambuc=item B<-receipt_request_to emailaddress> 346ebfedea0SLionel Sambuc 347ebfedea0SLionel SambucAdd an explicit email address where signed receipts should be sent to. This 348ebfedea0SLionel Sambucoption B<must> but supplied if a signed receipt it requested. 349ebfedea0SLionel Sambuc 350ebfedea0SLionel Sambuc=item B<-receipt_request_print> 351ebfedea0SLionel Sambuc 352ebfedea0SLionel SambucFor the B<-verify> operation print out the contents of any signed receipt 353ebfedea0SLionel Sambucrequests. 354ebfedea0SLionel Sambuc 355ebfedea0SLionel Sambuc=item B<-secretkey key> 356ebfedea0SLionel Sambuc 357ebfedea0SLionel Sambucspecify symmetric key to use. The key must be supplied in hex format and be 358ebfedea0SLionel Sambucconsistent with the algorithm used. Supported by the B<-EncryptedData_encrypt> 359ebfedea0SLionel SambucB<-EncrryptedData_decrypt>, B<-encrypt> and B<-decrypt> options. When used 360ebfedea0SLionel Sambucwith B<-encrypt> or B<-decrypt> the supplied key is used to wrap or unwrap the 361ebfedea0SLionel Sambuccontent encryption key using an AES key in the B<KEKRecipientInfo> type. 362ebfedea0SLionel Sambuc 363ebfedea0SLionel Sambuc=item B<-secretkeyid id> 364ebfedea0SLionel Sambuc 365ebfedea0SLionel Sambucthe key identifier for the supplied symmetric key for B<KEKRecipientInfo> type. 366ebfedea0SLionel SambucThis option B<must> be present if the B<-secretkey> option is used with 367ebfedea0SLionel SambucB<-encrypt>. With B<-decrypt> operations the B<id> is used to locate the 368ebfedea0SLionel Sambucrelevant key if it is not supplied then an attempt is used to decrypt any 369ebfedea0SLionel SambucB<KEKRecipientInfo> structures. 370ebfedea0SLionel Sambuc 371ebfedea0SLionel Sambuc=item B<-econtent_type type> 372ebfedea0SLionel Sambuc 373ebfedea0SLionel Sambucset the encapsulated content type to B<type> if not supplied the B<Data> type 374ebfedea0SLionel Sambucis used. The B<type> argument can be any valid OID name in either text or 375ebfedea0SLionel Sambucnumerical format. 376ebfedea0SLionel Sambuc 377ebfedea0SLionel Sambuc=item B<-inkey file> 378ebfedea0SLionel Sambuc 379ebfedea0SLionel Sambucthe private key to use when signing or decrypting. This must match the 380ebfedea0SLionel Sambuccorresponding certificate. If this option is not specified then the 381ebfedea0SLionel Sambucprivate key must be included in the certificate file specified with 382ebfedea0SLionel Sambucthe B<-recip> or B<-signer> file. When signing this option can be used 383ebfedea0SLionel Sambucmultiple times to specify successive keys. 384ebfedea0SLionel Sambuc 385ebfedea0SLionel Sambuc=item B<-passin arg> 386ebfedea0SLionel Sambuc 387ebfedea0SLionel Sambucthe private key password source. For more information about the format of B<arg> 388ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 389ebfedea0SLionel Sambuc 390ebfedea0SLionel Sambuc=item B<-rand file(s)> 391ebfedea0SLionel Sambuc 392ebfedea0SLionel Sambuca file or files containing random data used to seed the random number 393ebfedea0SLionel Sambucgenerator, or an EGD socket (see L<RAND_egd(3)|RAND_egd(3)>). 394ebfedea0SLionel SambucMultiple files can be specified separated by a OS-dependent character. 395ebfedea0SLionel SambucThe separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for 396ebfedea0SLionel Sambucall others. 397ebfedea0SLionel Sambuc 398ebfedea0SLionel Sambuc=item B<cert.pem...> 399ebfedea0SLionel Sambuc 400ebfedea0SLionel Sambucone or more certificates of message recipients: used when encrypting 401ebfedea0SLionel Sambuca message. 402ebfedea0SLionel Sambuc 403ebfedea0SLionel Sambuc=item B<-to, -from, -subject> 404ebfedea0SLionel Sambuc 405ebfedea0SLionel Sambucthe relevant mail headers. These are included outside the signed 406ebfedea0SLionel Sambucportion of a message so they may be included manually. If signing 407ebfedea0SLionel Sambucthen many S/MIME mail clients check the signers certificate's email 408ebfedea0SLionel Sambucaddress matches that specified in the From: address. 409ebfedea0SLionel Sambuc 410*0a6a1f1dSLionel Sambuc=item B<-purpose, -ignore_critical, -issuer_checks, -crl_check, -crl_check_all, -policy_check, -extended_crl, -x509_strict, -policy -check_ss_sig -no_alt_chains> 411ebfedea0SLionel Sambuc 412ebfedea0SLionel SambucSet various certificate chain valiadition option. See the 413ebfedea0SLionel SambucL<B<verify>|verify(1)> manual page for details. 414ebfedea0SLionel Sambuc 415ebfedea0SLionel Sambuc=back 416ebfedea0SLionel Sambuc 417ebfedea0SLionel Sambuc=head1 NOTES 418ebfedea0SLionel Sambuc 419ebfedea0SLionel SambucThe MIME message must be sent without any blank lines between the 420ebfedea0SLionel Sambucheaders and the output. Some mail programs will automatically add 421ebfedea0SLionel Sambuca blank line. Piping the mail directly to sendmail is one way to 422ebfedea0SLionel Sambucachieve the correct format. 423ebfedea0SLionel Sambuc 424ebfedea0SLionel SambucThe supplied message to be signed or encrypted must include the 425ebfedea0SLionel Sambucnecessary MIME headers or many S/MIME clients wont display it 426ebfedea0SLionel Sambucproperly (if at all). You can use the B<-text> option to automatically 427ebfedea0SLionel Sambucadd plain text headers. 428ebfedea0SLionel Sambuc 429ebfedea0SLionel SambucA "signed and encrypted" message is one where a signed message is 430ebfedea0SLionel Sambucthen encrypted. This can be produced by encrypting an already signed 431ebfedea0SLionel Sambucmessage: see the examples section. 432ebfedea0SLionel Sambuc 433ebfedea0SLionel SambucThis version of the program only allows one signer per message but it 434ebfedea0SLionel Sambucwill verify multiple signers on received messages. Some S/MIME clients 435ebfedea0SLionel Sambucchoke if a message contains multiple signers. It is possible to sign 436ebfedea0SLionel Sambucmessages "in parallel" by signing an already signed message. 437ebfedea0SLionel Sambuc 438ebfedea0SLionel SambucThe options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME 439ebfedea0SLionel Sambucclients. Strictly speaking these process CMS enveloped data: CMS 440ebfedea0SLionel Sambucencrypted data is used for other purposes. 441ebfedea0SLionel Sambuc 442ebfedea0SLionel SambucThe B<-resign> option uses an existing message digest when adding a new 443ebfedea0SLionel Sambucsigner. This means that attributes must be present in at least one existing 444ebfedea0SLionel Sambucsigner using the same message digest or this operation will fail. 445ebfedea0SLionel Sambuc 446ebfedea0SLionel SambucThe B<-stream> and B<-indef> options enable experimental streaming I/O support. 447ebfedea0SLionel SambucAs a result the encoding is BER using indefinite length constructed encoding 448ebfedea0SLionel Sambucand no longer DER. Streaming is supported for the B<-encrypt> operation and the 449ebfedea0SLionel SambucB<-sign> operation if the content is not detached. 450ebfedea0SLionel Sambuc 451ebfedea0SLionel SambucStreaming is always used for the B<-sign> operation with detached data but 452ebfedea0SLionel Sambucsince the content is no longer part of the CMS structure the encoding 453ebfedea0SLionel Sambucremains DER. 454ebfedea0SLionel Sambuc 455*0a6a1f1dSLionel SambucIf the B<-decrypt> option is used without a recipient certificate then an 456*0a6a1f1dSLionel Sambucattempt is made to locate the recipient by trying each potential recipient 457*0a6a1f1dSLionel Sambucin turn using the supplied private key. To thwart the MMA attack 458*0a6a1f1dSLionel Sambuc(Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) all recipients are 459*0a6a1f1dSLionel Sambuctried whether they succeed or not and if no recipients match the message 460*0a6a1f1dSLionel Sambucis "decrypted" using a random key which will typically output garbage. 461*0a6a1f1dSLionel SambucThe B<-debug_decrypt> option can be used to disable the MMA attack protection 462*0a6a1f1dSLionel Sambucand return an error if no recipient can be found: this option should be used 463*0a6a1f1dSLionel Sambucwith caution. For a fuller description see L<CMS_decrypt(3)|CMS_decrypt(3)>). 464*0a6a1f1dSLionel Sambuc 465ebfedea0SLionel Sambuc=head1 EXIT CODES 466ebfedea0SLionel Sambuc 467ebfedea0SLionel Sambuc=over 4 468ebfedea0SLionel Sambuc 469*0a6a1f1dSLionel Sambuc=item Z<>0 470ebfedea0SLionel Sambuc 471ebfedea0SLionel Sambucthe operation was completely successfully. 472ebfedea0SLionel Sambuc 473*0a6a1f1dSLionel Sambuc=item Z<>1 474ebfedea0SLionel Sambuc 475ebfedea0SLionel Sambucan error occurred parsing the command options. 476ebfedea0SLionel Sambuc 477*0a6a1f1dSLionel Sambuc=item Z<>2 478ebfedea0SLionel Sambuc 479ebfedea0SLionel Sambucone of the input files could not be read. 480ebfedea0SLionel Sambuc 481*0a6a1f1dSLionel Sambuc=item Z<>3 482ebfedea0SLionel Sambuc 483ebfedea0SLionel Sambucan error occurred creating the CMS file or when reading the MIME 484ebfedea0SLionel Sambucmessage. 485ebfedea0SLionel Sambuc 486*0a6a1f1dSLionel Sambuc=item Z<>4 487ebfedea0SLionel Sambuc 488ebfedea0SLionel Sambucan error occurred decrypting or verifying the message. 489ebfedea0SLionel Sambuc 490*0a6a1f1dSLionel Sambuc=item Z<>5 491ebfedea0SLionel Sambuc 492ebfedea0SLionel Sambucthe message was verified correctly but an error occurred writing out 493ebfedea0SLionel Sambucthe signers certificates. 494ebfedea0SLionel Sambuc 495ebfedea0SLionel Sambuc=back 496ebfedea0SLionel Sambuc 497ebfedea0SLionel Sambuc=head1 COMPATIBILITY WITH PKCS#7 format. 498ebfedea0SLionel Sambuc 499ebfedea0SLionel SambucThe B<smime> utility can only process the older B<PKCS#7> format. The B<cms> 500ebfedea0SLionel Sambucutility supports Cryptographic Message Syntax format. Use of some features 501ebfedea0SLionel Sambucwill result in messages which cannot be processed by applications which only 502ebfedea0SLionel Sambucsupport the older format. These are detailed below. 503ebfedea0SLionel Sambuc 504ebfedea0SLionel SambucThe use of the B<-keyid> option with B<-sign> or B<-encrypt>. 505ebfedea0SLionel Sambuc 506ebfedea0SLionel SambucThe B<-outform PEM> option uses different headers. 507ebfedea0SLionel Sambuc 508ebfedea0SLionel SambucThe B<-compress> option. 509ebfedea0SLionel Sambuc 510ebfedea0SLionel SambucThe B<-secretkey> option when used with B<-encrypt>. 511ebfedea0SLionel Sambuc 512ebfedea0SLionel SambucAdditionally the B<-EncryptedData_create> and B<-data_create> type cannot 513ebfedea0SLionel Sambucbe processed by the older B<smime> command. 514ebfedea0SLionel Sambuc 515ebfedea0SLionel Sambuc=head1 EXAMPLES 516ebfedea0SLionel Sambuc 517ebfedea0SLionel SambucCreate a cleartext signed message: 518ebfedea0SLionel Sambuc 519ebfedea0SLionel Sambuc openssl cms -sign -in message.txt -text -out mail.msg \ 520ebfedea0SLionel Sambuc -signer mycert.pem 521ebfedea0SLionel Sambuc 522ebfedea0SLionel SambucCreate an opaque signed message 523ebfedea0SLionel Sambuc 524ebfedea0SLionel Sambuc openssl cms -sign -in message.txt -text -out mail.msg -nodetach \ 525ebfedea0SLionel Sambuc -signer mycert.pem 526ebfedea0SLionel Sambuc 527ebfedea0SLionel SambucCreate a signed message, include some additional certificates and 528ebfedea0SLionel Sambucread the private key from another file: 529ebfedea0SLionel Sambuc 530ebfedea0SLionel Sambuc openssl cms -sign -in in.txt -text -out mail.msg \ 531ebfedea0SLionel Sambuc -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem 532ebfedea0SLionel Sambuc 533ebfedea0SLionel SambucCreate a signed message with two signers, use key identifier: 534ebfedea0SLionel Sambuc 535ebfedea0SLionel Sambuc openssl cms -sign -in message.txt -text -out mail.msg \ 536ebfedea0SLionel Sambuc -signer mycert.pem -signer othercert.pem -keyid 537ebfedea0SLionel Sambuc 538ebfedea0SLionel SambucSend a signed message under Unix directly to sendmail, including headers: 539ebfedea0SLionel Sambuc 540ebfedea0SLionel Sambuc openssl cms -sign -in in.txt -text -signer mycert.pem \ 541ebfedea0SLionel Sambuc -from steve@openssl.org -to someone@somewhere \ 542ebfedea0SLionel Sambuc -subject "Signed message" | sendmail someone@somewhere 543ebfedea0SLionel Sambuc 544ebfedea0SLionel SambucVerify a message and extract the signer's certificate if successful: 545ebfedea0SLionel Sambuc 546ebfedea0SLionel Sambuc openssl cms -verify -in mail.msg -signer user.pem -out signedtext.txt 547ebfedea0SLionel Sambuc 548ebfedea0SLionel SambucSend encrypted mail using triple DES: 549ebfedea0SLionel Sambuc 550ebfedea0SLionel Sambuc openssl cms -encrypt -in in.txt -from steve@openssl.org \ 551ebfedea0SLionel Sambuc -to someone@somewhere -subject "Encrypted message" \ 552ebfedea0SLionel Sambuc -des3 user.pem -out mail.msg 553ebfedea0SLionel Sambuc 554ebfedea0SLionel SambucSign and encrypt mail: 555ebfedea0SLionel Sambuc 556ebfedea0SLionel Sambuc openssl cms -sign -in ml.txt -signer my.pem -text \ 557ebfedea0SLionel Sambuc | openssl cms -encrypt -out mail.msg \ 558ebfedea0SLionel Sambuc -from steve@openssl.org -to someone@somewhere \ 559ebfedea0SLionel Sambuc -subject "Signed and Encrypted message" -des3 user.pem 560ebfedea0SLionel Sambuc 561ebfedea0SLionel SambucNote: the encryption command does not include the B<-text> option because the 562ebfedea0SLionel Sambucmessage being encrypted already has MIME headers. 563ebfedea0SLionel Sambuc 564ebfedea0SLionel SambucDecrypt mail: 565ebfedea0SLionel Sambuc 566ebfedea0SLionel Sambuc openssl cms -decrypt -in mail.msg -recip mycert.pem -inkey key.pem 567ebfedea0SLionel Sambuc 568ebfedea0SLionel SambucThe output from Netscape form signing is a PKCS#7 structure with the 569ebfedea0SLionel Sambucdetached signature format. You can use this program to verify the 570ebfedea0SLionel Sambucsignature by line wrapping the base64 encoded structure and surrounding 571ebfedea0SLionel Sambucit with: 572ebfedea0SLionel Sambuc 573ebfedea0SLionel Sambuc -----BEGIN PKCS7----- 574ebfedea0SLionel Sambuc -----END PKCS7----- 575ebfedea0SLionel Sambuc 576ebfedea0SLionel Sambucand using the command, 577ebfedea0SLionel Sambuc 578ebfedea0SLionel Sambuc openssl cms -verify -inform PEM -in signature.pem -content content.txt 579ebfedea0SLionel Sambuc 580ebfedea0SLionel Sambucalternatively you can base64 decode the signature and use 581ebfedea0SLionel Sambuc 582ebfedea0SLionel Sambuc openssl cms -verify -inform DER -in signature.der -content content.txt 583ebfedea0SLionel Sambuc 584ebfedea0SLionel SambucCreate an encrypted message using 128 bit Camellia: 585ebfedea0SLionel Sambuc 586ebfedea0SLionel Sambuc openssl cms -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem 587ebfedea0SLionel Sambuc 588ebfedea0SLionel SambucAdd a signer to an existing message: 589ebfedea0SLionel Sambuc 590ebfedea0SLionel Sambuc openssl cms -resign -in mail.msg -signer newsign.pem -out mail2.msg 591ebfedea0SLionel Sambuc 592ebfedea0SLionel Sambuc=head1 BUGS 593ebfedea0SLionel Sambuc 594ebfedea0SLionel SambucThe MIME parser isn't very clever: it seems to handle most messages that I've 595ebfedea0SLionel Sambucthrown at it but it may choke on others. 596ebfedea0SLionel Sambuc 597ebfedea0SLionel SambucThe code currently will only write out the signer's certificate to a file: if 598ebfedea0SLionel Sambucthe signer has a separate encryption certificate this must be manually 599ebfedea0SLionel Sambucextracted. There should be some heuristic that determines the correct 600ebfedea0SLionel Sambucencryption certificate. 601ebfedea0SLionel Sambuc 602ebfedea0SLionel SambucIdeally a database should be maintained of a certificates for each email 603ebfedea0SLionel Sambucaddress. 604ebfedea0SLionel Sambuc 605ebfedea0SLionel SambucThe code doesn't currently take note of the permitted symmetric encryption 606ebfedea0SLionel Sambucalgorithms as supplied in the SMIMECapabilities signed attribute. this means the 607ebfedea0SLionel Sambucuser has to manually include the correct encryption algorithm. It should store 608ebfedea0SLionel Sambucthe list of permitted ciphers in a database and only use those. 609ebfedea0SLionel Sambuc 610ebfedea0SLionel SambucNo revocation checking is done on the signer's certificate. 611ebfedea0SLionel Sambuc 612ebfedea0SLionel Sambuc=head1 HISTORY 613ebfedea0SLionel Sambuc 614ebfedea0SLionel SambucThe use of multiple B<-signer> options and the B<-resign> command were first 615ebfedea0SLionel Sambucadded in OpenSSL 1.0.0 616ebfedea0SLionel Sambuc 617ebfedea0SLionel Sambuc 618*0a6a1f1dSLionel SambucThe -no_alt_chains options was first added to OpenSSL 1.0.1n and 1.0.2b. 619*0a6a1f1dSLionel Sambuc 620ebfedea0SLionel Sambuc=cut 621