Domanda

I am pretty much new to cryptographic. So far I am successful to generate an enveloped CMS file. But after it, I need to encode a CMS Signed and encrypted data file using ASN.1 DER format but don't know how to? please provide me some suggestion.

below I paste my code for more light;

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
È stato utile?

Soluzione

EnvelopedCms.Encode() is specified to create bytes, but the only way to do that is to use an encoding method. It is about 99% certain that that encoding is ASN.1 BER or DER. So it is extremely likely that you've already accomplished your goal.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top