public CompressedDataOpenPgpPacket(OpenPgpPacketHeader header, Stream inputStream) : base(header, inputStream) { int compressionAlgorithmId = inputStream.ReadByte(); CompressionAlgorithm = OpenPgpCompressionAlgorithm.GetCompressionAlgorithmById(compressionAlgorithmId); var decompressionStream = CompressionAlgorithm.Decompress(inputStream) as DeflateStream; DecompressedStream = new MemoryStream(); decompressionStream.CopyTo(DecompressedStream); DecompressedStream.Position = 0; }
private void ReadCompressedBlock(Stream inputStream) { var numBytesRead = inputStream.Read(CompressedBlock, 0, Header.NumCompressedBytes); if (numBytesRead != Header.NumCompressedBytes) { throw new IOException($"Expected {Header.NumCompressedBytes} bytes from the block, but received only {numBytesRead} bytes."); } int numUncompressedBytes = CompressionAlgorithm.Decompress(CompressedBlock, Header.NumCompressedBytes, UncompressedBlock, UncompressedBlock.Length); if (numUncompressedBytes != Header.NumUncompressedBytes) { throw new CompressionException($"Expected {Header.NumUncompressedBytes} bytes after decompression, but found only {numUncompressedBytes} bytes."); } }