locked
RSA Public key to String RRS feed

  • Question

  • Hello All,

    I am developing a PDA application. I need to send my RSA public key to a Linux machine. For this I want to convert my key public key to String. ToXmlString and FromXmlString are not supported in .Net Compact Framework 2.0. So, can anyone tell me an alternative to convert the RSA public key to String format.

     

    Thanks in advance.

     

     

    Praveen

    Wednesday, June 13, 2007 1:45 PM

Answers

  • You can get the same information as contained in the XML string by calling ExportParameters.
    Wednesday, June 13, 2007 10:24 PM
  • You can create the same string you would have gotten from ToXmlString (or whatever format is best for your application) from RSAParameters. Something like this:

     

    RSAParameters rsap = rsakey.ExportParameters(false);

    string publicKeyXML = "<RSAKeyValue><Modulus>" + rsap.Modulus.ToString() +"</Modulus><Exponent>" + rsap.Exponent.ToString() +"</Exponent></RSAKeyValue>";

    Monday, June 18, 2007 10:47 PM

All replies

  • You can get the same information as contained in the XML string by calling ExportParameters.
    Wednesday, June 13, 2007 10:24 PM
  • Hello All,

    I will make my question more clear. I want to send the public key from a pda to a linux machine. So, I want to export my public key in a format that could be recognized by the linux machine. Can any one help me with a sample code.

     

    Thanks in advance.

     

    Praveen

    Saturday, June 16, 2007 5:52 AM
  • You can create the same string you would have gotten from ToXmlString (or whatever format is best for your application) from RSAParameters. Something like this:

     

    RSAParameters rsap = rsakey.ExportParameters(false);

    string publicKeyXML = "<RSAKeyValue><Modulus>" + rsap.Modulus.ToString() +"</Modulus><Exponent>" + rsap.Exponent.ToString() +"</Exponent></RSAKeyValue>";

    Monday, June 18, 2007 10:47 PM
  • We do something that is similar .... taking the data and converting it to a byte array (which of course can then be manipulated into anything you want) for transmission to the Unix box.  Not my favorite code to write, but fast and effective.

    Tuesday, June 19, 2007 2:06 AM
  • Thanks for your reply Lee. I am using openssl for RSA encryption. So, I want to send the public key of the PDA to the linux machine and the linux machine should be able to use this public key to encyrpt the data that is being sent to the PDA. Is there a standard format for sending the public key to linux machine? Or else is there a way to convert the key in the stirng format to an RSA recognizable format on the linux machine.

     

     

    Thanks,

    Praveen

    Tuesday, June 19, 2007 4:24 PM