Esempio n. 1
0
 public byte[] GetContent(
     ICipherParameters key)
 {
     try
     {
         return(CmsUtilities.StreamToByteArray(GetContentStream(key).ContentStream));
     }
     catch (IOException e)
     {
         throw new Exception("unable to parse internal stream: " + e);
     }
 }
Esempio n. 2
0
        /**
         * Return the uncompressed content, throwing an exception if the data size
         * is greater than the passed in limit. If the content is exceeded getCause()
         * on the CMSException will contain a StreamOverflowException
         *
         * @param limit maximum number of bytes to read
         * @return the content read
         * @throws CMSException if there is an exception uncompressing the data.
         */

        public byte[] GetContent(int limit)
        {
            CompressedData comData = CompressedData.GetInstance(ContentInfoInternal.Content);
            ContentInfo    content = comData.EncapContentInfo;

            var bytes = (Asn1OctetString)content.Content;

            var zIn = new ZInputStream(new MemoryStream(bytes.GetOctets(), false));

            try
            {
                return(CmsUtilities.StreamToByteArray(zIn, limit));
            }
            catch (IOException e)
            {
                throw new CmsException("exception reading compressed stream.", e);
            }
        }