在C#解密PKCS#7加密数据 [英] Decrypting PKCS#7 encrypted data in C#

查看:1475
本文介绍了在C#解密PKCS#7加密数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个解决方案,需要解密PKCS#7加密数据,preferably在C#。据我所看到的,.NET API支持这个功能通过System.Security.Cryptography.Pkcs命名空间。但似乎执行只能工作于字节数组。所以,我该怎么办时,我有一个不适合的内存?

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.Cryptography.Pkcs namespace. However it seems that the implementation can only work on byte arrays. So what do I do when I have a large encrypted file that does not fit into the memory?

我失去了一些东西在这里,或有另一种方式来做到这一点在流水平,而不是使用的ByteArray?

Am I missing something here, or is there another way to do this on a Stream level instead of using bytearrays?

推荐答案

在.NET框架对PKCS#7 / CMS只有基本的支持,所以它不支持流媒体的数据。

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

您需要一个第三方库。正如其他人所说,BouncyCastle的是一个很好的选择。它支持的PKCS#7(PKCS#7也被称为CMS)的

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).

他们的测试很可能是一个很好的地方去寻找样本code:<一href="http://www.bouncycastle.org/viewcvs/viewcvs.cgi/csharp/crypto/test/src/cms/test/EnvelopedDataStreamTest.cs?rev=1.5&content-type=text/vnd.viewcvs-markup"相对=nofollow> EnvelopedDataStreamTest.cs 。

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

这篇关于在C#解密PKCS#7加密数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆