fix-38054
[mono.git] / mcs / class / corlib / Test / System.Security.Cryptography / RSACryptoServiceProviderTest.cs
index 56f9a9be336792de7e413077cd16fe66c94338ef..c9011cb41f6f9a37736eb9d0ba9e89d39e203b67 100644 (file)
@@ -420,7 +420,7 @@ public class RSACryptoServiceProviderTest {
                rsa.VerifyHash (hash, "1.3.14.3.2.26", null);
        }
 
-#if !NET_2_1
+#if !MOBILE
        [Test]
        [Category ("NotWorking")]
        public void ImportDisposed ()
@@ -843,6 +843,20 @@ public class RSACryptoServiceProviderTest {
                rsa.ToXmlString (true);
        }
 
+       [Test]
+       [ExpectedException (typeof (CryptographicException))]
+       public void ExportWithoutCRT_2 () 
+       {
+               try {
+                       rsa = new RSACryptoServiceProvider ();
+                       rsa.FromXmlString (MonoXml384woCRT);
+               }
+               catch {
+               }
+               // exception is HERE!
+               rsa.ExportParameters (true);
+       }
+
        // Validate that we can sign with every keypair and verify the signature
        // With Windows this means that we can use Mono keypairs to sign and verify.
        // For Mono this doesn't mean much.
@@ -1147,7 +1161,7 @@ public class RSACryptoServiceProviderTest {
                Assert.IsNotNull (r.Decrypt (bytes, true));
        }
 
-#if !NET_2_1
+#if !MOBILE
        [Test]
        [Category ("NotWorking")]
        public void CspKeyContainerInfo_NewKeypair ()
@@ -1389,6 +1403,16 @@ public class RSACryptoServiceProviderTest {
                rsa = new RSACryptoServiceProvider (minKeySize);
                rsa.ImportCspBlob (blob);
        }
+
+       [Test] //bug 38054
+       public void NonExportableKeysAreNonExportable ()
+       {
+               var cspParams = new CspParameters();
+               cspParams.KeyContainerName = "TestRSAKey";
+               cspParams.Flags = CspProviderFlags.UseNonExportableKey;
+               var rsa = new RSACryptoServiceProvider(cspParams);
+               Assert.Throws<CryptographicException>(() => rsa.ExportParameters(true));
+       }
 }
 
 }