Esempio n. 1
0
        private CmsCompressedData GetStdData()
        {
            CmsProcessableByteArray    testData = new CmsProcessableByteArray(TEST_DATA);
            CmsCompressedDataGenerator gen      = new CmsCompressedDataGenerator();

            return(gen.Generate(testData, CmsCompressedDataGenerator.ZLib));
        }
Esempio n. 2
0
        /// <summary>
        /// Compresses the specified stream.
        /// </summary>
        /// <remarks>
        /// Compresses the specified stream.
        /// </remarks>
        /// <returns>A new <see cref="MimeKit.Cryptography.ApplicationPkcs7Mime"/> instance
        /// containing the compressed content.</returns>
        /// <param name="stream">The stream to compress.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="stream"/> is <c>null</c>.
        /// </exception>
        /// <exception cref="Org.BouncyCastle.Cms.CmsException">
        /// An error occurred in the cryptographic message syntax subsystem.
        /// </exception>
        public ApplicationPkcs7Mime Compress(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            var compresser  = new CmsCompressedDataGenerator();
            var processable = new CmsProcessableInputStream(stream);
            var compressed  = compresser.Generate(processable, CmsCompressedDataGenerator.ZLib);
            var encoded     = compressed.GetEncoded();

            return(new ApplicationPkcs7Mime(SecureMimeType.CompressedData, new MemoryStream(encoded, false)));
        }