Merge pull request #487 from mayerwin/patch-1
[mono.git] / mcs / class / corlib / System.Security.Cryptography / HashAlgorithm.cs
index 91b7f0f0a20d0bda63a7832a2896c267f8c46b16..07074f8aef3ee6b3be94a8203be37ffd3759ca31 100644 (file)
@@ -1,5 +1,5 @@
 //
-// System.Security.Cryptography HashAlgorithm Class implementation
+// System.Security.Cryptography.HashAlgorithm.cs
 //
 // Authors:
 //     Matthew S. Ford (Matthew.S.Ford@Rose-Hulman.Edu)
@@ -35,16 +35,10 @@ using System.Runtime.InteropServices;
 
 namespace System.Security.Cryptography {
 
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public abstract class HashAlgorithm : ICryptoTransform {
 
-#if NET_2_0
                protected internal byte[] HashValue;
-#else
-               protected byte[] HashValue;
-#endif
                protected int HashSizeValue;
                protected int State;
                private bool disposed;
@@ -68,12 +62,12 @@ namespace System.Security.Cryptography {
                        Dispose (true);
                }
 
-               public byte[] ComputeHash (byte[] input
+               public byte[] ComputeHash (byte[] buffer
                {
-                       if (input == null)
-                               throw new ArgumentNullException ("input");
+                       if (buffer == null)
+                               throw new ArgumentNullException ("buffer");
 
-                       return ComputeHash (input, 0, input.Length);
+                       return ComputeHash (buffer, 0, buffer.Length);
                }
 
                public byte[] ComputeHash (byte[] buffer, int offset, int count) 
@@ -118,7 +112,11 @@ namespace System.Security.Cryptography {
        
                public static HashAlgorithm Create () 
                {
+#if FULL_AOT_RUNTIME
+                       return new System.Security.Cryptography.SHA1CryptoServiceProvider ();
+#else
                        return Create ("System.Security.Cryptography.HashAlgorithm");
+#endif
                }
        
                public static HashAlgorithm Create (string hashName)
@@ -136,7 +134,7 @@ namespace System.Security.Cryptography {
                        }
                }
        
-               protected abstract void HashCore (byte[] rgb, int start, int size);
+               protected abstract void HashCore (byte[] array, int ibStart, int cbSize);
 
                protected abstract byte[] HashFinal ();
 
@@ -159,7 +157,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
@@ -183,20 +185,12 @@ namespace System.Security.Cryptography {
 
                        if (outputBuffer != null) {
                                if (outputOffset < 0) {
-#if NET_2_0
                                        throw new ArgumentOutOfRangeException ("outputOffset", "< 0");
-#else
-                                       throw new IndexOutOfRangeException ("outputBuffer");
-#endif
                                }
                                // ordered to avoid possible integer overflow
                                if (outputOffset > outputBuffer.Length - inputCount) {
-#if NET_2_0
                                        throw new ArgumentException ("outputOffset + inputCount", 
                                                Locale.GetText ("Overflow"));
-#else
-                                       throw new IndexOutOfRangeException ("outputBuffer");
-#endif
                                }
                        }