[docs] Import of Microsoft BCL Documentation.
[mono.git] / mcs / class / corlib / System.Security.Cryptography / DSACryptoServiceProvider.cs
index 41951ff66ccf22575abf1a1ddddf321141ed3f34..3d72d23a7bdd8f080f86f4fea135004791588510 100644 (file)
@@ -31,8 +31,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if !MOONLIGHT
-
 using System.IO;
 using System.Globalization;
 using System.Runtime.InteropServices;
@@ -65,7 +63,7 @@ namespace System.Security.Cryptography {
                // least in the unit tests).
 
                public DSACryptoServiceProvider ()
-                       : this (1024, null)
+                       : this (1024)
                {
                }
 
@@ -75,11 +73,19 @@ namespace System.Security.Cryptography {
                }
 
                public DSACryptoServiceProvider (int dwKeySize)
-                       : this (dwKeySize, null)
                {
+                       Common (dwKeySize, false);
                }
 
                public DSACryptoServiceProvider (int dwKeySize, CspParameters parameters)
+               {
+                       bool has_parameters = parameters != null;
+                       Common (dwKeySize, has_parameters);
+                       if (has_parameters)
+                               Common (parameters);
+               }
+
+               void Common (int dwKeySize, bool parameters) 
                {
                        LegalKeySizesValue = new KeySizes [1];
                        LegalKeySizesValue [0] = new KeySizes (512, 1024, 64);
@@ -89,23 +95,24 @@ namespace System.Security.Cryptography {
                        dsa = new DSAManaged (dwKeySize);
                        dsa.KeyGenerated += new DSAManaged.KeyGeneratedEventHandler (OnKeyGenerated);
 
-                       persistKey = (parameters != null);
-                       if (parameters == null) {
-                               parameters = new CspParameters (PROV_DSS_DH);
-#if NET_1_1
-                               if (useMachineKeyStore)
-                                       parameters.Flags |= CspProviderFlags.UseMachineKeyStore;
-#endif
-                               store = new KeyPairPersistence (parameters);
-                               // no need to load - it cannot exists
-                       }
-                       else {
-                               store = new KeyPairPersistence (parameters);
-                               store.Load ();
-                               if (store.KeyValue != null) {
-                                       persisted = true;
-                                       this.FromXmlString (store.KeyValue);
-                               }
+                       persistKey = parameters;
+                       if (parameters)
+                               return;
+
+                       var p = new CspParameters (PROV_DSS_DH);
+                       if (useMachineKeyStore)
+                               p.Flags |= CspProviderFlags.UseMachineKeyStore;
+                       store = new KeyPairPersistence (p);
+                       // no need to load - it cannot exists
+               }
+
+               void Common (CspParameters parameters)
+               {
+                       store = new KeyPairPersistence (parameters);
+                       store.Load ();
+                       if (store.KeyValue != null) {
+                               persisted = true;
+                               this.FromXmlString (store.KeyValue);
                        }
                }
 
@@ -137,14 +144,12 @@ namespace System.Security.Cryptography {
                        get { return "http://www.w3.org/2000/09/xmldsig#dsa-sha1"; }
                }
 
-#if NET_1_1
-               private static bool useMachineKeyStore = false;
+               private static bool useMachineKeyStore;
 
                public static bool UseMachineKeyStore {
                        get { return useMachineKeyStore; }
                        set { useMachineKeyStore = value; }
                }
-#endif
 
                public override DSAParameters ExportParameters (bool includePrivateParameters) 
                {
@@ -297,6 +302,3 @@ namespace System.Security.Cryptography {
                }
        }
 }
-
-#endif
-