2005-02-10 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 10 Feb 2005 16:09:34 +0000 (16:09 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 10 Feb 2005 16:09:34 +0000 (16:09 -0000)
* DSA.cs: Weekly fix to case where DSAParameters.Counter is 0 :-(
A new unit test was added for this specific case so it's hopefully
the last fix for this. Fixed exception reporting to match NET_2_0.

svn path=/trunk/mcs/; revision=40406

mcs/class/corlib/System.Security.Cryptography/ChangeLog
mcs/class/corlib/System.Security.Cryptography/DSA.cs

index 8e11ddd2dc912dd9245fe9d6b8665bebbffd24d6..61311cc0be61d426800590f71137fb83ec2a8c18 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-10  Sebastien Pouliot  <sebastien@ximian.com> 
+
+       * DSA.cs: Weekly fix to case where DSAParameters.Counter is 0 :-(
+       A new unit test was added for this specific case so it's hopefully
+       the last fix for this. Fixed exception reporting to match NET_2_0.
+
 2005-01-30  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * DSA.cs: Really fixed case where DSAParameters.Counter is 0.
index be07e9a4f7af538cd53d1e9b2f88924e7601877c..0f10dc8b909ecf04ae46dde63b3a115dfc33a0c4 100755 (executable)
@@ -156,14 +156,13 @@ namespace System.Security.Cryptography {
 
                                        sb.Append ("<PgenCounter>");
                                        // the number of bytes is important (no matter == 0x00)
-                                       byte[] inArr = BitConverterLE.GetBytes (dsaParams.Counter);
-                                       int l = inArr.Length;
-                                       if (l > 0) {
+                                       if (dsaParams.Counter != 0) {
+                                               byte[] inArr = BitConverterLE.GetBytes (dsaParams.Counter);
+                                               int l = inArr.Length;
                                                while (inArr[l-1] == 0x00)
                                                        l--;
-                                               byte[] c = new byte [l];
-                                               Buffer.BlockCopy (inArr, 0, c, 0, l);
-                                               sb.Append (Convert.ToBase64String (c));
+
+                                               sb.Append (Convert.ToBase64String (inArr, 0, l));
                                        } else {
                                                sb.Append ("AA==");     // base64 encoded 0
                                        }
@@ -176,8 +175,12 @@ namespace System.Security.Cryptography {
                                        sb.Append ("</X>");
                                }
                                else if (includePrivateParameters) {
+#if NET_2_0
+                                       throw new ArgumentNullException ("X");
+#else
                                        throw new CryptographicException (
                                                Locale.GetText ("Missing private key informations"));
+#endif
                                }
 
                                sb.Append ("</DSAKeyValue>");