public CmsEnvelopedDataParser(Stream envelopedData)
        : base(envelopedData)
    {
        _attrNotRead       = true;
        this.envelopedData = new EnvelopedDataParser((Asn1SequenceParser)contentInfo.GetContent(16));
        Asn1Set instance = Asn1Set.GetInstance(this.envelopedData.GetRecipientInfos().ToAsn1Object());
        EncryptedContentInfoParser encryptedContentInfo = this.envelopedData.GetEncryptedContentInfo();

        _encAlg = encryptedContentInfo.ContentEncryptionAlgorithm;
        CmsReadable       readable       = new CmsProcessableInputStream(((Asn1OctetStringParser)encryptedContentInfo.GetEncryptedContent(4)).GetOctetStream());
        CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(_encAlg, readable);

        recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(instance, secureReadable);
    }
    public CmsAuthenticatedDataParser(Stream envelopedData)
        : base(envelopedData)
    {
        authAttrNotRead = true;
        authData        = new AuthenticatedDataParser((Asn1SequenceParser)contentInfo.GetContent(16));
        Asn1Set instance = Asn1Set.GetInstance(authData.GetRecipientInfos().ToAsn1Object());

        macAlg = authData.GetMacAlgorithm();
        ContentInfoParser enapsulatedContentInfo = authData.GetEnapsulatedContentInfo();
        CmsReadable       readable       = new CmsProcessableInputStream(((Asn1OctetStringParser)enapsulatedContentInfo.GetContent(4)).GetOctetStream());
        CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(macAlg, readable);

        _recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(instance, secureReadable);
    }
Exemplo n.º 3
0
    public CmsEnvelopedData(ContentInfo contentInfo)
    {
        this.contentInfo = contentInfo;
        EnvelopedData        instance             = EnvelopedData.GetInstance(contentInfo.Content);
        Asn1Set              recipientInfos       = instance.RecipientInfos;
        EncryptedContentInfo encryptedContentInfo = instance.EncryptedContentInfo;

        encAlg = encryptedContentInfo.ContentEncryptionAlgorithm;
        CmsReadable       readable       = new CmsProcessableByteArray(encryptedContentInfo.EncryptedContent.GetOctets());
        CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsEnvelopedSecureReadable(encAlg, readable);

        recipientInfoStore    = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
        unprotectedAttributes = instance.UnprotectedAttrs;
    }
Exemplo n.º 4
0
 static CmsEnvelopedHelper()
 {
     Instance        = new CmsEnvelopedHelper();
     KeySizes        = Platform.CreateHashtable();
     BaseCipherNames = Platform.CreateHashtable();
     KeySizes.Add(CmsEnvelopedGenerator.DesEde3Cbc, 192);
     KeySizes.Add(CmsEnvelopedGenerator.Aes128Cbc, 128);
     KeySizes.Add(CmsEnvelopedGenerator.Aes192Cbc, 192);
     KeySizes.Add(CmsEnvelopedGenerator.Aes256Cbc, 256);
     BaseCipherNames.Add(CmsEnvelopedGenerator.DesEde3Cbc, "DESEDE");
     BaseCipherNames.Add(CmsEnvelopedGenerator.Aes128Cbc, "AES");
     BaseCipherNames.Add(CmsEnvelopedGenerator.Aes192Cbc, "AES");
     BaseCipherNames.Add(CmsEnvelopedGenerator.Aes256Cbc, "AES");
 }
    public CmsAuthenticatedData(ContentInfo contentInfo)
    {
        this.contentInfo = contentInfo;
        AuthenticatedData instance       = AuthenticatedData.GetInstance(contentInfo.Content);
        Asn1Set           recipientInfos = instance.RecipientInfos;

        macAlg = instance.MacAlgorithm;
        ContentInfo       encapsulatedContentInfo = instance.EncapsulatedContentInfo;
        CmsReadable       readable       = new CmsProcessableByteArray(Asn1OctetString.GetInstance(encapsulatedContentInfo.Content).GetOctets());
        CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(macAlg, readable);

        recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
        authAttrs          = instance.AuthAttrs;
        mac         = instance.Mac.GetOctets();
        unauthAttrs = instance.UnauthAttrs;
    }
Exemplo n.º 6
0
    public CmsAuthEnvelopedData(ContentInfo contentInfo)
    {
        this.contentInfo = contentInfo;
        AuthEnvelopedData instance = AuthEnvelopedData.GetInstance(contentInfo.Content);

        originator = instance.OriginatorInfo;
        Asn1Set recipientInfos = instance.RecipientInfos;
        EncryptedContentInfo authEncryptedContentInfo = instance.AuthEncryptedContentInfo;

        authEncAlg = authEncryptedContentInfo.ContentEncryptionAlgorithm;
        CmsSecureReadable secureReadable = new AuthEnvelopedSecureReadable(this);

        recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(recipientInfos, secureReadable);
        authAttrs          = instance.AuthAttrs;
        mac         = instance.Mac.GetOctets();
        unauthAttrs = instance.UnauthAttrs;
    }