Thursday, March 22, 2012

Generate RSA key pair with OpenSSL


The OpenSSL web site tells us to generate the RSA keys by running (without using a protecting password for the keys):

openssl genrsa -out privkey.pem 2048

That command outputs the private key in the default PEM format. It is said that "With OpenSSL, the private key contains the public key information as well, so a public key doesn't need to be generated separately." -- sure, but please show me how to extract the public key from it!

It is the openssl rsa command that will do it:

openssl rsa -pubout -in privkey.pem -out pubkey.pem

This post shows how to encrypt/decrypt with the RSA keys. This post gives an example of RSA decryption in C++.

No comments:

 
Get This <