ToXmlString() public method

public ToXmlString ( bool includePrivateParameters ) : string
includePrivateParameters bool
return string
Example #1
0
 public Product()
 {
     _key = RSA.Create();
     _id = Guid.NewGuid();
     _issuedLicenses = new ObservableCollection<License>();
     _publicKey = _key.ToXmlString(false);
     _privateKey = _key.ToXmlString(true);
 }
Example #2
0
 /// <summary>
 /// Erstellt ein neues Schlüsselpaar
 /// </summary>
 /// <returns></returns>
 public static string[] CreateNewKeys()
 {
     System.Security.Cryptography.RSA rsa = System.Security.Cryptography.RSA.Create();
     return(new[] {
         rsa.ToXmlString(true),                         //PrivateKey
         rsa.ToXmlString(false)                         //PublicKey
     });
 }
Example #3
0
        public static void WriteKey(Stream file, String password, RSA rsa)
        {
            byte[] key = DeriveBytes(file, password);
            byte[] iv = DeriveBytes(file, password);

            using (var aes = new RijndaelManaged { KeySize = BlockSize * 8, BlockSize = BlockSize * 8, Key = key, IV = iv })
            using (var transform = aes.CreateEncryptor())
            using (var stream = new CryptoStream(file, transform, CryptoStreamMode.Write))
            using (var writer = new StreamWriter(stream)) {
                writer.Write(rsa.ToXmlString(true));
            }
        }
 void SetPublicKey(RSA rsa)
 {
     SetText(rsaKey, XElement.Parse(rsa.ToXmlString(false)).ToString());
 }
Example #5
0
 public string GetPublicKey()
 {
     return(rsa.ToXmlString(false));
 }
Example #6
0
 public override string ToXmlString(bool includePrivateParameters) => _impl.ToXmlString(includePrivateParameters);
Example #7
0
        bool BruteForce(MSX.PKCS12 pfx)
        {
            foreach (object o in pfx.Keys) {
                key = (o as RSA);
                if (key == null)
                    continue;

                string s = key.ToXmlString (false);
                foreach (MSX.X509Certificate cert in pfx.Certificates) {
                    if (s == cert.RSA.ToXmlString (false))
                        x509 = new X509Certificate (cert.RawData);
                }

                // complete ?
                if ((x509 != null) && (key != null))
                    return true;
            }
            return false;
        }
Example #8
0
		public bool Matches (RSA rsa)
		{
			// hmm, there should be more decent way to compare ...
			return rsa.ToXmlString (false) == this.rsa.ToXmlString (false);
		}