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

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

问题描述

我正在研究需要解密 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?

我在这里遗漏了什么,还是有另一种方法可以在流级别而不是使用字节数组来做到这一点?

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.

您需要一个 3rd 方库.正如其他人所说,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.

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

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