Author: spouliot
Date: 2006-06-15 15:15:17 -0400 (Thu, 15 Jun 2006)
New Revision: 61765

Modified:
   trunk/mcs/class/corlib/System.Security.Cryptography/ChangeLog
   trunk/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs
Log:
2006-06-15  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * HashAlgorithm.cs: Changed the order of BlockCopy + HashCore to
        HashCore + BlockCopy. Fx 2.0 now allows using a null output buffer
        (without exception) while previous 1.x versions crashed the runtime
        (mono won't crash the runtime, so we always do like 2.0).



Modified: trunk/mcs/class/corlib/System.Security.Cryptography/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.Security.Cryptography/ChangeLog       
2006-06-15 18:46:29 UTC (rev 61764)
+++ trunk/mcs/class/corlib/System.Security.Cryptography/ChangeLog       
2006-06-15 19:15:17 UTC (rev 61765)
@@ -1,3 +1,10 @@
+2006-06-15  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * HashAlgorithm.cs: Changed the order of BlockCopy + HashCore to
+       HashCore + BlockCopy. Fx 2.0 now allows using a null output buffer
+       (without exception) while previous 1.x versions crashed the runtime
+       (mono won't crash the runtime, so we always do like 2.0).
+
 2006-05-30  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * AsymmetricKeyExchangeDeformatter.cs: Under 2.0 the ctor is 

Modified: trunk/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs
===================================================================
--- trunk/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs        
2006-06-15 18:46:29 UTC (rev 61764)
+++ trunk/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs        
2006-06-15 19:15:17 UTC (rev 61765)
@@ -164,13 +164,13 @@
                        Dispose (true);
                        GC.SuppressFinalize (this);  // Finalization is now 
unnecessary
                }
-               
+
+               // LAMESPEC: outputBuffer is optional in 2.0 (i.e. can be null).
+               // However a null outputBuffer would throw a 
ExecutionEngineException under 1.x
                public int TransformBlock (byte[] inputBuffer, int inputOffset, 
int inputCount, byte[] outputBuffer, int outputOffset) 
                {
                        if (inputBuffer == null)
                                throw new ArgumentNullException ("inputBuffer");
-                       if (outputBuffer == null)
-                               throw new ArgumentNullException 
("outputBuffer");
 
                        if (inputOffset < 0)
                                throw new ArgumentOutOfRangeException 
("inputOffset", "< 0");
@@ -180,27 +180,31 @@
                        // ordered to avoid possible integer overflow
                        if ((inputOffset < 0) || (inputOffset > 
inputBuffer.Length - inputCount))
                                throw new ArgumentException ("inputBuffer");
-                       if (outputOffset < 0) {
+
+                       if (outputBuffer != null) {
+                               if (outputOffset < 0) {
 #if NET_2_0
-                               throw new ArgumentOutOfRangeException 
("outputOffset", "< 0");
+                                       throw new ArgumentOutOfRangeException 
("outputOffset", "< 0");
 #else
-                               throw new IndexOutOfRangeException 
("outputBuffer");
+                                       throw new IndexOutOfRangeException 
("outputBuffer");
 #endif
-                       }
-                       if (outputOffset > outputBuffer.Length - inputCount) {
+                               }
+                               // ordered to avoid possible integer overflow
+                               if (outputOffset > outputBuffer.Length - 
inputCount) {
 #if NET_2_0
-                               throw new ArgumentException ("outputOffset + 
inputCount", 
-                                       Locale.GetText ("Overflow"));
+                                       throw new ArgumentException 
("outputOffset + inputCount", 
+                                               Locale.GetText ("Overflow"));
 #else
-                               throw new IndexOutOfRangeException 
("outputBuffer");
+                                       throw new IndexOutOfRangeException 
("outputBuffer");
 #endif
+                               }
                        }
-                       // ordered to avoid possible integer overflow
 
-                       // note: other exceptions are handled by 
Buffer.BlockCopy
-                       Buffer.BlockCopy (inputBuffer, inputOffset, 
outputBuffer, outputOffset, inputCount);
                        HashCore (inputBuffer, inputOffset, inputCount);
 
+                       if (outputBuffer != null)
+                               Buffer.BlockCopy (inputBuffer, inputOffset, 
outputBuffer, outputOffset, inputCount);
+
                        return inputCount;
                }
        

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to