Ejemplo n.º 1
0
        public CmsAuthenticatedDataParser(
            Stream envelopedData)
            : base(envelopedData)
        {
            this.authAttrNotRead = true;
            this.authData        = new AuthenticatedDataParser(
                (Asn1SequenceParser)contentInfo.GetContent(Asn1Tags.Sequence));

            // TODO Validate version?
            //DerInteger version = this.authData.getVersion();

            //
            // read the recipients
            //
            Asn1Set recipientInfos = Asn1Set.GetInstance(authData.GetRecipientInfos().ToAsn1Object());

            this.macAlg = authData.GetMacAlgorithm();

            //
            // read the authenticated content info
            //
            ContentInfoParser data     = authData.GetEnapsulatedContentInfo();
            CmsReadable       readable = new CmsProcessableInputStream(
                ((Asn1OctetStringParser)data.GetContent(Asn1Tags.OctetString)).GetOctetStream());
            CmsSecureReadable secureReadable = new CmsEnvelopedHelper.CmsAuthenticatedSecureReadable(
                this.macAlg, readable);

            //
            // build the RecipientInformationStore
            //
            this._recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(
                recipientInfos, secureReadable);
        }
        public CmsAuthenticatedDataParser(Stream envelopedData) : base(envelopedData)
        {
            this.authAttrNotRead = true;
            this.authData        = new AuthenticatedDataParser((Asn1SequenceParser)this.contentInfo.GetContent(16));
            Asn1Set instance = Asn1Set.GetInstance(this.authData.GetRecipientInfos().ToAsn1Object());

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

            this._recipientInfoStore = CmsEnvelopedHelper.BuildRecipientInformationStore(instance, secureReadable);
        }
        public CmsAuthenticatedDataParser(
            Stream envelopedData)
            : base(envelopedData)
        {
            this.authAttrNotRead = true;
            this.authData        = new AuthenticatedDataParser(
                (Asn1SequenceParser)contentInfo.GetContent(Asn1Tags.Sequence));

            // TODO Validate version?
            //DerInteger version = this.authData.getVersion();

            //
            // load the RecipientInfoStore
            //
            Asn1SetParser s         = authData.GetRecipientInfos();
            IList         baseInfos = new ArrayList();

            IAsn1Convertible entry;

            while ((entry = s.ReadObject()) != null)
            {
                baseInfos.Add(RecipientInfo.GetInstance(entry.ToAsn1Object()));
            }

            this.macAlg = authData.GetMacAlgorithm();

            //
            // read the encrypted content info
            //
            ContentInfoParser data = authData.GetEnapsulatedContentInfo();

            //
            // prime the recipients
            //
            Stream contentStream = ((Asn1OctetStringParser)data.GetContent(Asn1Tags.OctetString)).GetOctetStream();
            IList  infos         = CmsEnvelopedHelper.ReadRecipientInfos(
                baseInfos, contentStream, null, macAlg, null);

            _recipientInfoStore = new RecipientInformationStore(infos);
        }