Decrypt my World

Cryptography, Security, Debugging and more!

How to call CryptMsg API in streaming mode - LargeCMS full sample

How to call CryptMsg API in streaming mode - LargeCMS full sample

  • Comments 4

Hi all

Some time ago I posted a sample which shows how to sign large CMS data by calling CryptMsg API directly (How to call CryptMsg API in streaming mode (C#)) and that way overcome the current limitations of SignedCms in .NET ("ASN1 value too large" error when calling SignedCms.ComputeSignature).

I continued working on the sample and extended it quite a lot. Current version implements SignedLargeCMS and EnvelopedLargeCMS, my own version of SignedCms and EnvelopedCMS to work with large data. 

I already shared the p/invoke declarations I used (P/Invoking CryptoAPI in .NET. Part 2 (C#)), and you can find the full version of the sample at Codeplex.

I hope this helps.

Regards,

 

Alex (Alejandro Campos Magencio)

  • Alex,

    Why the cosign method only support detached signature?

    Regards,

    Anlemaco

  • Hi Anlemaco, it is true that when using streaming, we only get detached cosigned messages. I figured it out when developing the sample. When I asked our Windows Product Group about this, they told me that streaming wasn’t designed to support adding a second signature. And there are no workarounds to this.

    Regards,

    Alex

  • Thanks for your quick reply Alex. Do you know another way (different to streaming) to cosign big files in attached mode?

    Regards,

    Anlemaco

  • Well, you can always call the same APIs without streaming. Cosign should work fine in attached mode there. Now, you won't be able to sign such big files (which was the purpose of this sample).

Page 1 of 1 (4 items)
Leave a Comment
  • Please add 4 and 4 and type the answer here:
  • Post
Translate This Page