Hi All! I wanted to write an application wherein I had to "send" a server's public key (RSA) to a client.
So I generated the RSA keys with RSA_generate_key and checked it with RSA_check_key. I then tried copying the "entire" RSA structure pointer returned by RSA_generate_key to a send buffer and tried to send it over a TCP connection. (For the first cut I had decided to send the entire structure containing both the keys and then "narrow" it down to only the public key later on..) The key was not getting "received" properly at the other end - some of the fields were modified and hence the key was not valid. I then tried writing the keys to .pem files using PEM_write_RSAPrivateKey and PEM_write_RSAPublicKey. Both the functions simply "hanged" upon calling them (i.e. they never returned control..). I am at a loss to understand why is this happening.. I want to have the following information in general: 1.. Sample methods to send a public key over a TCP connection. 2.. What could have possibly made the PEM_write_RSAPrivateKey and PEM_write_RSAPublicKey fail..? 3.. Why possibly was the RSA key-structure not getting received properly at the client end? 4.. Finally, I would like to store the keys in an encrypted fashion in .pem files instead of storing them in cleartext.. Regards, Mrigank Mishra
