[Mono-bugs] [Bug 78647][Nor] Changed - HashAlgorithm.TransformBlock can break if destination offset is different than source (on same buffer)

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Wed Jun 14 15:04:33 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien at ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=78647

--- shadow/78647	2006-06-14 14:31:42.000000000 -0400
+++ shadow/78647.tmp.14948	2006-06-14 15:04:33.000000000 -0400
@@ -1,12 +1,12 @@
 Bug#: 78647
 Product: Mono: Class Libraries
 Version: 1.1
 OS: All
 OS Details: 
-Status: NEW   
+Status: ASSIGNED   
 Resolution: 
 Severity: Unknown
 Priority: Normal
 Component: CORLIB
 AssignedTo: sebastien at ximian.com                            
 ReportedBy: sebastien at ximian.com               
@@ -34,6 +34,65 @@
 Always.
 
 Additional Information:
 * See
 http://lists.ximian.com/archives/public/mono-patches/2006-June/075590.html
 * Not sure if it only affects some, or all, hash algorithms (found on MD5)
+
+------- Additional Comments From sebastien at ximian.com  2006-06-14 15:04 -------
+It's a common problem in all hash algorithm.
+
+using System;
+using System.Security.Cryptography;
+
+class Program {
+
+	static void Main (string[] args)
+	{
+		string algo = args.Length > 0 ? args[0] : "MD5";
+		bool bug = args.Length > 1 && args [1] == "nobug" ? false : true;
+
+		byte[] buffer = new byte [256];
+		for (int i = 0; i < buffer.Length; i++)
+			buffer [i] = (byte) i;
+
+		using (HashAlgorithm hash = HashAlgorithm.Create (algo)) {
+			// ok
+			hash.TransformBlock (buffer, 0, 64, buffer, 0);
+			// bad - we rewrite the beginning of the buffer
+			hash.TransformBlock (buffer, 64, 128, buffer, bug ? 0 : 64);
+			// ok
+			hash.TransformFinalBlock (buffer, 192, 64);
+			Console.WriteLine ("{0}: {1}", algo, BitConverter.ToString
+(hash.Hash));
+		}
+	}
+}
+
+poupou at pollux:~/src/bugzilla> mcs 78647.cs
+poupou at pollux:~/src/bugzilla> mono 78647.exe
+MD5: EF-B3-9B-DD-65-CB-FA-82-FC-9C-6A-C4-CA-D7-8E-24
+poupou at pollux:~/src/bugzilla> mono 78647.exe MD5 nobug
+MD5: E2-C8-65-DB-41-62-BE-D9-63-BF-AA-9E-F6-AC-18-F0
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA1
+SHA1: 49-46-88-03-E4-09-01-5D-E5-B0-86-D8-6A-73-B2-D2-F9-ED-27-B1
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA1 nobug
+SHA1: 49-16-D6-BD-B7-F7-8E-68-03-69-8C-AB-32-D1-58-6E-A4-57-DF-C8
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA256
+SHA256:
+5C-68-4C-3F-B0-25-4D-ED-E6-E3-DA-47-2E-0D-1F-3D-30-17-4D-F5-1A-D2-7D-BD-1C-8B-B6-6B-4A-0D-A4-6A
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA256 nobug
+SHA256:
+40-AF-F2-E9-D2-D8-92-2E-47-AF-D4-64-8E-69-67-49-71-58-78-5F-BD-1D-A8-70-E7-11-02-66-BF-94-48-80
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA384
+SHA384:
+0B-35-69-55-82-D0-CE-0F-9B-F9-27-F8-52-C2-4E-47-01-D1-84-1C-76-E7-80-4B-C1-E9-97-55-C1-28-91-12-C1-71-FE-1E-38-1D-F2-68-30-7B-DC-0D-82-FF-26-D0
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA384 nobug
+SHA384:
+FF-DA-EB-FF-65-ED-05-CF-40-0F-02-21-C4-CC-FB-4B-21-04-FB-6A-51-F8-7E-40-BE-6C-43-09-38-6B-FD-EC-28-92-E9-17-9B-34-63-23-31-A5-95-92-73-7D-B5-C5
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA512
+SHA512:
+83-A1-E6-BB-DF-54-14-E3-06-5E-10-06-53-C3-42-0D-BB-7E-CA-B1-1E-A6-1C-30-6F-F4-1E-E1-39-A0-00-59-D4-F5-49-73-E1-36-37-64-6B-1D-98-4E-C3-DA-7F-75-55-F9-B4-BF-9F-CC-5C-89-AE-F5-DD-C2-95-5C-15-45
+poupou at pollux:~/src/bugzilla> mono 78647.exe SHA512 nobug
+SHA512:
+1E-7B-80-BC-8E-DC-55-2C-8F-EE-B2-78-0E-11-14-77-E5-BC-70-46-5F-AC-1A-77-B2-9B-35-98-0C-3F-0C-E4-A0-36-A6-C9-46-20-36-82-4B-D5-68-01-E6-2A-F7-E9-FE-BA-5C-22-ED-8A-5A-F8-77-BF-7D-E1-17-DC-AC-6D
+


More information about the mono-bugs mailing list