summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2023-03-06 23:30:06 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2023-03-06 23:30:06 +0700
commit52327a7cfef7837f5464f04f1fd681998e7a7ed2 (patch)
treeaf263306fca83f48e76bc5e7a0d7aea5ff4779d1
parentSupport leaveOpen in decompressors (diff)
downloadBouncyCastle.NET-ed25519-52327a7cfef7837f5464f04f1fd681998e7a7ed2.tar.xz
Refactoring in OpenPgp
-rw-r--r--crypto/src/openpgp/PgpCompressedData.cs7
-rw-r--r--crypto/src/openpgp/PgpLiteralData.cs7
-rw-r--r--crypto/src/openpgp/PgpMarker.cs7
-rw-r--r--crypto/src/openpgp/PgpPublicKeyRing.cs4
4 files changed, 11 insertions, 14 deletions
diff --git a/crypto/src/openpgp/PgpCompressedData.cs b/crypto/src/openpgp/PgpCompressedData.cs
index 346b0b1a1..b06f9bcaa 100644
--- a/crypto/src/openpgp/PgpCompressedData.cs
+++ b/crypto/src/openpgp/PgpCompressedData.cs
@@ -10,14 +10,13 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
     {
         private readonly CompressedDataPacket data;
 
-		public PgpCompressedData(
-            BcpgInputStream bcpgInput)
+		public PgpCompressedData(BcpgInputStream bcpgInput)
         {
             Packet packet = bcpgInput.ReadPacket();
-            if (!(packet is CompressedDataPacket))
+            if (!(packet is CompressedDataPacket compressedDataPacket))
                 throw new IOException("unexpected packet in stream: " + packet);
 
-            this.data = (CompressedDataPacket)packet;
+            this.data = compressedDataPacket;
         }
 
 		/// <summary>The algorithm used for compression</summary>
diff --git a/crypto/src/openpgp/PgpLiteralData.cs b/crypto/src/openpgp/PgpLiteralData.cs
index d1b7b4a4d..92fafe657 100644
--- a/crypto/src/openpgp/PgpLiteralData.cs
+++ b/crypto/src/openpgp/PgpLiteralData.cs
@@ -18,14 +18,13 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 
 		private readonly LiteralDataPacket data;
 
-		public PgpLiteralData(
-            BcpgInputStream bcpgInput)
+		public PgpLiteralData(BcpgInputStream bcpgInput)
         {
             Packet packet = bcpgInput.ReadPacket();
-            if (!(packet is LiteralDataPacket))
+            if (!(packet is LiteralDataPacket literalDataPacket))
                 throw new IOException("unexpected packet in stream: " + packet);
 
-            this.data = (LiteralDataPacket)packet;
+            this.data = literalDataPacket;
         }
 
 		/// <summary>The format of the data stream - Binary or Text</summary>
diff --git a/crypto/src/openpgp/PgpMarker.cs b/crypto/src/openpgp/PgpMarker.cs
index 7257767ec..fdbc02bc1 100644
--- a/crypto/src/openpgp/PgpMarker.cs
+++ b/crypto/src/openpgp/PgpMarker.cs
@@ -12,14 +12,13 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
     {
         private readonly MarkerPacket data;
 
-		public PgpMarker(
-            BcpgInputStream bcpgInput)
+		public PgpMarker(BcpgInputStream bcpgInput)
         {
             Packet packet = bcpgInput.ReadPacket();
-            if (!(packet is MarkerPacket))
+            if (!(packet is MarkerPacket markerPacket))
                 throw new IOException("unexpected packet in stream: " + packet);
 
-            this.data = (MarkerPacket)packet;
+            this.data = markerPacket;
         }
 	}
 }
diff --git a/crypto/src/openpgp/PgpPublicKeyRing.cs b/crypto/src/openpgp/PgpPublicKeyRing.cs
index e1a2a83f2..34b9e34d1 100644
--- a/crypto/src/openpgp/PgpPublicKeyRing.cs
+++ b/crypto/src/openpgp/PgpPublicKeyRing.cs
@@ -185,10 +185,10 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
         internal static PublicKeyPacket ReadPublicKeyPacket(BcpgInputStream bcpgInput)
         {
             Packet packet = bcpgInput.ReadPacket();
-            if (!(packet is PublicKeyPacket))
+            if (!(packet is PublicKeyPacket publicKeyPacket))
                 throw new IOException("unexpected packet in stream: " + packet);
 
-            return (PublicKeyPacket)packet;
+            return publicKeyPacket;
         }
 
         internal static PgpPublicKey ReadSubkey(BcpgInputStream bcpgInput)