Asymmetric encryption algorithm is also called < public key algorithm, different from symmetric encryption algorithm, asymmetric encryption algorithm encryption key and decryption key is not a key, asymmetric key pair in the public key can be disclosed.
This algorithm can only be decrypted with the corresponding private key if the public key is used for encryption, or it can only be decrypted with the corresponding public key if encrypted with the private key. It is almost impossible to derive the private key from the public key (such an algorithm can be implemented using some irreversible functions)!
OpenSSL supports RSA, DSA, DH three different asymmetric encryption algorithms. Here we'll explain how to use OpenSSL to build and learn to use RSA key pairs.
RSA Asymmetric Encryption:
First, generate the RSA key pair (OPENSLL Genrsa):
1. Syntax Description:
Usage:genrsa [args] [numbits]
-des encrypt the generated key with DES in CBC mode (encrypted RSA key pair using DES encryption algorithm)
-des3 encrypt the generated key with DES in Ede CBC mode (encrypted RSA key pair using the DES3 encryption algorithm)
-aes128,-aes192,-aes256
Encrypt PEM output with CBC AES (encrypted RSA key pair with AES encryption algorithm)
-out file output the key to '
-passout arg output File pass phrase source (password for output key file)
-f4 use F4 (0x10001) for the E value (using F4 as the e-parameter of the public key, default to this option)
-3 use 3 for the E value (using 3 as the E-parameter of the public key)
-engine e use engine E, possibly a hardware device. (Generating a key pair using a third party device)
-rand file:file: ... (Manually specify random number files)
Load the file (or the "files in" directory) into
The random number generator
2. Case:
(1) OpenSSL genrsa-out Rsakey.pem 2048
Generates a 2048-bit key pair, note: There is no cryptographic operation on the key.
(2) OpenSSL genrsa-aes128-out rsakey.pem-passout pass:111111 2048
Generates a 2048-bit key pair, encrypts the key pair using the AES algorithm, and the key password is 111111
Note: The OpenSSL generated public and private keys are stored in a file by default and can be used to manage key files when a public or private key needs to be extracted using the RSA command.