Author: spouliot
Date: 2006-06-16 09:25:14 -0400 (Fri, 16 Jun 2006)
New Revision: 61797
Modified:
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/ChangeLog
branches/mono-1-1-13/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:
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/ChangeLog
===================================================================
---
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/ChangeLog
2006-06-16 13:18:06 UTC (rev 61796)
+++
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/ChangeLog
2006-06-16 13:25:14 UTC (rev 61797)
@@ -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).
+
2005-12-15 Sebastien Pouliot <[EMAIL PROTECTED]>
* SymmetricAlgorithm.cs: Changing (not setting) BlockSize must
Modified:
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs
===================================================================
---
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs
2006-06-16 13:18:06 UTC (rev 61796)
+++
branches/mono-1-1-13/mcs/class/corlib/System.Security.Cryptography/HashAlgorithm.cs
2006-06-16 13:25:14 UTC (rev 61797)
@@ -7,7 +7,7 @@
//
// Copyright 2001 by Matthew S. Ford.
// Portions (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004-2006 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
@@ -40,7 +40,11 @@
#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;
@@ -160,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");
@@ -176,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