Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[mono.git] / mcs / class / System.Core / System.Security.Cryptography / Aes.cs
index eaee476a5005b273ce30f724f51c3036ed336663..cb2ddbc93fab41b52784ebb551f562efa1c2856b 100644 (file)
@@ -31,7 +31,7 @@
 //
 
 // Since 4.0 (both FX and SL) this type is defined in mscorlib - before 4.0 it was in System.Core.dll
-#if (INSIDE_CORLIB && (NET_4_0 || BOOTSTRAP_NET_4_0 || MOONLIGHT)) || (!INSIDE_CORLIB && !NET_4_0 && !BOOTSTRAP_NET_4_0 && !MOONLIGHT)
+#if (INSIDE_CORLIB && (NET_4_0 || MOONLIGHT || MOBILE)) || (!INSIDE_CORLIB && !NET_4_0 && !MOONLIGHT && !MOBILE)
 \r
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
@@ -44,10 +44,10 @@ namespace System.Security.Cryptography {
 
 #if INSIDE_CORLIB
        // since 4.0 (both FX and SL) this type now resides inside mscorlib.dll and link back to System.Core.dll\r
-       #if MOONLIGHT
+       #if MOONLIGHT || MOBILE
        // version has not changed between SL3 (System.Core) and SL4
        [TypeForwardedFrom (Consts.AssemblySystem_Core)]
-       #elif NET_4_0 || BOOTSTRAP_NET_4_0
+       #elif NET_4_0
        // use 3.5 version
        [TypeForwardedFrom ("System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
        #endif
@@ -56,19 +56,29 @@ namespace System.Security.Cryptography {
 
                public static new Aes Create () \r
                {\r
+#if FULL_AOT_RUNTIME\r
+                       // The Aes base class was moved from System.Core to mscorlib - so we can't just return a new AesCryptoServiceProvider instance\r
+                       // note: the linker is aware of this condition\r
+                       return (Aes) Activator.CreateInstance (Type.GetType ("System.Security.Cryptography.AesCryptoServiceProvider, " + Consts.AssemblySystem_Core));\r
+#elif MOBILE\r
+                       // there was a mixup in the MOBILE profile, to be compatible with Silverlight it's\r
+                       // AesManaged that should have been provided, not AesCryptoServiceProvider\r
+                       return Create ("System.Security.Cryptography.AesCryptoServiceProvider, " + Consts.AssemblySystem_Core);\r
+#else\r
                        return Create ("System.Security.Cryptography.AesManaged, " + Consts.AssemblySystem_Core);\r
+#endif\r
                }\r
 \r
-               public static new Aes Create (string algName) \r
+               public static new Aes Create (string algorithmName) \r
                {\r
-                       return (Aes) CryptoConfig.CreateFromName (algName);\r
+                       return (Aes) CryptoConfig.CreateFromName (algorithmName);\r
                }\r
 
                protected Aes ()
                {\r
                        KeySizeValue = 256;\r
                        BlockSizeValue = 128;
-#if !NET_2_1
+#if !MOONLIGHT
                        // Silverlight 2.0 only supports CBC mode (i.e. no feedback)\r
                        FeedbackSizeValue = 128;
 #endif\r