summary refs log tree commit diff
path: root/crypto/src/cms
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2022-11-09 13:46:52 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2022-11-09 13:46:52 +0700
commit43047794022f233577135285cf7a6aa6905ab65e (patch)
tree2a82f3ede3151e3eef177bda6e2988475022ecb7 /crypto/src/cms
parentCleanup (diff)
downloadBouncyCastle.NET-ed25519-43047794022f233577135285cf7a6aa6905ab65e.tar.xz
CmsContentInfoParser implements IDisposable
- Obsolete the Close method
Diffstat (limited to 'crypto/src/cms')
-rw-r--r--crypto/src/cms/CMSContentInfoParser.cs27
-rw-r--r--crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs2
-rw-r--r--crypto/src/cms/CMSEnvelopedHelper.cs12
3 files changed, 28 insertions, 13 deletions
diff --git a/crypto/src/cms/CMSContentInfoParser.cs b/crypto/src/cms/CMSContentInfoParser.cs
index c3bc9e736..86c7f459e 100644
--- a/crypto/src/cms/CMSContentInfoParser.cs
+++ b/crypto/src/cms/CMSContentInfoParser.cs
@@ -3,11 +3,11 @@ using System.IO;
 
 using Org.BouncyCastle.Asn1;
 using Org.BouncyCastle.Asn1.Cms;
-using Org.BouncyCastle.Utilities;
 
 namespace Org.BouncyCastle.Cms
 {
 	public class CmsContentInfoParser
+		: IDisposable
 	{
 		protected ContentInfoParser	contentInfo;
 		protected Stream data;
@@ -36,13 +36,28 @@ namespace Org.BouncyCastle.Cms
 			}
 		}
 
-		/**
-		* Close the underlying data stream.
-		* @throws IOException if the close fails.
-		*/
+		[Obsolete("Dispose instead")]
 		public void Close()
 		{
-            data.Dispose();
+            Dispose();
 		}
+
+		#region IDisposable
+
+		public void Dispose()
+		{
+			Dispose(true);
+			GC.SuppressFinalize(this);
+		}
+
+		protected virtual void Dispose(bool disposing)
+		{
+			if (disposing)
+			{
+				data.Dispose();
+			}
+		}
+
+		#endregion
 	}
 }
diff --git a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
index aafebee44..cfd3dde10 100644
--- a/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
+++ b/crypto/src/cms/CMSEnvelopedDataStreamGenerator.cs
@@ -26,7 +26,7 @@ namespace Org.BouncyCastle.Cms
 	*      MemoryStream  bOut = new MemoryStream();
 	*
 	*      Stream out = edGen.Open(
-	*                              bOut, CMSEnvelopedDataGenerator.AES128_CBC);*
+	*                              bOut, CMSEnvelopedGenerator.AES128_CBC);*
 	*      out.Write(data);
 	*
 	*      out.Close();
diff --git a/crypto/src/cms/CMSEnvelopedHelper.cs b/crypto/src/cms/CMSEnvelopedHelper.cs
index 86baa3642..888aba817 100644
--- a/crypto/src/cms/CMSEnvelopedHelper.cs
+++ b/crypto/src/cms/CMSEnvelopedHelper.cs
@@ -191,9 +191,9 @@ namespace Org.BouncyCastle.Cms
 //						else
 //						{
 //							string alg = macAlg.Algorithm.Id;
-//							if (alg.Equals(CmsEnvelopedDataGenerator.DesEde3Cbc)
-//								|| alg.Equals(CmsEnvelopedDataGenerator.IdeaCbc)
-//								|| alg.Equals(CmsEnvelopedDataGenerator.Cast5Cbc))
+//							if (alg.Equals(CmsEnvelopedGenerator.DesEde3Cbc)
+//								|| alg.Equals(CmsEnvelopedGenerator.IdeaCbc)
+//								|| alg.Equals(CmsEnvelopedGenerator.Cast5Cbc))
 //							{
 //								cipherParameters = new ParametersWithIV(cipherParameters, new byte[8]);
 //							}
@@ -269,9 +269,9 @@ namespace Org.BouncyCastle.Cms
 					else
 					{
                         string alg = this.algorithm.Algorithm.Id;
-						if (alg.Equals(CmsEnvelopedDataGenerator.DesEde3Cbc)
-							|| alg.Equals(CmsEnvelopedDataGenerator.IdeaCbc)
-							|| alg.Equals(CmsEnvelopedDataGenerator.Cast5Cbc))
+						if (alg.Equals(CmsEnvelopedGenerator.DesEde3Cbc)
+							|| alg.Equals(CmsEnvelopedGenerator.IdeaCbc)
+							|| alg.Equals(CmsEnvelopedGenerator.Cast5Cbc))
 						{
 							cipherParameters = new ParametersWithIV(cipherParameters, new byte[8]);
 						}