Transwiki:Generate a keypair using OpenSSL
From Wikibooks, the open-content textbooks collection
Download and install the OpenSSL runtimes. If you are running Windows, grab the Cygwin package.
[edit] Generate a 1024 bit RSA private key
Execute command: “openssl genrsa -out private_key.pem 1024”
e.g.
$ openssl genrsa -out private_key.pem 1024 Generating RSA private key, 1024 bit long modulus .............................++++++ ................................................................++++++ e is 65537 (0x10001)
[edit] Generating a public key from a private key
Execute command: "openssl rsa -pubout -in private_key.pem -out public_key.pem"
e.g.
$ openssl rsa -pubout -in private_key.pem -out public_key.pem writing RSA key
A new file is created, public_key.pem, with the public key.
[edit] Viewing the key elements
Execute command: "openssl rsa -text -in private_key.pem"
All parts of private_key.pem are printed to the screen. This includes the modulus (also referred to as public key and n), public exponent (also referred to as e and exponent; default value is 0x010001), private exponent, and primes used to create keys (prime1, also called p, and prime2, also called q), as well as a few other variables used to perform RSA operations faster and the Base64 PEM encoded version of the key.

