工厂中的未知对象:Org.BouncyCastle.Asn1.DerApplicationSpecific'

时间:2019-04-30 15:22:07

标签: c# encryption bouncycastle

我正在尝试使用BouncyCastle库解密文件,但是当我尝试实例化CmsEnvelopedData对象时遇到此异常。前提是使用较小的文件(大约30Kb)可以工作。当我想解密一个较大的文件(大约400 Kb)时,出现此异常。解决方案?谢谢

代码解密文件:

public byte[] DecryptFile(byte[] file)
    {
        Asn1InputStream aIn = new Asn1InputStream(file);
        CmsEnvelopedData envelopedData = new CmsEnvelopedData(ContentInfo.GetInstance(aIn.ReadObject()));


        RecipientInformationStore recipients = envelopedData.GetRecipientInfos();
        var c = recipients.GetRecipients();
        foreach (RecipientInformation recipient in c)
        {
            var decrypted = recipient.GetContent(RetrievePrivateKey());
            return decrypted;


        }

        return null;
    }

enter image description here

我还附上了加密的示例文件: enter link description here

0 个答案:

没有答案