【问题标题】:encode CMS signedfile using ASN.1 DER in C#在 C# 中使用 ASN.1 DER 对 CMS 签名文件进行编码
【发布时间】:2013-11-17 18:48:14
【问题描述】:

我对密码学非常陌生。到目前为止,我已经成功生成了一个封装的 CMS 文件。但之后,我需要使用 ASN.1 DER 格式对 CMS 签名和加密数据文件进行编码,但不知道该怎么做?请给我一些建议。

下面我粘贴我的代码以获得更多亮点;

var content = File.ReadAllBytes(@"E:\Miscellaneous\Pacs.zip");

var contentInfo1 = new ContentInfo(content);
var signedCms = new SignedCms(contentInfo1);
var cmsSigner = new CmsSigner(GetSignerCert()) { IncludeOption = X509IncludeOption.None };

signedCms.ComputeSignature(cmsSigner);

var contentInfo = new ContentInfo(signedCms.Encode());

//  RSA_DES_EDE3_CBC.
var envelopedCms = new EnvelopedCms(contentInfo);

var recip1 = new CmsRecipient(
    SubjectIdentifierType.IssuerAndSerialNumber,
    GetRecipientCert());

envelopedCms.Encrypt(recip1);

File.WriteAllBytes(@"E:\signedfile", envelopedCms.Encode());
// need code to encode signedfile using ASN.1 DER

【问题讨论】:

标签: c# cryptography asn.1 der


【解决方案1】:

EnvelopedCms.Encode() 被指定为创建字节,但唯一的方法是使用编码方法。大约 99% 的确定编码 ASN.1 BER 或DER。所以很有可能你已经完成了你的目标。

【讨论】:

  • 让我猜猜,第一个字节是十六进制的3031,对吧?
猜你喜欢
  • 2013-10-14
  • 2022-01-22
  • 1970-01-01
  • 1970-01-01
  • 2017-06-29
  • 2015-12-10
  • 1970-01-01
  • 2011-11-11
  • 2010-11-19
相关资源
最近更新 更多