コード例 #1
0
 public CmsTypedStream GetContent()
 {
     try
     {
         CompressedDataParser  compressedDataParser  = new CompressedDataParser((Asn1SequenceParser)contentInfo.GetContent(16));
         ContentInfoParser     encapContentInfo      = compressedDataParser.GetEncapContentInfo();
         Asn1OctetStringParser asn1OctetStringParser = (Asn1OctetStringParser)encapContentInfo.GetContent(4);
         return(new CmsTypedStream(encapContentInfo.ContentType.ToString(), new ZInputStream(asn1OctetStringParser.GetOctetStream())));
     }
     catch (IOException e)
     {
         throw new CmsException("IOException reading compressed content.", e);
     }
 }
コード例 #2
0
        public CmsTypedStream GetContent()
        {
            try
            {
                CompressedDataParser comData = new CompressedDataParser((Asn1SequenceParser)this.contentInfo.GetContent(Asn1Tags.Sequence));
                ContentInfoParser    content = comData.GetEncapContentInfo();

                Asn1OctetStringParser bytes = (Asn1OctetStringParser)content.GetContent(Asn1Tags.OctetString);

                return(new CmsTypedStream(content.ContentType.ToString(), new ZInputStream(bytes.GetOctetStream())));
            }
            catch (IOException e)
            {
                throw new CmsException("IOException reading compressed content.", e);
            }
        }
コード例 #3
0
 public CmsTypedStream GetContent()
 {
     //IL_004c: Expected O, but got Unknown
     try
     {
         CompressedDataParser  compressedDataParser  = new CompressedDataParser((Asn1SequenceParser)contentInfo.GetContent(16));
         ContentInfoParser     encapContentInfo      = compressedDataParser.GetEncapContentInfo();
         Asn1OctetStringParser asn1OctetStringParser = (Asn1OctetStringParser)encapContentInfo.GetContent(4);
         return(new CmsTypedStream(encapContentInfo.ContentType.ToString(), (Stream)(object)new ZInputStream(asn1OctetStringParser.GetOctetStream())));
     }
     catch (IOException val)
     {
         IOException e = val;
         throw new CmsException("IOException reading compressed content.", (global::System.Exception)(object) e);
     }
 }
コード例 #4
0
        public void TestNestedStructure()
        {
            MemoryStream bOut = new MemoryStream();

            BerSequenceGenerator sGen = new BerSequenceGenerator(bOut);

            sGen.AddObject(new DerObjectIdentifier(CmsObjectIdentifiers.CompressedData.Id));

            BerSequenceGenerator cGen = new BerSequenceGenerator(sGen.GetRawOutputStream(), 0, true);

            cGen.AddObject(new DerInteger(0));

            //
            // AlgorithmIdentifier
            //
            DerSequenceGenerator algGen = new DerSequenceGenerator(cGen.GetRawOutputStream());

            algGen.AddObject(new DerObjectIdentifier("1.2"));

            algGen.Close();

            //
            // Encapsulated ContentInfo
            //
            BerSequenceGenerator eiGen = new BerSequenceGenerator(cGen.GetRawOutputStream());

            eiGen.AddObject(new DerObjectIdentifier("1.1"));

            BerOctetStringGenerator octGen = new BerOctetStringGenerator(eiGen.GetRawOutputStream(), 0, true);

            //
            // output containing zeroes
            //
            Stream outStream = octGen.GetOctetOutputStream();

            outStream.Write(new byte[] { 1, 2, 3, 4 }, 0, 4);
            outStream.Write(new byte[4], 0, 4);
            outStream.Write(new byte[20], 0, 20);

            outStream.Close();
            eiGen.Close();
            cGen.Close();
            sGen.Close();

            //
            // reading back
            //
            Asn1StreamParser aIn = new Asn1StreamParser(bOut.ToArray());

            ContentInfoParser cp = new ContentInfoParser((Asn1SequenceParser)aIn.ReadObject());

            CompressedDataParser comData = new CompressedDataParser((Asn1SequenceParser)cp.GetContent(Asn1Tags.Sequence));
            ContentInfoParser    content = comData.GetEncapContentInfo();

            Asn1OctetStringParser bytes = (Asn1OctetStringParser)content.GetContent(Asn1Tags.OctetString);

            Stream inStream = bytes.GetOctetStream();
            int    count    = 0;

            while (inStream.ReadByte() >= 0)
            {
                count++;
            }

            Assert.AreEqual(28, count);
        }