0

I have created a public key using RSACryptoServiceProvider in c#. Later in my program I want to store it's content in database. How can I make sure that the file is a true public key.

Note: I have checked it's structure against xsd. but I need more. Any help?

the code to produce public key:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048);
string publicKey = rsa.ToXmlString(false);

1 Answers1

0

finally I've found a solution: first I check the schema against a xsd file, and then

                try
                {
                    var csp = new RSACryptoServiceProvider();
                    var reader = new StreamReader(address);
                    var xml = reader.ReadToEnd();
                    csp.FromXmlString(xml);
                }
                catch
                {
                    //not a rsa public key                   
                }