Author: spouliot
Date: 2006-12-11 15:39:39 -0500 (Mon, 11 Dec 2006)
New Revision: 69362

Modified:
   trunk/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog
   trunk/mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs
Log:
2006-12-11  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * PKCS12.cs: Fix DSA certificates (with parameters) and don't throw
        an exception in the case where parameters aren't part of the 
        certificate. This fix makes all 405 PKCS#12 test cases from PKITS 
        works using Mono :).



Modified: trunk/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog  2006-12-11 
20:39:17 UTC (rev 69361)
+++ trunk/mcs/class/Mono.Security/Mono.Security.X509/ChangeLog  2006-12-11 
20:39:39 UTC (rev 69362)
@@ -1,3 +1,10 @@
+2006-12-11  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * PKCS12.cs: Fix DSA certificates (with parameters) and don't throw
+       an exception in the case where parameters aren't part of the 
+       certificate. This fix makes all 405 PKCS#12 test cases from PKITS 
+       works using Mono :).
+
 2006-12-06  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * X501Name.cs: Add decoding of RFC3280 mandatory and optional 

Modified: trunk/mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs
===================================================================
--- trunk/mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs  2006-12-11 
20:39:17 UTC (rev 69361)
+++ trunk/mcs/class/Mono.Security/Mono.Security.X509/PKCS12.cs  2006-12-11 
20:39:39 UTC (rev 69362)
@@ -671,13 +671,32 @@
                        return result;
                }
 
+               private DSAParameters GetExistingParameters (out bool found)
+               {
+                       foreach (X509Certificate cert in Certificates) {
+                               // FIXME: that won't work if parts of the 
parameters are missing
+                               if (cert.KeyAlgorithmParameters != null) {
+                                       DSA dsa = cert.DSA;
+                                       if (dsa != null) {
+                                               found = true;
+                                               return dsa.ExportParameters 
(false);
+                                       }
+                               }
+                       }
+                       found = false;
+                       return new DSAParameters ();
+               }
+
                private void AddPrivateKey (PKCS8.PrivateKeyInfo pki) 
                {
                        byte[] privateKey = pki.PrivateKey;
                        switch (privateKey [0]) {
                                case 0x02:
-                                       DSAParameters p = new DSAParameters (); 
// FIXME
-                                       _keyBags.Add 
(PKCS8.PrivateKeyInfo.DecodeDSA (privateKey, p));
+                                       bool found;
+                                       DSAParameters p = GetExistingParameters 
(out found);
+                                       if (found) {
+                                               _keyBags.Add 
(PKCS8.PrivateKeyInfo.DecodeDSA (privateKey, p));
+                                       }
                                        break;
                                case 0x30:
                                        _keyBags.Add 
(PKCS8.PrivateKeyInfo.DecodeRSA (privateKey));

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to