Merge pull request #505 from roji/shutdown_flow
[mono.git] / mcs / class / corlib / System.Security.Cryptography / RSAPKCS1KeyExchangeFormatter.cs
index 8214690d439b410146c08f0abfe92680be4d3b73..b3d9e27dd00345f1f281d295e270822c994963c2 100644 (file)
@@ -36,9 +36,7 @@ namespace System.Security.Cryptography {
        // LAMESPEC: There seems no way to select a hash algorithm. The default 
        // algorithm, is SHA1 because the class use the PKCS1MaskGenerationMethod -
        // which default to SHA1.
-#if NET_2_0
        [ComVisible (true)]
-#endif
        public class RSAPKCS1KeyExchangeFormatter: AsymmetricKeyExchangeFormatter
        {
                private RSA rsa;
@@ -50,7 +48,7 @@ namespace System.Security.Cryptography {
        
                public RSAPKCS1KeyExchangeFormatter (AsymmetricAlgorithm key)
                {
-                       SetKey (key);
+                       SetRSAKey (key);
                }
        
                public RandomNumberGenerator Rng {
@@ -66,12 +64,10 @@ namespace System.Security.Cryptography {
                {
                        if (rgbData == null)
                                throw new ArgumentNullException ("rgbData");
-#if NET_2_0
                        if (rsa == null) {
                                string msg = Locale.GetText ("No RSA key specified");
                                throw new CryptographicUnexpectedOperationException (msg);
                        }
-#endif
                        if (random == null)
                                random = RandomNumberGenerator.Create ();  // create default
                        return PKCS1.Encrypt_v15 (rsa, random, rgbData);
@@ -82,10 +78,17 @@ namespace System.Security.Cryptography {
                        // documentation says that symAlgType is not used !?!
                        return CreateKeyExchange (rgbData);
                }
-       
-               public override void SetKey (AsymmetricAlgorithm key)
+               
+               private void SetRSAKey (AsymmetricAlgorithm key)
                {
+                       if (key == null)
+                               throw new ArgumentNullException ("key");
                        rsa = (RSA) key;
                }
+                       
+               public override void SetKey (AsymmetricAlgorithm key)
+               {
+                       SetRSAKey (key);
+               }
        }
 }