Example #1
0
		public void Bug18482 ()
		{
			RSAManaged privateRsa = new RSAManaged ();
			privateRsa.FromXmlString (MonoXml384);
			
			var rsaParameters = privateRsa.ExportParameters (false);
			
			RSAManaged publicRsa = new RSAManaged ();
			
			//Generates a key pair with private key values
			publicRsa.ExportParameters (false);
			
			//Sets public key values and should reset private key values
			publicRsa.ImportParameters (rsaParameters);
			
			//Should export valid parameters without throwing an exception.
			publicRsa.ExportParameters (false);
		}
Example #2
0
		public void FixtureSetUp ()
		{
			rsa = new RSAManaged ();
			rsa.FromXmlString (rsaxml);
		}
Example #3
0
		public void MonoEncryptDecryptWithoutCRT () 
		{
			RSAManaged rsa = new RSAManaged ();

			rsa.FromXmlString (MonoXml384woCRT);
			EncryptDecrypt ("Mono-384-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml448woCRT);
			EncryptDecrypt ("Mono-448-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml512woCRT);
			EncryptDecrypt ("Mono-512-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml576woCRT);
			EncryptDecrypt ("Mono-576-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml640woCRT);
			EncryptDecrypt ("Mono-640-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml704woCRT);
			EncryptDecrypt ("Mono-704-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml768woCRT);
			EncryptDecrypt ("Mono-768-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml832woCRT);
			EncryptDecrypt ("Mono-832-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml896woCRT);
			EncryptDecrypt ("Mono-896-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml960woCRT);
			EncryptDecrypt ("Mono-960-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml1024woCRT);
			EncryptDecrypt ("Mono-1024-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml1536woCRT);
			EncryptDecrypt ("Mono-1536-WithoutCRT", rsa);

			rsa.FromXmlString (MonoXml2048woCRT);
			EncryptDecrypt ("Mono-2048-WithoutCRT", rsa);
		}
Example #4
0
		public void Bug79269 ()
		{
	                RSAManaged rsa = new RSAManaged ();
			rsa.FromXmlString ("<RSAKeyValue><Modulus>iSObDmmhDgrl4NiLaviFcpv4NdysBWJcqiVz3AQbPdajtXaQQ8VJdfRkixah132yKOFGCWZhHS3EuPMh8dcNwGwta2nh+m2IV6ktzI4+mZ7CSNAsmlDY0JI+H8At1vKvNArlC5jkVGuliYroJeSU/NLPLNYgspi7TtXGy9Rfug8=</Modulus><Exponent>EQ==</Exponent></RSAKeyValue>");
			Assert.IsTrue (rsa.PublicOnly, "PublicOnly");
        	        string b64 = @"YgyAhscnTTIcDeLJTZcOYYyHVxNhV6d03jeZYjq0sPMEsfCCbE/NcFyYHD9BTuiduqPplCLbGpfZIZYJ6vAP9m5z4Q9eEw79kmEFCsm8wSKEo/gKiptVpwQ78VOPrWd/wEkTTeeg2nVim3JIsTKGFlV7rKxIWQhGN9aAqgP8nZI=";
        	        byte [] bytes = Convert.FromBase64String (b64);
	                rsa.DecryptValue (bytes);
		}
Example #5
0
		public void MonoEncryptDecrypt () 
		{
			RSAManaged rsa = new RSAManaged ();

			rsa.FromXmlString (MonoXml384);
			EncryptDecrypt ("Mono-384", rsa);

			rsa.FromXmlString (MonoXml448);
			EncryptDecrypt ("Mono-448", rsa);

			rsa.FromXmlString (MonoXml512);
			EncryptDecrypt ("Mono-512", rsa);

			rsa.FromXmlString (MonoXml576);
			EncryptDecrypt ("Mono-576", rsa);

			rsa.FromXmlString (MonoXml640);
			EncryptDecrypt ("Mono-640", rsa);

			rsa.FromXmlString (MonoXml704);
			EncryptDecrypt ("Mono-704", rsa);

			rsa.FromXmlString (MonoXml768);
			EncryptDecrypt ("Mono-768", rsa);

			rsa.FromXmlString (MonoXml832);
			EncryptDecrypt ("Mono-832", rsa);

			rsa.FromXmlString (MonoXml896);
			EncryptDecrypt ("Mono-896", rsa);

			rsa.FromXmlString (MonoXml960);
			EncryptDecrypt ("Mono-960", rsa);

			rsa.FromXmlString (MonoXml1024);
			EncryptDecrypt ("Mono-1024", rsa);

			rsa.FromXmlString (MonoXml1536);
			EncryptDecrypt ("Mono-1536", rsa);

			rsa.FromXmlString (MonoXml2048);
			EncryptDecrypt ("Mono-2048", rsa);
		}
Example #6
0
		public void MonoXmlImportExportWithoutCRT () 
		{
			RSAManaged rsa = new RSAManaged ();

			rsa.FromXmlString (MonoXml384woCRT);
			Assert.AreEqual (MonoXml384woCRT, rsa.ToXmlString (true), "Mono-Xml384-WithoutCRT");

			rsa.FromXmlString (MonoXml448woCRT);
			Assert.AreEqual (MonoXml448woCRT, rsa.ToXmlString (true), "Mono-Xml448-WithoutCRT");

			rsa.FromXmlString (MonoXml512woCRT);
			Assert.AreEqual (MonoXml512woCRT, rsa.ToXmlString (true), "Mono-Xml512-WithoutCRT");

			rsa.FromXmlString (MonoXml576woCRT);
			Assert.AreEqual (MonoXml576woCRT, rsa.ToXmlString (true), "Mono-Xml576-WithoutCRT");

			rsa.FromXmlString (MonoXml640woCRT);
			Assert.AreEqual (MonoXml640woCRT, rsa.ToXmlString (true), "Mono-Xml640-WithoutCRT");

			rsa.FromXmlString (MonoXml704woCRT);
			Assert.AreEqual (MonoXml704woCRT, rsa.ToXmlString (true), "Mono-Xml704-WithoutCRT");

			rsa.FromXmlString (MonoXml768woCRT);
			Assert.AreEqual (MonoXml768woCRT, rsa.ToXmlString (true), "Mono-Xml768-WithoutCRT");

			rsa.FromXmlString (MonoXml832woCRT);
			Assert.AreEqual (MonoXml832woCRT, rsa.ToXmlString (true), "Mono-Xml832-WithoutCRT");

			rsa.FromXmlString (MonoXml896woCRT);
			Assert.AreEqual (MonoXml896woCRT, rsa.ToXmlString (true), "Mono-Xml896-WithoutCRT");

			rsa.FromXmlString (MonoXml960woCRT);
			Assert.AreEqual (MonoXml960woCRT, rsa.ToXmlString (true), "Mono-Xml960-WithoutCRT");

			rsa.FromXmlString (MonoXml1024woCRT);
			Assert.AreEqual (MonoXml1024woCRT, rsa.ToXmlString (true), "Mono-Xml1024-WithoutCRT");

			rsa.FromXmlString (MonoXml1536woCRT);
			Assert.AreEqual (MonoXml1536woCRT, rsa.ToXmlString (true), "Mono-Xml1536-WithoutCRT");

			rsa.FromXmlString (MonoXml2048woCRT);
			Assert.AreEqual (MonoXml2048woCRT, rsa.ToXmlString (true), "Mono-Xml2048-WithoutCRT");
		}
Example #7
0
		public void MonoXmlImportExport () 
		{
			RSAManaged rsa = new RSAManaged ();

			rsa.FromXmlString (MonoXml384);
			Assert.AreEqual (MonoXml384, rsa.ToXmlString (true), "Mono-Xml384");

			rsa.FromXmlString (MonoXml448);
			Assert.AreEqual (MonoXml448, rsa.ToXmlString (true), "Mono-Xml448");

			rsa.FromXmlString (MonoXml512);
			Assert.AreEqual (MonoXml512, rsa.ToXmlString (true), "Mono-Xml512");

			rsa.FromXmlString (MonoXml576);
			Assert.AreEqual (MonoXml576, rsa.ToXmlString (true), "Mono-Xml576");

			rsa.FromXmlString (MonoXml640);
			Assert.AreEqual (MonoXml640, rsa.ToXmlString (true), "Mono-Xml640");

			rsa.FromXmlString (MonoXml704);
			Assert.AreEqual (MonoXml704, rsa.ToXmlString (true), "Mono-Xml704");

			rsa.FromXmlString (MonoXml768);
			Assert.AreEqual (MonoXml768, rsa.ToXmlString (true), "Mono-Xml768");

			rsa.FromXmlString (MonoXml832);
			Assert.AreEqual (MonoXml832, rsa.ToXmlString (true), "Mono-Xml832");

			rsa.FromXmlString (MonoXml896);
			Assert.AreEqual (MonoXml896, rsa.ToXmlString (true), "Mono-Xml896");

			rsa.FromXmlString (MonoXml960);
			Assert.AreEqual (MonoXml960, rsa.ToXmlString (true), "Mono-Xml960");

			rsa.FromXmlString (MonoXml1024);
			Assert.AreEqual (MonoXml1024, rsa.ToXmlString (true), "Mono-Xml1024");

			rsa.FromXmlString (MonoXml1536);
			Assert.AreEqual (MonoXml1536, rsa.ToXmlString (true), "Mono-Xml1536");

			rsa.FromXmlString (MonoXml2048);
			Assert.AreEqual (MonoXml2048, rsa.ToXmlString (true), "Mono-Xml2048");
		}
Example #8
0
		public void CapiEncryptDecryptWithoutCRT () 
		{
			RSAManaged rsa = new RSAManaged ();

			rsa.FromXmlString (CapiXml384woCRT);
			EncryptDecrypt ("Capi-384-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml448woCRT);
			EncryptDecrypt ("Capi-448-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml512woCRT);
			EncryptDecrypt ("Capi-512-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml576woCRT);
			EncryptDecrypt ("Capi-576-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml640woCRT);
			EncryptDecrypt ("Capi-640-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml704woCRT);
			EncryptDecrypt ("Capi-704-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml768woCRT);
			EncryptDecrypt ("Capi-768-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml832woCRT);
			EncryptDecrypt ("Capi-832-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml896woCRT);
			EncryptDecrypt ("Capi-896-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml960woCRT);
			EncryptDecrypt ("Capi-960-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml1024woCRT);
			EncryptDecrypt ("Capi-1024-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml1536woCRT);
			EncryptDecrypt ("Capi-1536-WithoutCRT", rsa);

			rsa.FromXmlString (CapiXml2048woCRT);
			EncryptDecrypt ("Capi-2048-WithoutCRT", rsa);
		}
Example #9
0
		public void CapiEncryptDecrypt () 
		{
			RSAManaged rsa = new RSAManaged ();

			rsa.FromXmlString (CapiXml384);
			EncryptDecrypt ("Capi-384", rsa);

			rsa.FromXmlString (CapiXml448);
			EncryptDecrypt ("Capi-448", rsa);

			rsa.FromXmlString (CapiXml512);
			EncryptDecrypt ("Capi-512", rsa);

			rsa.FromXmlString (CapiXml576);
			EncryptDecrypt ("Capi-576", rsa);

			rsa.FromXmlString (CapiXml640);
			EncryptDecrypt ("Capi-640", rsa);

			rsa.FromXmlString (CapiXml704);
			EncryptDecrypt ("Capi-704", rsa);

			rsa.FromXmlString (CapiXml768);
			EncryptDecrypt ("Capi-768", rsa);

			rsa.FromXmlString (CapiXml832);
			EncryptDecrypt ("Capi-832", rsa);

			rsa.FromXmlString (CapiXml896);
			EncryptDecrypt ("Capi-896", rsa);

			rsa.FromXmlString (CapiXml960);
			EncryptDecrypt ("Capi-960", rsa);

			rsa.FromXmlString (CapiXml1024);
			EncryptDecrypt ("Capi-1024", rsa);

			rsa.FromXmlString (CapiXml1536);
			EncryptDecrypt ("Capi-1536", rsa);

			rsa.FromXmlString (CapiXml2048);
			EncryptDecrypt ("Capi-2048", rsa);
		}