How To Create RSA Public and Private Key? – POFTUT

How To Create RSA Public and Private Key?

RSA is an algorithm used for Cryptography. It was patented until 2000 in the USA (not the 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.

Create Key

In order to manage the RSA key, we need to create it first. we specify the output type where it is a file named t1.key and the size of the key with 2048. We used the verb genrsa with OpenSSL. By default, keys are created in PEM format as it showed with file command.

Create Key

Create Key

Convert Pem Format into Der Format

Formats are used to encode created RSA key and save into a file. Pem is common format but sometimes 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 then show the existing file within and created file with -out. Then we check file as we see that data as file type because of the binary type. Der is not encoded base64 like pem format.

LEARN MORE  What Is Windows Sysinternal?

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 encrypted RSA key file without parameter. Or while generating the RSA key pair it can be encrypted too.

Encrypting RSA Key with AES

Encrypting RSA Key with AES

List/Show Public Key

We can display or view a given public key in the terminal. We will use -in parameter to provide the certificate file name which is t1.key in this example and -pubout and -text options in order to print to the screen.

List/Show Public Key

List/Show Public Key

We can see from the screenshot that RSA key is 2048 bit with modulus.

Leave a Reply

Your email address will not be published. Required fields are marked *

Enjoy this blog? Please spread the word :)