/// <summary>Initializes an <see cref="T:System.Security.Cryptography.RSA" /> object from the key information from an XML string.</summary>
/// <param name="xmlString">The XML string containing <see cref="T:System.Security.Cryptography.RSA" /> key information. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="xmlString" /> parameter is null. </exception>
/// <exception cref="T:System.Security.Cryptography.CryptographicException">The format of the <paramref name="xmlString" /> parameter is not valid. </exception>
public override void FromXmlString(string xmlString)
{
if (xmlString == null)
{
throw new ArgumentNullException("xmlString");
}
RSAParameters parameters = default(RSAParameters);
try
{
parameters.P = AsymmetricAlgorithm.GetNamedParam(xmlString, "P");
parameters.Q = AsymmetricAlgorithm.GetNamedParam(xmlString, "Q");
parameters.D = AsymmetricAlgorithm.GetNamedParam(xmlString, "D");
parameters.DP = AsymmetricAlgorithm.GetNamedParam(xmlString, "DP");
parameters.DQ = AsymmetricAlgorithm.GetNamedParam(xmlString, "DQ");
parameters.InverseQ = AsymmetricAlgorithm.GetNamedParam(xmlString, "InverseQ");
parameters.Exponent = AsymmetricAlgorithm.GetNamedParam(xmlString, "Exponent");
parameters.Modulus = AsymmetricAlgorithm.GetNamedParam(xmlString, "Modulus");
this.ImportParameters(parameters);
}
catch (Exception inner)
{
this.ZeroizePrivateKey(parameters);
throw new CryptographicException(Locale.GetText("Couldn't decode XML"), inner);
}
finally
{
this.ZeroizePrivateKey(parameters);
}
}