2007-05-08 Randolph Chung <tausq@debian.org>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 8 May 2007 17:54:58 +0000 (17:54 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 8 May 2007 17:54:58 +0000 (17:54 -0000)
* DSAManaged.cs: Do not reject the input if only Y is null.
Fixes #81558. [small edits from Sebastien]

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

mcs/class/corlib/Mono.Security.Cryptography/ChangeLog
mcs/class/corlib/Mono.Security.Cryptography/DSAManaged.cs

index 22909774a3427442a280189d950e2c29a15d918d..ac047a327c48e8d416e16b9767a8179cab575e1b 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-08  Randolph Chung  <tausq@debian.org>
+
+       * DSAManaged.cs: Do not reject the input if only Y is null.
+       Fixes #81558. [small edits from Sebastien]
+
 2007-03-22  Sebastien Pouliot  <sebastien@ximian.com>
 
        * SymmetricTransform.cs: Before 2.0 an IndexOutOfRangeException was 
index ca29b42fc7845f3415fb4c6a99f4c09aff63be45..d8679bc1904edbe810be9540ae5c9bfd00ac481b 100644 (file)
@@ -297,21 +297,28 @@ namespace Mono.Security.Cryptography {
                public override void ImportParameters (DSAParameters parameters) 
                {
                        if (m_disposed)
-                               throw new ObjectDisposedException ("");
+                               throw new ObjectDisposedException (Locale.GetText ("Keypair was disposed"));
 
                        // if missing "mandatory" parameters
-                       if ((parameters.P == null) || (parameters.Q == null) || (parameters.G == null) || (parameters.Y == null))
-                               throw new CryptographicException ();
+                       if ((parameters.P == null) || (parameters.Q == null) || (parameters.G == null))
+                               throw new CryptographicException (Locale.GetText ("Missing mandatory DSA parameters (P, Q or G)."));
+                       // We can calculate Y from X, but both can't be missing
+                       if ((parameters.X == null) && (parameters.Y == null))
+                               throw new CryptographicException (Locale.GetText ("Missing both public (Y) and private (X) keys."));
 
                        p = new BigInteger (parameters.P);
                        q = new BigInteger (parameters.Q);
                        g = new BigInteger (parameters.G);
-                       y = new BigInteger (parameters.Y);
                        // optional parameter - private key
                        if (parameters.X != null)
                                x = new BigInteger (parameters.X);
                        else
                                x = null;
+                       // we can calculate Y from X if required
+                       if (parameters.Y != null)
+                               y = new BigInteger (parameters.Y);
+                       else
+                               y = g.ModPow (x, p);
                        // optional parameter - pre-computation
                        if (parameters.J != null) {
                                j = new BigInteger (parameters.J);
@@ -334,7 +341,7 @@ namespace Mono.Security.Cryptography {
                public override byte[] CreateSignature (byte[] rgbHash) 
                {
                        if (m_disposed)
-                               throw new ObjectDisposedException ("");
+                               throw new ObjectDisposedException (Locale.GetText ("Keypair was disposed"));
 
                        if (rgbHash == null)
                                throw new ArgumentNullException ("rgbHash");