ExportParameters() 공개 메소드

public ExportParameters ( bool includePrivateParameters ) : RSAParameters
includePrivateParameters bool
리턴 System.Security.Cryptography.RSAParameters
예제 #1
0
		private void EncryptDecrypt (string msg, RSAManaged rsa) 
		{
			RSAParameters param = rsa.ExportParameters (false);

			byte[] data = { 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 };
			// we don't need the private key to encrypt
			RSAManaged pubkey = new RSAManaged ();
			pubkey.ImportParameters (param);
			byte[] enc = pubkey.EncryptValue (data);

			byte[] dec = rsa.DecryptValue (enc);
			// note: the decrypted value is now right padded with zeros
			Assert.IsTrue (BitConverter.ToString (dec).EndsWith (BitConverter.ToString (data)), msg);
		}
예제 #2
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);
		}
		private void EncryptDecrypt (string msg, RSAManaged rsa) 
		{
			RSAParameters param = rsa.ExportParameters (false);

			byte[] data = { 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 };
			// we don't need the private key to encrypt
			RSAManaged pubkey = new RSAManaged ();
			pubkey.ImportParameters (param);
			byte[] enc = pubkey.EncryptValue (data);

			byte[] dec = rsa.DecryptValue (enc);
			Assert.AreEqual (BitConverter.ToString (data), BitConverter.ToString (dec), msg);
		}