summary refs log tree commit diff
path: root/crypto/src
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src')
-rw-r--r--crypto/src/openpgp/IStreamGenerator.cs3
-rw-r--r--crypto/src/openpgp/PgpCompressedDataGenerator.cs34
-rw-r--r--crypto/src/openpgp/PgpEncryptedDataGenerator.cs70
-rw-r--r--crypto/src/openpgp/PgpLiteralDataGenerator.cs26
-rw-r--r--crypto/src/openpgp/WrappedGeneratorStream.cs4
5 files changed, 52 insertions, 85 deletions
diff --git a/crypto/src/openpgp/IStreamGenerator.cs b/crypto/src/openpgp/IStreamGenerator.cs
index df8ff75da..03df37158 100644
--- a/crypto/src/openpgp/IStreamGenerator.cs
+++ b/crypto/src/openpgp/IStreamGenerator.cs
@@ -3,7 +3,8 @@ using System;
 namespace Org.BouncyCastle.Bcpg.OpenPgp
 {
 	public interface IStreamGenerator
-		: IDisposable
 	{
+		[Obsolete("Dispose any opened Stream directly")]
+		void Close();
 	}
 }
diff --git a/crypto/src/openpgp/PgpCompressedDataGenerator.cs b/crypto/src/openpgp/PgpCompressedDataGenerator.cs
index 271dfac7a..ecd09fd4f 100644
--- a/crypto/src/openpgp/PgpCompressedDataGenerator.cs
+++ b/crypto/src/openpgp/PgpCompressedDataGenerator.cs
@@ -148,33 +148,21 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 			}
 		}
 
-        #region IDisposable
-
-        public void Dispose()
-        {
-            Dispose(true);
-            GC.SuppressFinalize(this);
-        }
-
-        protected virtual void Dispose(bool disposing)
-        {
-            if (disposing)
+        [Obsolete("Dispose any opened Stream directly")]
+        public void Close()
+		{
+            if (dOut != null)
             {
-                if (dOut != null)
+                if (dOut != pkOut)
                 {
-                    if (dOut != pkOut)
-                    {
-                        dOut.Dispose();
-                    }
-                    dOut = null;
-
-                    pkOut.Finish();
-                    pkOut.Flush();
-                    pkOut = null;
+                    dOut.Dispose();
                 }
+                dOut = null;
+
+                pkOut.Finish();
+                pkOut.Flush();
+                pkOut = null;
             }
         }
-
-        #endregion
 	}
 }
diff --git a/crypto/src/openpgp/PgpEncryptedDataGenerator.cs b/crypto/src/openpgp/PgpEncryptedDataGenerator.cs
index b9473a32c..29d90c6fa 100644
--- a/crypto/src/openpgp/PgpEncryptedDataGenerator.cs
+++ b/crypto/src/openpgp/PgpEncryptedDataGenerator.cs
@@ -600,55 +600,43 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
             return Open(outStr, 0, buffer);
         }
 
-        #region IDisposable
-
-        public void Dispose()
+        [Obsolete("Dispose any opened Stream directly")]
+        public void Close()
         {
-            Dispose(true);
-            GC.SuppressFinalize(this);
-        }
-
-        protected virtual void Dispose(bool disposing)
-        {
-            if (disposing)
+            if (cOut != null)
             {
-                if (cOut != null)
+				// TODO Should this all be under the try/catch block?
+                if (digestOut != null)
                 {
-				    // TODO Should this all be under the try/catch block?
-                    if (digestOut != null)
-                    {
-                        //
-                        // hand code a mod detection packet
-                        //
-                        BcpgOutputStream bOut = new BcpgOutputStream(
-						    digestOut, PacketTag.ModificationDetectionCode, 20);
-
-                        bOut.Flush();
-                        digestOut.Flush();
-
-					    // TODO
-					    byte[] dig = DigestUtilities.DoFinal(digestOut.WriteDigest);
-					    cOut.Write(dig, 0, dig.Length);
-                    }
+                    //
+                    // hand code a mod detection packet
+                    //
+                    BcpgOutputStream bOut = new BcpgOutputStream(
+						digestOut, PacketTag.ModificationDetectionCode, 20);
 
-				    cOut.Flush();
+                    bOut.Flush();
+                    digestOut.Flush();
 
-				    try
-                    {
-					    pOut.Write(c.DoFinal());
-                        pOut.Finish();
-                    }
-                    catch (Exception e)
-                    {
-                        throw new IOException(e.Message, e);
-                    }
+					// TODO
+					byte[] dig = DigestUtilities.DoFinal(digestOut.WriteDigest);
+					cOut.Write(dig, 0, dig.Length);
+                }
+
+				cOut.Flush();
 
-				    cOut = null;
-				    pOut = null;
+				try
+                {
+					pOut.Write(c.DoFinal());
+                    pOut.Finish();
+                }
+                catch (Exception e)
+                {
+                    throw new IOException(e.Message, e);
                 }
+
+				cOut = null;
+				pOut = null;
             }
         }
-
-        #endregion
 	}
 }
diff --git a/crypto/src/openpgp/PgpLiteralDataGenerator.cs b/crypto/src/openpgp/PgpLiteralDataGenerator.cs
index fd59c1ebe..8fbed23d5 100644
--- a/crypto/src/openpgp/PgpLiteralDataGenerator.cs
+++ b/crypto/src/openpgp/PgpLiteralDataGenerator.cs
@@ -162,27 +162,15 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
 			return Open(outStr, format, file.Name, file.Length, file.LastWriteTime);
         }
 
-        #region IDisposable
-
-        public void Dispose()
-        {
-            Dispose(true);
-            GC.SuppressFinalize(this);
-        }
-
-        protected virtual void Dispose(bool disposing)
-        {
-            if (disposing)
+        [Obsolete("Dispose any opened Stream directly")]
+        public void Close()
+		{
+            if (pkOut != null)
             {
-                if (pkOut != null)
-                {
-                    pkOut.Finish();
-                    pkOut.Flush();
-                    pkOut = null;
-                }
+                pkOut.Finish();
+                pkOut.Flush();
+                pkOut = null;
             }
         }
-
-        #endregion
 	}
 }
diff --git a/crypto/src/openpgp/WrappedGeneratorStream.cs b/crypto/src/openpgp/WrappedGeneratorStream.cs
index c985a7a05..c973d0b02 100644
--- a/crypto/src/openpgp/WrappedGeneratorStream.cs
+++ b/crypto/src/openpgp/WrappedGeneratorStream.cs
@@ -20,7 +20,9 @@ namespace Org.BouncyCastle.Bcpg.OpenPgp
         {
 			if (disposing)
 			{
-				m_generator.Dispose();
+#pragma warning disable CS0618 // Type or member is obsolete
+				m_generator.Close();
+#pragma warning restore CS0618 // Type or member is obsolete
 			}
 
 			Detach(disposing);