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

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

问题描述

我正在开发一个解决方案,需要解密PKCS#7加密的数据,最好在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?

我缺少这里的东西,或者有另一种方式做到这一点一个流级别而不是使用bytearrays?

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

他们的测试可能是一个寻找示例代码的好地方: EnvelopedDataStreamTest.cs

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

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

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