summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpCompressedData.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-10-24 15:49:27 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-10-24 15:49:27 +0700
commitbe97c80fdecadac37413a6a6a8de417e0332f6bf (patch)
treedef3bf31b937a4e59458574f6441036ffdf61616 /crypto/src/openpgp/PgpCompressedData.cs
parentUse correct OID (diff)
downloadBouncyCastle.NET-ed25519-be97c80fdecadac37413a6a6a8de417e0332f6bf.tar.xz
Use platform compression where available
- Move Bzip2 code into Utilities
Diffstat (limited to 'crypto/src/openpgp/PgpCompressedData.cs')
-rw-r--r--crypto/src/openpgp/PgpCompressedData.cs23
1 files changed, 11 insertions, 12 deletions
diff --git a/crypto/src/openpgp/PgpCompressedData.cs b/crypto/src/openpgp/PgpCompressedData.cs
index fc7d200d0..346b0b1a1 100644
--- a/crypto/src/openpgp/PgpCompressedData.cs
+++ b/crypto/src/openpgp/PgpCompressedData.cs
@@ -1,7 +1,6 @@
 using System.IO;
 
-using Org.BouncyCastle.Bzip2;
-using Org.BouncyCastle.Utilities.Zlib;
+using Org.BouncyCastle.Utilities.IO.Compression;
 
 namespace Org.BouncyCastle.Bcpg.OpenPgp
 {
@@ -38,16 +37,16 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
         {
             switch (Algorithm)
             {
-				case CompressionAlgorithmTag.Uncompressed:
-					return GetInputStream();
-				case CompressionAlgorithmTag.Zip:
-					return new ZInputStream(GetInputStream(), true);
-                case CompressionAlgorithmTag.ZLib:
-					return new ZInputStream(GetInputStream());
-				case CompressionAlgorithmTag.BZip2:
-					return new CBZip2InputStream(GetInputStream());
-                default:
-                    throw new PgpException("can't recognise compression algorithm: " + Algorithm);
+			case CompressionAlgorithmTag.Uncompressed:
+				return GetInputStream();
+			case CompressionAlgorithmTag.Zip:
+                return Zip.DecompressInput(GetInputStream());
+            case CompressionAlgorithmTag.ZLib:
+				return ZLib.DecompressInput(GetInputStream());
+			case CompressionAlgorithmTag.BZip2:
+                return Bzip2.DecompressInput(GetInputStream());
+            default:
+                throw new PgpException("can't recognise compression algorithm: " + Algorithm);
             }
         }
     }