cms.pod 23 KB

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