This sample also demonstrates how to define the CRYPT_DECRYPT_MESSAGE_PARA struct in managed code, specify its members, and pass it by ref to CryptDecryptMessage().
DecEnvelop.exe is a command line utility:
DecEnvelop.exe [enveloped message file] [decrypted data output file]
Example: Outlook Express 6 S/MIME EnvelopedData Message
The following shows a simple example of an encrypted email message, with plain text and a binary (image) file attachment generated by Outlook Express 6.
[Note: While CAPICOM provides the
object, there are some interop usage issues. EnvelopedData.Content is exposed as a bstr and because of
.NET <--> COM interop marshaling, usage is restricted to enveloped data and associated content in b64 format.
Usage of binary data content with CAPICOM.EnvelopedData requires disassembling/modifying/reassembly of the standard .NET
interop assembly. The DecEnvelop implemention here using P/Invoke does not require CAPICOM and is not
limited in this way.]
Michel I. Gallant