How to create a CADES-BES PKCS#7 signed message in c# with a precomputed signature?

Viewed 527

I am using key Vault HSM to compute the signature. However i need a CADES-BES PKCS#7 structure to contain the signature .

I tried using CMS Signer library, however CMS Signer need private key, but in my case private key is only present in HSM.I also tried using Bouncy castle, but it provides signature in CMS format and i need to generate CADES-BES format.

What can be the best approach to generate the CADES-BES signature in C# ? Is there any built in .Net Class for it ?

I have used this code under Org.BouncyCastle.Asn1.Cms to create ,however it is CMS Format.

        SignedData signedData = new SignedData(
            digestAlgorithms: new DerSet(digestAlgorithms),
            contentInfo: encapContentInfo,
            certificates: new BerSet(certificates),
            crls: null,
            signerInfos: new DerSet(signerInfos));

        ContentInfo contentInfo = new ContentInfo(
            contentType: new DerObjectIdentifier(OID.PKCS7IdSignedData),
            content: signedData);
0 Answers
Related