cms.pod 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. =pod
  2. =head1 NAME
  3. openssl-cms,
  4. cms - CMS utility
  5. =head1 SYNOPSIS
  6. B<openssl> B<cms>
  7. [B<-help>]
  8. [B<-encrypt>]
  9. [B<-decrypt>]
  10. [B<-sign>]
  11. [B<-verify>]
  12. [B<-cmsout>]
  13. [B<-resign>]
  14. [B<-data_create>]
  15. [B<-data_out>]
  16. [B<-digest_create>]
  17. [B<-digest_verify>]
  18. [B<-compress>]
  19. [B<-uncompress>]
  20. [B<-EncryptedData_encrypt>]
  21. [B<-sign_receipt>]
  22. [B<-verify_receipt receipt>]
  23. [B<-in filename>]
  24. [B<-inform SMIME|PEM|DER>]
  25. [B<-rctform SMIME|PEM|DER>]
  26. [B<-out filename>]
  27. [B<-outform SMIME|PEM|DER>]
  28. [B<-stream -indef -noindef>]
  29. [B<-noindef>]
  30. [B<-content filename>]
  31. [B<-text>]
  32. [B<-noout>]
  33. [B<-print>]
  34. [B<-CAfile file>]
  35. [B<-CApath dir>]
  36. [B<-no-CAfile>]
  37. [B<-no-CApath>]
  38. [B<-attime timestamp>]
  39. [B<-check_ss_sig>]
  40. [B<-crl_check>]
  41. [B<-crl_check_all>]
  42. [B<-explicit_policy>]
  43. [B<-extended_crl>]
  44. [B<-ignore_critical>]
  45. [B<-inhibit_any>]
  46. [B<-inhibit_map>]
  47. [B<-no_check_time>]
  48. [B<-partial_chain>]
  49. [B<-policy arg>]
  50. [B<-policy_check>]
  51. [B<-policy_print>]
  52. [B<-purpose purpose>]
  53. [B<-suiteB_128>]
  54. [B<-suiteB_128_only>]
  55. [B<-suiteB_192>]
  56. [B<-trusted_first>]
  57. [B<-no_alt_chains>]
  58. [B<-use_deltas>]
  59. [B<-auth_level num>]
  60. [B<-verify_depth num>]
  61. [B<-verify_email email>]
  62. [B<-verify_hostname hostname>]
  63. [B<-verify_ip ip>]
  64. [B<-verify_name name>]
  65. [B<-x509_strict>]
  66. [B<-md digest>]
  67. [B<-I<cipher>>]
  68. [B<-nointern>]
  69. [B<-noverify>]
  70. [B<-nocerts>]
  71. [B<-noattr>]
  72. [B<-nosmimecap>]
  73. [B<-binary>]
  74. [B<-crlfeol>]
  75. [B<-asciicrlf>]
  76. [B<-nodetach>]
  77. [B<-certfile file>]
  78. [B<-certsout file>]
  79. [B<-signer file>]
  80. [B<-recip file>]
  81. [B<-keyid>]
  82. [B<-receipt_request_all -receipt_request_first>]
  83. [B<-receipt_request_from emailaddress>]
  84. [B<-receipt_request_to emailaddress>]
  85. [B<-receipt_request_print>]
  86. [B<-secretkey key>]
  87. [B<-secretkeyid id>]
  88. [B<-econtent_type type>]
  89. [B<-inkey file>]
  90. [B<-keyopt name:parameter>]
  91. [B<-passin arg>]
  92. [B<-rand file...>]
  93. [B<-writerand file>]
  94. [B<cert.pem...>]
  95. [B<-to addr>]
  96. [B<-from addr>]
  97. [B<-subject subj>]
  98. [cert.pem]...
  99. =head1 DESCRIPTION
  100. The B<cms> command handles S/MIME v3.1 mail. It can encrypt, decrypt, sign and
  101. verify, compress and uncompress S/MIME messages.
  102. =head1 OPTIONS
  103. There are fourteen operation options that set the type of operation to be
  104. performed. The meaning of the other options varies according to the operation
  105. type.
  106. =over 4
  107. =item B<-help>
  108. Print out a usage message.
  109. =item B<-encrypt>
  110. Encrypt mail for the given recipient certificates. Input file is the message
  111. to be encrypted. The output file is the encrypted mail in MIME format. The
  112. actual CMS type is <B>EnvelopedData<B>.
  113. Note that no revocation check is done for the recipient cert, so if that
  114. key has been compromised, others may be able to decrypt the text.
  115. =item B<-decrypt>
  116. Decrypt mail using the supplied certificate and private key. Expects an
  117. encrypted mail message in MIME format for the input file. The decrypted mail
  118. is written to the output file.
  119. =item B<-debug_decrypt>
  120. This option sets the B<CMS_DEBUG_DECRYPT> flag. This option should be used
  121. with caution: see the notes section below.
  122. =item B<-sign>
  123. Sign mail using the supplied certificate and private key. Input file is
  124. the message to be signed. The signed message in MIME format is written
  125. to the output file.
  126. =item B<-verify>
  127. Verify signed mail. Expects a signed mail message on input and outputs
  128. the signed data. Both clear text and opaque signing is supported.
  129. =item B<-cmsout>
  130. Takes an input message and writes out a PEM encoded CMS structure.
  131. =item B<-resign>
  132. Resign a message: take an existing message and one or more new signers.
  133. =item B<-data_create>
  134. Create a CMS B<Data> type.
  135. =item B<-data_out>
  136. B<Data> type and output the content.
  137. =item B<-digest_create>
  138. Create a CMS B<DigestedData> type.
  139. =item B<-digest_verify>
  140. Verify a CMS B<DigestedData> type and output the content.
  141. =item B<-compress>
  142. Create a CMS B<CompressedData> type. OpenSSL must be compiled with B<zlib>
  143. support for this option to work, otherwise it will output an error.
  144. =item B<-uncompress>
  145. Uncompress a CMS B<CompressedData> type and output the content. OpenSSL must be
  146. compiled with B<zlib> support for this option to work, otherwise it will
  147. output an error.
  148. =item B<-EncryptedData_encrypt>
  149. Encrypt content using supplied symmetric key and algorithm using a CMS
  150. B<EncryptedData> type and output the content.
  151. =item B<-sign_receipt>
  152. Generate and output a signed receipt for the supplied message. The input
  153. message B<must> contain a signed receipt request. Functionality is otherwise
  154. similar to the B<-sign> operation.
  155. =item B<-verify_receipt receipt>
  156. Verify a signed receipt in filename B<receipt>. The input message B<must>
  157. contain the original receipt request. Functionality is otherwise similar
  158. to the B<-verify> operation.
  159. =item B<-in filename>
  160. The input message to be encrypted or signed or the message to be decrypted
  161. or verified.
  162. =item B<-inform SMIME|PEM|DER>
  163. This specifies the input format for the CMS structure. The default
  164. is B<SMIME> which reads an S/MIME format message. B<PEM> and B<DER>
  165. format change this to expect PEM and DER format CMS structures
  166. instead. This currently only affects the input format of the CMS
  167. structure, if no CMS structure is being input (for example with
  168. B<-encrypt> or B<-sign>) this option has no effect.
  169. =item B<-rctform SMIME|PEM|DER>
  170. Specify the format for a signed receipt for use with the B<-receipt_verify>
  171. operation.
  172. =item B<-out filename>
  173. The message text that has been decrypted or verified or the output MIME
  174. format message that has been signed or verified.
  175. =item B<-outform SMIME|PEM|DER>
  176. This specifies the output format for the CMS structure. The default
  177. is B<SMIME> which writes an S/MIME format message. B<PEM> and B<DER>
  178. format change this to write PEM and DER format CMS structures
  179. instead. This currently only affects the output format of the CMS
  180. structure, if no CMS structure is being output (for example with
  181. B<-verify> or B<-decrypt>) this option has no effect.
  182. =item B<-stream -indef -noindef>
  183. The B<-stream> and B<-indef> options are equivalent and enable streaming I/O
  184. for encoding operations. This permits single pass processing of data without
  185. the need to hold the entire contents in memory, potentially supporting very
  186. large files. Streaming is automatically set for S/MIME signing with detached
  187. data if the output format is B<SMIME> it is currently off by default for all
  188. other operations.
  189. =item B<-noindef>
  190. Disable streaming I/O where it would produce and indefinite length constructed
  191. encoding. This option currently has no effect. In future streaming will be
  192. enabled by default on all relevant operations and this option will disable it.
  193. =item B<-content filename>
  194. This specifies a file containing the detached content, this is only
  195. useful with the B<-verify> command. This is only usable if the CMS
  196. structure is using the detached signature form where the content is
  197. not included. This option will override any content if the input format
  198. is S/MIME and it uses the multipart/signed MIME content type.
  199. =item B<-text>
  200. This option adds plain text (text/plain) MIME headers to the supplied
  201. message if encrypting or signing. If decrypting or verifying it strips
  202. off text headers: if the decrypted or verified message is not of MIME
  203. type text/plain then an error occurs.
  204. =item B<-noout>
  205. For the B<-cmsout> operation do not output the parsed CMS structure. This
  206. is useful when combined with the B<-print> option or if the syntax of the CMS
  207. structure is being checked.
  208. =item B<-print>
  209. For the B<-cmsout> operation print out all fields of the CMS structure. This
  210. is mainly useful for testing purposes.
  211. =item B<-CAfile file>
  212. A file containing trusted CA certificates, only used with B<-verify>.
  213. =item B<-CApath dir>
  214. A directory containing trusted CA certificates, only used with
  215. B<-verify>. This directory must be a standard certificate directory: that
  216. is a hash of each subject name (using B<x509 -hash>) should be linked
  217. to each certificate.
  218. =item B<-no-CAfile>
  219. Do not load the trusted CA certificates from the default file location
  220. =item B<-no-CApath>
  221. Do not load the trusted CA certificates from the default directory location
  222. =item B<-md digest>
  223. Digest algorithm to use when signing or resigning. If not present then the
  224. default digest algorithm for the signing key will be used (usually SHA1).
  225. =item B<-I<cipher>>
  226. The encryption algorithm to use. For example triple DES (168 bits) - B<-des3>
  227. or 256 bit AES - B<-aes256>. Any standard algorithm name (as used by the
  228. EVP_get_cipherbyname() function) can also be used preceded by a dash, for
  229. example B<-aes-128-cbc>. See L<B<enc>|enc(1)> for a list of ciphers
  230. supported by your version of OpenSSL.
  231. If not specified triple DES is used. Only used with B<-encrypt> and
  232. B<-EncryptedData_create> commands.
  233. =item B<-nointern>
  234. When verifying a message normally certificates (if any) included in
  235. the message are searched for the signing certificate. With this option
  236. only the certificates specified in the B<-certfile> option are used.
  237. The supplied certificates can still be used as untrusted CAs however.
  238. =item B<-noverify>
  239. Do not verify the signers certificate of a signed message.
  240. =item B<-nocerts>
  241. When signing a message the signer's certificate is normally included
  242. with this option it is excluded. This will reduce the size of the
  243. signed message but the verifier must have a copy of the signers certificate
  244. available locally (passed using the B<-certfile> option for example).
  245. =item B<-noattr>
  246. Normally when a message is signed a set of attributes are included which
  247. include the signing time and supported symmetric algorithms. With this
  248. option they are not included.
  249. =item B<-nosmimecap>
  250. Exclude the list of supported algorithms from signed attributes, other options
  251. such as signing time and content type are still included.
  252. =item B<-binary>
  253. Normally the input message is converted to "canonical" format which is
  254. effectively using CR and LF as end of line: as required by the S/MIME
  255. specification. When this option is present no translation occurs. This
  256. is useful when handling binary data which may not be in MIME format.
  257. =item B<-crlfeol>
  258. Normally the output file uses a single B<LF> as end of line. When this
  259. option is present B<CRLF> is used instead.
  260. =item B<-asciicrlf>
  261. When signing use ASCII CRLF format canonicalisation. This strips trailing
  262. whitespace from all lines, deletes trailing blank lines at EOF and sets
  263. the encapsulated content type. This option is normally used with detached
  264. content and an output signature format of DER. This option is not normally
  265. needed when verifying as it is enabled automatically if the encapsulated
  266. content format is detected.
  267. =item B<-nodetach>
  268. When signing a message use opaque signing: this form is more resistant
  269. to translation by mail relays but it cannot be read by mail agents that
  270. do not support S/MIME. Without this option cleartext signing with
  271. the MIME type multipart/signed is used.
  272. =item B<-certfile file>
  273. Allows additional certificates to be specified. When signing these will
  274. be included with the message. When verifying these will be searched for
  275. the signers certificates. The certificates should be in PEM format.
  276. =item B<-certsout file>
  277. Any certificates contained in the message are written to B<file>.
  278. =item B<-signer file>
  279. A signing certificate when signing or resigning a message, this option can be
  280. used multiple times if more than one signer is required. If a message is being
  281. verified then the signers certificates will be written to this file if the
  282. verification was successful.
  283. =item B<-recip file>
  284. When decrypting a message this specifies the recipients certificate. The
  285. certificate must match one of the recipients of the message or an error
  286. occurs.
  287. When encrypting a message this option may be used multiple times to specify
  288. each recipient. This form B<must> be used if customised parameters are
  289. required (for example to specify RSA-OAEP).
  290. Only certificates carrying RSA, Diffie-Hellman or EC keys are supported by this
  291. option.
  292. =item B<-keyid>
  293. Use subject key identifier to identify certificates instead of issuer name and
  294. serial number. The supplied certificate B<must> include a subject key
  295. identifier extension. Supported by B<-sign> and B<-encrypt> options.
  296. =item B<-receipt_request_all -receipt_request_first>
  297. For B<-sign> option include a signed receipt request. Indicate requests should
  298. be provided by all recipient or first tier recipients (those mailed directly
  299. and not from a mailing list). Ignored it B<-receipt_request_from> is included.
  300. =item B<-receipt_request_from emailaddress>
  301. For B<-sign> option include a signed receipt request. Add an explicit email
  302. address where receipts should be supplied.
  303. =item B<-receipt_request_to emailaddress>
  304. Add an explicit email address where signed receipts should be sent to. This
  305. option B<must> but supplied if a signed receipt it requested.
  306. =item B<-receipt_request_print>
  307. For the B<-verify> operation print out the contents of any signed receipt
  308. requests.
  309. =item B<-secretkey key>
  310. Specify symmetric key to use. The key must be supplied in hex format and be
  311. consistent with the algorithm used. Supported by the B<-EncryptedData_encrypt>
  312. B<-EncryptedData_decrypt>, B<-encrypt> and B<-decrypt> options. When used
  313. with B<-encrypt> or B<-decrypt> the supplied key is used to wrap or unwrap the
  314. content encryption key using an AES key in the B<KEKRecipientInfo> type.
  315. =item B<-secretkeyid id>
  316. The key identifier for the supplied symmetric key for B<KEKRecipientInfo> type.
  317. This option B<must> be present if the B<-secretkey> option is used with
  318. B<-encrypt>. With B<-decrypt> operations the B<id> is used to locate the
  319. relevant key if it is not supplied then an attempt is used to decrypt any
  320. B<KEKRecipientInfo> structures.
  321. =item B<-econtent_type type>
  322. Set the encapsulated content type to B<type> if not supplied the B<Data> type
  323. is used. The B<type> argument can be any valid OID name in either text or
  324. numerical format.
  325. =item B<-inkey file>
  326. The private key to use when signing or decrypting. This must match the
  327. corresponding certificate. If this option is not specified then the
  328. private key must be included in the certificate file specified with
  329. the B<-recip> or B<-signer> file. When signing this option can be used
  330. multiple times to specify successive keys.
  331. =item B<-keyopt name:opt>
  332. For signing and encryption this option can be used multiple times to
  333. set customised parameters for the preceding key or certificate. It can
  334. currently be used to set RSA-PSS for signing, RSA-OAEP for encryption
  335. or to modify default parameters for ECDH.
  336. =item B<-passin arg>
  337. The private key password source. For more information about the format of B<arg>
  338. see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
  339. =item B<-rand file...>
  340. A file or files containing random data used to seed the random number
  341. generator.
  342. Multiple files can be specified separated by an OS-dependent character.
  343. The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
  344. all others.
  345. =item [B<-writerand file>]
  346. Writes random data to the specified I<file> upon exit.
  347. This can be used with a subsequent B<-rand> flag.
  348. =item B<cert.pem...>
  349. One or more certificates of message recipients: used when encrypting
  350. a message.
  351. =item B<-to, -from, -subject>
  352. The relevant mail headers. These are included outside the signed
  353. portion of a message so they may be included manually. If signing
  354. then many S/MIME mail clients check the signers certificate's email
  355. address matches that specified in the From: address.
  356. =item B<-attime>, B<-check_ss_sig>, B<-crl_check>, B<-crl_check_all>,
  357. B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>, B<-inhibit_any>,
  358. B<-inhibit_map>, B<-no_alt_chains>, B<-no_check_time>, B<-partial_chain>, B<-policy>,
  359. B<-policy_check>, B<-policy_print>, B<-purpose>, B<-suiteB_128>,
  360. B<-suiteB_128_only>, B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>,
  361. B<-auth_level>, B<-verify_depth>, B<-verify_email>, B<-verify_hostname>,
  362. B<-verify_ip>, B<-verify_name>, B<-x509_strict>
  363. Set various certificate chain validation options. See the
  364. L<verify(1)> manual page for details.
  365. =back
  366. =head1 NOTES
  367. The MIME message must be sent without any blank lines between the
  368. headers and the output. Some mail programs will automatically add
  369. a blank line. Piping the mail directly to sendmail is one way to
  370. achieve the correct format.
  371. The supplied message to be signed or encrypted must include the
  372. necessary MIME headers or many S/MIME clients won't display it
  373. properly (if at all). You can use the B<-text> option to automatically
  374. add plain text headers.
  375. A "signed and encrypted" message is one where a signed message is
  376. then encrypted. This can be produced by encrypting an already signed
  377. message: see the examples section.
  378. This version of the program only allows one signer per message but it
  379. will verify multiple signers on received messages. Some S/MIME clients
  380. choke if a message contains multiple signers. It is possible to sign
  381. messages "in parallel" by signing an already signed message.
  382. The options B<-encrypt> and B<-decrypt> reflect common usage in S/MIME
  383. clients. Strictly speaking these process CMS enveloped data: CMS
  384. encrypted data is used for other purposes.
  385. The B<-resign> option uses an existing message digest when adding a new
  386. signer. This means that attributes must be present in at least one existing
  387. signer using the same message digest or this operation will fail.
  388. The B<-stream> and B<-indef> options enable streaming I/O support.
  389. As a result the encoding is BER using indefinite length constructed encoding
  390. and no longer DER. Streaming is supported for the B<-encrypt> operation and the
  391. B<-sign> operation if the content is not detached.
  392. Streaming is always used for the B<-sign> operation with detached data but
  393. since the content is no longer part of the CMS structure the encoding
  394. remains DER.
  395. If the B<-decrypt> option is used without a recipient certificate then an
  396. attempt is made to locate the recipient by trying each potential recipient
  397. in turn using the supplied private key. To thwart the MMA attack
  398. (Bleichenbacher's attack on PKCS #1 v1.5 RSA padding) all recipients are
  399. tried whether they succeed or not and if no recipients match the message
  400. is "decrypted" using a random key which will typically output garbage.
  401. The B<-debug_decrypt> option can be used to disable the MMA attack protection
  402. and return an error if no recipient can be found: this option should be used
  403. with caution. For a fuller description see L<CMS_decrypt(3)>).
  404. =head1 EXIT CODES
  405. =over 4
  406. =item Z<>0
  407. The operation was completely successfully.
  408. =item Z<>1
  409. An error occurred parsing the command options.
  410. =item Z<>2
  411. One of the input files could not be read.
  412. =item Z<>3
  413. An error occurred creating the CMS file or when reading the MIME
  414. message.
  415. =item Z<>4
  416. An error occurred decrypting or verifying the message.
  417. =item Z<>5
  418. The message was verified correctly but an error occurred writing out
  419. the signers certificates.
  420. =back
  421. =head1 COMPATIBILITY WITH PKCS#7 format.
  422. The B<smime> utility can only process the older B<PKCS#7> format. The B<cms>
  423. utility supports Cryptographic Message Syntax format. Use of some features
  424. will result in messages which cannot be processed by applications which only
  425. support the older format. These are detailed below.
  426. The use of the B<-keyid> option with B<-sign> or B<-encrypt>.
  427. The B<-outform PEM> option uses different headers.
  428. The B<-compress> option.
  429. The B<-secretkey> option when used with B<-encrypt>.
  430. The use of PSS with B<-sign>.
  431. The use of OAEP or non-RSA keys with B<-encrypt>.
  432. Additionally the B<-EncryptedData_create> and B<-data_create> type cannot
  433. be processed by the older B<smime> command.
  434. =head1 EXAMPLES
  435. Create a cleartext signed message:
  436. openssl cms -sign -in message.txt -text -out mail.msg \
  437. -signer mycert.pem
  438. Create an opaque signed message
  439. openssl cms -sign -in message.txt -text -out mail.msg -nodetach \
  440. -signer mycert.pem
  441. Create a signed message, include some additional certificates and
  442. read the private key from another file:
  443. openssl cms -sign -in in.txt -text -out mail.msg \
  444. -signer mycert.pem -inkey mykey.pem -certfile mycerts.pem
  445. Create a signed message with two signers, use key identifier:
  446. openssl cms -sign -in message.txt -text -out mail.msg \
  447. -signer mycert.pem -signer othercert.pem -keyid
  448. Send a signed message under Unix directly to sendmail, including headers:
  449. openssl cms -sign -in in.txt -text -signer mycert.pem \
  450. -from steve@openssl.org -to someone@somewhere \
  451. -subject "Signed message" | sendmail someone@somewhere
  452. Verify a message and extract the signer's certificate if successful:
  453. openssl cms -verify -in mail.msg -signer user.pem -out signedtext.txt
  454. Send encrypted mail using triple DES:
  455. openssl cms -encrypt -in in.txt -from steve@openssl.org \
  456. -to someone@somewhere -subject "Encrypted message" \
  457. -des3 user.pem -out mail.msg
  458. Sign and encrypt mail:
  459. openssl cms -sign -in ml.txt -signer my.pem -text \
  460. | openssl cms -encrypt -out mail.msg \
  461. -from steve@openssl.org -to someone@somewhere \
  462. -subject "Signed and Encrypted message" -des3 user.pem
  463. Note: the encryption command does not include the B<-text> option because the
  464. message being encrypted already has MIME headers.
  465. Decrypt mail:
  466. openssl cms -decrypt -in mail.msg -recip mycert.pem -inkey key.pem
  467. The output from Netscape form signing is a PKCS#7 structure with the
  468. detached signature format. You can use this program to verify the
  469. signature by line wrapping the base64 encoded structure and surrounding
  470. it with:
  471. -----BEGIN PKCS7-----
  472. -----END PKCS7-----
  473. and using the command,
  474. openssl cms -verify -inform PEM -in signature.pem -content content.txt
  475. alternatively you can base64 decode the signature and use
  476. openssl cms -verify -inform DER -in signature.der -content content.txt
  477. Create an encrypted message using 128 bit Camellia:
  478. openssl cms -encrypt -in plain.txt -camellia128 -out mail.msg cert.pem
  479. Add a signer to an existing message:
  480. openssl cms -resign -in mail.msg -signer newsign.pem -out mail2.msg
  481. Sign mail using RSA-PSS:
  482. openssl cms -sign -in message.txt -text -out mail.msg \
  483. -signer mycert.pem -keyopt rsa_padding_mode:pss
  484. Create encrypted mail using RSA-OAEP:
  485. openssl cms -encrypt -in plain.txt -out mail.msg \
  486. -recip cert.pem -keyopt rsa_padding_mode:oaep
  487. Use SHA256 KDF with an ECDH certificate:
  488. openssl cms -encrypt -in plain.txt -out mail.msg \
  489. -recip ecdhcert.pem -keyopt ecdh_kdf_md:sha256
  490. =head1 BUGS
  491. The MIME parser isn't very clever: it seems to handle most messages that I've
  492. thrown at it but it may choke on others.
  493. The code currently will only write out the signer's certificate to a file: if
  494. the signer has a separate encryption certificate this must be manually
  495. extracted. There should be some heuristic that determines the correct
  496. encryption certificate.
  497. Ideally a database should be maintained of a certificates for each email
  498. address.
  499. The code doesn't currently take note of the permitted symmetric encryption
  500. algorithms as supplied in the SMIMECapabilities signed attribute. this means the
  501. user has to manually include the correct encryption algorithm. It should store
  502. the list of permitted ciphers in a database and only use those.
  503. No revocation checking is done on the signer's certificate.
  504. =head1 HISTORY
  505. The use of multiple B<-signer> options and the B<-resign> command were first
  506. added in OpenSSL 1.0.0.
  507. The B<keyopt> option was first added in OpenSSL 1.0.2.
  508. Support for RSA-OAEP and RSA-PSS was first added to OpenSSL 1.0.2.
  509. The use of non-RSA keys with B<-encrypt> and B<-decrypt> was first added
  510. to OpenSSL 1.0.2.
  511. The -no_alt_chains options was first added to OpenSSL 1.0.2b.
  512. =head1 COPYRIGHT
  513. Copyright 2008-2018 The OpenSSL Project Authors. All Rights Reserved.
  514. Licensed under the OpenSSL license (the "License"). You may not use
  515. this file except in compliance with the License. You can obtain a copy
  516. in the file LICENSE in the source distribution or at
  517. L<https://www.openssl.org/source/license.html>.
  518. =cut