Match IDisposable with 4.0 changes in System.Security.Cryptography
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 2 May 2011 16:14:53 +0000 (12:14 -0400)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 2 May 2011 16:14:53 +0000 (12:14 -0400)
* AsymmetricAlgorithm.cs:
* CryptoAPITransform.cs:
* DeriveBytes.cs:
* FromBase64Transform.cs:
* HashAlgorithm.cs:
* PasswordDeriveBytes.cs:
* Rfc2898DeriveBytes.cs:
* RijndaelManagedTransform.cs:
* SymmetricAlgorithm.cs:
* ToBase64Transform.cs:
Adjust changes to IDisposable wrt 4.0

mcs/class/corlib/System.Security.Cryptography/AsymmetricAlgorithm.cs
mcs/class/corlib/System.Security.Cryptography/CryptoAPITransform.cs
mcs/class/corlib/System.Security.Cryptography/DeriveBytes.cs
mcs/class/corlib/System.Security.Cryptography/FromBase64Transform.cs
mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs
mcs/class/corlib/System.Security.Cryptography/PasswordDeriveBytes.cs
mcs/class/corlib/System.Security.Cryptography/Rfc2898DeriveBytes.cs
mcs/class/corlib/System.Security.Cryptography/RijndaelManagedTransform.cs
mcs/class/corlib/System.Security.Cryptography/SymmetricAlgorithm.cs
mcs/class/corlib/System.Security.Cryptography/ToBase64Transform.cs

index b8e848a0a6a1432bd383fe80cecde05ff00e559e..5109910cb1e13e469e0ffaa45577f18965d0e105 100644 (file)
@@ -65,7 +65,11 @@ namespace System.Security.Cryptography {
                        get;
                }
 
+#if NET_4_0
+               public void Dispose ()
+#else
                void IDisposable.Dispose () 
+#endif
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now unnecessary
@@ -76,8 +80,13 @@ namespace System.Security.Cryptography {
                        Dispose (false);
                }
 
+#if NET_4_0
+               protected virtual void Dispose (bool disposing)
+               {
+               }
+#else
                protected abstract void Dispose (bool disposing);
-
+#endif
                public abstract void FromXmlString (string xmlString);
                
                public abstract string ToXmlString (bool includePrivateParameters);             
index 5b8aa7f73f56bf500b98c2c277de5c0165f95fb4..777017de58972acdf5f7817c0120e3dae9148793 100644 (file)
@@ -67,7 +67,11 @@ namespace System.Security.Cryptography {
                        get { return 0; }
                }
 
+#if NET_4_0
+               public void Dispose ()
+#else
                void IDisposable.Dispose () 
+#endif
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now unnecessary
index 87cb0161e5ae1e303e2b69d229c0287cb9db3afc..2d782fba475459c3a580a71a987516ad344b141d 100644 (file)
@@ -4,7 +4,7 @@
 // Author:\r
 //   Thomas Neidhart (tome@sbox.tugraz.at)\r
 //\r
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2005, 2011 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -31,9 +31,11 @@ using System.Runtime.InteropServices;
 namespace System.Security.Cryptography {\r
 \r
        [ComVisible (true)]
+#if NET_4_0
        public abstract class DeriveBytes : IDisposable {
-               private bool m_disposed;
-
+#else
+       public abstract class DeriveBytes {
+#endif
                protected DeriveBytes ()
                {
                }\r
@@ -42,7 +44,10 @@ namespace System.Security.Cryptography {
 \r
                public abstract void Reset ();
 
-               void IDisposable.Dispose()
+#if NET_4_0
+               private bool m_disposed;
+
+               public void Dispose ()
                {
                        Dispose(true);
                }
@@ -56,5 +61,6 @@ namespace System.Security.Cryptography {
                                m_disposed = true;
                        }
                }
+#endif
        }\r
 }\r
index a8c3e89e3fe882b33606bc486f4ef4cad571a181..bf4150c57d1e404e332ab54d4348388f60c5b90b 100644 (file)
@@ -88,7 +88,11 @@ namespace System.Security.Cryptography {
                        Dispose (true);
                }
 
+#if NET_4_0
+               public void Dispose ()
+#else
                void IDisposable.Dispose () 
+#endif
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now unnecessary
index b8aac3a7678923528107223e15a9f3f30222d77c..8d76956973635893607057d86d32164345d2a5d8 100644 (file)
@@ -153,7 +153,11 @@ namespace System.Security.Cryptography {
                        get { return 1; }
                }
 
+#if NET_4_0
+               public void Dispose ()
+#else
                void IDisposable.Dispose () 
+#endif
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now unnecessary
index 641c149de12ef2618c2399ccfd7c5b1e9307be33..66d18aeb0ec35bfeb16d3602f41c275f41e97b74 100644 (file)
@@ -112,6 +112,13 @@ public class PasswordDeriveBytes : DeriveBytes {
 
        ~PasswordDeriveBytes () 
        {
+#if NET_4_0
+               Dispose (false);
+       }
+
+       protected override void Dispose (bool disposing)
+       {
+#endif
                // zeroize buffer
                if (initial != null) {
                        Array.Clear (initial, 0, initial.Length);
@@ -119,6 +126,9 @@ public class PasswordDeriveBytes : DeriveBytes {
                }
                // zeroize temporary password storage
                Array.Clear (password, 0, password.Length);
+#if NET_4_0
+               base.Dispose (disposing);
+#endif
        }
 
        private void Prepare (string strPassword, byte[] rgbSalt, string strHashName, int iterations) 
index 17c7fc9aec5770a2fbed211f9b7a048a9c293ba6..5169358df64febc625381fcc94ff152b1bbed2d3 100644 (file)
@@ -180,6 +180,15 @@ namespace System.Security.Cryptography {
                        _pos = 0;
                        _f = 0;
                }
+#if NET_4_0
+               protected override void Dispose (bool disposing)
+               {
+                       Array.Clear (_buffer, 0, _buffer.Length);
+                       Array.Clear (_salt, 0, _salt.Length);
+                       _hmac.Clear ();
+                       base.Dispose (disposing);
+               }
+#endif
        } 
 }
 
index ccc4da333b8d2e36360639019b09d25d5c67775c..4191343d523d8d923a2334f35461598fb1499065 100644 (file)
@@ -79,7 +79,11 @@ namespace System.Security.Cryptography {
                {
                }
 
-               void System.IDisposable.Dispose () 
+#if NET_4_0
+               public void Dispose ()
+#else
+               void IDisposable.Dispose () 
+#endif
                {
                        _st.Clear ();
                }
index 2ee27a7fabcbdea3b57f808622b05abb2c89b935..f915376048f1f79d35fc9c53bb8ed365580c26e1 100644 (file)
@@ -70,7 +70,12 @@ namespace System.Security.Cryptography {
                        Dispose (false);
                }
 #endif
+
+#if NET_4_0
+               public void Dispose ()
+#else
                void IDisposable.Dispose () 
+#endif
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now unnecessary
index ce5a95e8763309608ba09cd82bbf87c994e767e4..0f0f05a54d15c8e71edf6515982097ca6b984752 100644 (file)
@@ -69,7 +69,11 @@ namespace System.Security.Cryptography {
                        Dispose (true);
                }
 
+#if NET_4_0
+               public void Dispose ()
+#else
                void IDisposable.Dispose () 
+#endif
                {
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now unnecessary