summary refs log tree commit diff
path: root/crypto/src/openpgp/PgpCompressedData.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/openpgp/PgpCompressedData.cs')
-rw-r--r--crypto/src/openpgp/PgpCompressedData.cs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/src/openpgp/PgpCompressedData.cs b/crypto/src/openpgp/PgpCompressedData.cs
index e64a17c9c..c841b7474 100644
--- a/crypto/src/openpgp/PgpCompressedData.cs
+++ b/crypto/src/openpgp/PgpCompressedData.cs
@@ -14,7 +14,11 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 		public PgpCompressedData(
             BcpgInputStream bcpgInput)
         {
-            data = (CompressedDataPacket) bcpgInput.ReadPacket();
+            Packet packet = bcpgInput.ReadPacket();
+            if (!(packet is CompressedDataPacket))
+                throw new IOException("unexpected packet in stream: " + packet);
+
+            this.data = (CompressedDataPacket)packet;
         }
 
 		/// <summary>The algorithm used for compression</summary>