I\'ve used the .NET class RSACryptoServiceProvider
to get a keypair:
using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider())
{
File.
This blog post on using OpenSSL and RSACryptoServiceProvider states that it is possible, but the author ended up using the Chilkat RSA Library to ultimately interoperate with OpenSSL from within C#. The PEM format is not supported in the .NET world so you could use this library from JavaScience called OpenSSLKey.cs; however, as the author of the blog post mentions they had problems due to this (quoted):
OpenSSL: Can only sign small bits of data that fit within a single block. The data is padded and signed. The reverse is called "verify" and in that case the data is "unsigned" and then unpadded and the original data is returned.
[Windows]: Can sign any amount of data. The Sign* methods first hash the data and then the hash is padded and signed. The Verify* methods expect three inputs: the original data, a hash algorithm name, and the signature data. The original data is hashed and the result of unsigning/unpadding is compared with the hash of the original data.
So I recommend you go with the Chilkat RSA library.