|  | @@ -1,6 +1,9 @@
 | 
	
		
			
				|  |  | -#if NET6_0_OR_GREATER
 | 
	
		
			
				|  |  | -using System.IO;
 | 
	
		
			
				|  |  | +using System.IO;
 | 
	
		
			
				|  |  | +#if NET6_0_OR_GREATER
 | 
	
		
			
				|  |  |  using System.IO.Compression;
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +using Org.BouncyCastle.Utilities.Zlib;
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  namespace Renci.SshNet.Compression
 | 
	
		
			
				|  |  |  {
 | 
	
	
		
			
				|  | @@ -11,8 +14,13 @@ namespace Renci.SshNet.Compression
 | 
	
		
			
				|  |  |      public class Zlib : Compressor
 | 
	
		
			
				|  |  |  #pragma warning restore CA1724 // Type names should not match namespaces
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  | +#if NET6_0_OR_GREATER
 | 
	
		
			
				|  |  |          private readonly ZLibStream _compressor;
 | 
	
		
			
				|  |  |          private readonly ZLibStream _decompressor;
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +        private readonly ZOutputStream _compressor;
 | 
	
		
			
				|  |  | +        private readonly ZOutputStream _decompressor;
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |          private MemoryStream _compressorStream;
 | 
	
		
			
				|  |  |          private MemoryStream _decompressorStream;
 | 
	
		
			
				|  |  |          private bool _isDisposed;
 | 
	
	
		
			
				|  | @@ -37,8 +45,13 @@ namespace Renci.SshNet.Compression
 | 
	
		
			
				|  |  |              _compressorStream = new MemoryStream();
 | 
	
		
			
				|  |  |              _decompressorStream = new MemoryStream();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +#if NET6_0_OR_GREATER
 | 
	
		
			
				|  |  |              _compressor = new ZLibStream(_compressorStream, CompressionMode.Compress);
 | 
	
		
			
				|  |  |              _decompressor = new ZLibStream(_decompressorStream, CompressionMode.Decompress);
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +            _compressor = new ZOutputStream(_compressorStream, level: JZlib.Z_DEFAULT_COMPRESSION) { FlushMode = JZlib.Z_PARTIAL_FLUSH };
 | 
	
		
			
				|  |  | +            _decompressor = new ZOutputStream(_decompressorStream) { FlushMode = JZlib.Z_PARTIAL_FLUSH };
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <inheritdoc/>
 | 
	
	
		
			
				|  | @@ -61,6 +74,7 @@ namespace Renci.SshNet.Compression
 | 
	
		
			
				|  |  |          /// <inheritdoc/>
 | 
	
		
			
				|  |  |          protected override byte[] DecompressCore(byte[] data, int offset, int length)
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  | +#if NET6_0_OR_GREATER
 | 
	
		
			
				|  |  |              _decompressorStream.Write(data, offset, length);
 | 
	
		
			
				|  |  |              _decompressorStream.Position = 0;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -70,6 +84,14 @@ namespace Renci.SshNet.Compression
 | 
	
		
			
				|  |  |              _decompressorStream.SetLength(0);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              return outputStream.ToArray();
 | 
	
		
			
				|  |  | +#else
 | 
	
		
			
				|  |  | +            _decompressorStream.SetLength(0);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            _decompressor.Write(data, offset, length);
 | 
	
		
			
				|  |  | +            _decompressor.Flush();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return _decompressorStream.ToArray();
 | 
	
		
			
				|  |  | +#endif
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          /// <summary>
 | 
	
	
		
			
				|  | @@ -106,4 +128,3 @@ namespace Renci.SshNet.Compression
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  | -#endif
 |