How To Create RSA Public and Private Key


RSA is an algorithm used for Cryptography. It was patented until 2000 in USA (not whole world) where now it can be used freely. RSA has a lot of usage examples but it is mainly used for encryption of small pieces of data like key and Digital signatures. RSA is based integer factorization problem. As it is known that asymmetric ciphers are very slow against symmetric ciphers. So it is used with symmetric cipher like AES to secure bulk data. Using with AES and RSA together named hybrid usage. Here are some practical RSA tools to manage.

openssl rsa command can be used for format exchange, encryption with symmetric key etc. where we look below.

Create Key

In order to manage RSA key we need to create it firstly. we specify the output type where it is file named t1.key and the size of the key with 2048. We used verb genrsa for openssl. By default keys are created in pem format as it shown with file command.

Convert Pem into Der

Formats are used to encode created rsa key and save into a file. Pem is common format but sometime you need to use der format. Here is how it can be done. We specify input form and output form with inform and outform parameters and than show existing file with in and created file wirh out. Then we check file as we see that data as file typr because of the binary type. Der is not encoded base64 like pem format.

Encrypting RSA Key with AES

Private keys are very sensitive if we transmit it over insecure places we should encrypt it with symmetric keys. Here we use AES with 128 bit key and we set encyrpted RSA key file with out parameter. Or while generating the RSA key pair it can be encrypted too.

Show Public Key

A public key in a RSA key pair can be viewed or exported. Below we view with pubout parameter the public key. If we give -out against -text the public key will be written to the file.

LEARN MORE  How To Redirect Stderr To Stdout In Linux Bash?

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)