[This document is under construction]
Create a private key with 2048-bit modulus (n) like this. See below for information about the PEM file format.
openssl genrsa -out private.pem 2048
Create a public key file from the private key you made above.
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
Let's say you have a message in plaintext.txt. You can encrypt it using your public key from above like so:
openssl rsautl -encrypt -pubin -inkey public.pem < plaintext.txt > ciphertext.txt
Decrypt your ciphertext from above using your private key like so:
openssl rsautl -decrypt -inkey private.pem < ciphertext.txt
Extract the information stored in public.pem:
openssl rsa -pubin -inform PEM -text -noout < public.pem
Extract the information stored in private.pem:
openssl rsa -inform PEM -text -noout < private.pem
What are those extra items stored in private.pem?
Take a look at the public and private key files:
cat private.pem
cat public.pem
These files are in a format known as privacy-enhanced electronic email form. They consist of:
Extract the DER data from public.pem:
openssl rsa -outform der -in public.pem -pubin -inform PEM -out public.der
(Question: could you pull off the same conversion using Python?)
...[not done yet]...