[Mono-bugs] [Bug 69036][Nor] New - An System.ArgumentException appears when execute any assembly that use PasswordDeriveBytes class
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Tue, 2 Nov 2004 15:18:27 -0500 (EST)
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 gonzaloantonio@gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=69036
--- shadow/69036 2004-11-02 15:18:27.000000000 -0500
+++ shadow/69036.tmp.25100 2004-11-02 15:18:27.000000000 -0500
@@ -0,0 +1,89 @@
+Bug#: 69036
+Product: Mono: Class Libraries
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: System.Security
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: gonzaloantonio@gmail.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: An System.ArgumentException appears when execute any assembly that use PasswordDeriveBytes class
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+
+Steps to reproduce the problem:
+1. the source: crypto.cs
+
+using System;
+using System.IO;
+using System.Security.Cryptography;
+
+class Foo
+{
+ public static void Main( string[] args )
+ {
+ Console.WriteLine( Encrypt("go mono!!!", "12345678password") );
+ }
+
+
+ static string Encrypt( string clearstring, string password )
+ {
+ byte[] clearbytes = System.Text.Encoding.UTF8.GetBytes( clearstring );
+
+ PasswordDeriveBytes pdb = new PasswordDeriveBytes( password,
+ new byte[]{0x47, 0x6F, 0x6E, 0x7A, 0x61, 0x6C, 0x6F, 0x20, 0x53, 0x6F,
+0x73, 0x61} );
+
+ return Convert.ToBase64String( Encrypt(clearbytes, pdb.GetBytes(32),
+pdb.GetBytes(16)) );
+ }
+
+ static byte[] Encrypt( byte[] clearbytes, byte[] key, byte[] iv )
+ {
+ Rijndael rijndael = Rijndael.Create();
+ rijndael.Key = key;
+ rijndael.IV = iv;
+
+ MemoryStream mem = new MemoryStream();
+ CryptoStream cs = new CryptoStream( mem, rijndael.CreateEncryptor(),
+CryptoStreamMode.Write );
+ cs.Write( clearbytes, 0, clearbytes.Length );
+ cs.Flush();
+ cs.Close();
+
+ return mem.ToArray();
+ }
+}
+
+2. to compile: mcs crypto.cs
+3. to execute: mono crypto.exe
+
+Actual Results:
+
+Unhandled Exception: System.ArgumentException: Offset and length were out
+of bounds for the array or count is greater thanthe number of elements from
+index to the end of the source collection.
+in <0x001b5> System.Buffer:BlockCopy (System.Array,int,System.Array,int,int)
+in <0x002a5> System.Security.Cryptography.PasswordDeriveBytes:GetBytes (int)
+in <0x000ad> Foo:Encrypt (string,string)
+in <0x00014> Foo:Main (string[])
+
+Expected Results:
+
+ Encrypt the string.
+
+How often does this happen?
+Every time
+
+Additional Information:
+The class work fine on .Net Framework.