public byte[] GetContent(
     ICipherParameters key)
 {
     try
     {
         return(CmsUtilities.StreamToByteArray(GetContentStream(key).ContentStream));
     }
     catch (IOException e)
     {
         throw new Exception("unable to parse internal stream: " + e);
     }
 }
        /**
         * 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(contentInfo.Content);
            ContentInfo    content = comData.EncapContentInfo;

            Asn1OctetString bytes = (Asn1OctetString)content.Content;

            ZInputStream 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);
            }
        }
        /**
         * Return the uncompressed content.
         *
         * @return the uncompressed content
         * @throws CmsException if there is an exception uncompressing the data.
         */
        public byte[] GetContent()
        {
            CompressedData comData = CompressedData.GetInstance(contentInfo.Content);
            ContentInfo    content = comData.EncapContentInfo;

            Asn1OctetString bytes = (Asn1OctetString)content.Content;
            ZInputStream    zIn   = new ZInputStream(bytes.GetOctetStream());

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