Decrypting PKCS#7 encrypted data in C#

后端 未结 4 1404
无人及你
无人及你 2020-12-10 19:53

I am working on a solution that needs to decrypt PKCS#7 encrypted data, preferably in C#. As far as I can see, the .NET api has support for this through the System.Security.

相关标签:
4条回答
  • 2020-12-10 20:28

    Do you have the option to change to using the BouncyCastle API, from http://www.bouncycastle.org/csharp/, as it uses streams for decryption.

    But, I don't believe it can use PKCS#7 encrypted data, so you would need to use BouncyCastle for the encryption side also.

    Here is an example of using this API: http://elian.co.uk/post/2009/07/29/Bouncy-Castle-CSharp.aspx

    If you want to use the .NET stuff this may be useful: http://www.geekpedia.com/tutorial227_Encrypting-and-Decrypting-Files-with-Csharp.html

    0 讨论(0)
  • 2020-12-10 20:32

    .Net Framework from 2.0 provided pkcs namespace that helps us to do sign/encrypt/decrypt in pkcs#7 standard. Please refer here for the overview http://msdn.microsoft.com/en-us/library/bb885086.aspx and here for a good example http:**msdn.microsoft.com/en-us/library/bb924565.aspx.

    0 讨论(0)
  • 2020-12-10 20:39

    The .NET framework has only rudimentary support for PKCS#7/CMS, so it does not support streaming the data.

    You need a 3rd party library. As others have mentioned, BouncyCastle is an excellent choice. It does support PKCS#7 (PKCS#7 is also known as CMS).

    Their tests are probably a good place to look for sample code: EnvelopedDataStreamTest.cs.

    0 讨论(0)
  • 2020-12-10 20:40

    I found an example of how to decrypt PKCS#7 in C#. It may be enough to get you started.

    0 讨论(0)
提交回复
热议问题