Sunday, 24 April 2011

Generating public and private keys

Asymmetric keys are often used so I shall describe two ways of generating them. Using openssl we can generate them as follows:

openssl genrsa -out key.priv 1024
openssl rsa -in key.priv -out -pubout

The key pair generated above can be used as follows:
- distribute the public key so that messages can be encrypted using the public key
- use the private key to decrypt them

Whenever there is the need for a password, the ssh format for RSA and DSA keys can be used. An ssh key-pair can be generated in the following way.

ssh-keygen -t rsa -b 2048

No comments: