What is difference between below two commands?
1. openssl genpkey -algorithm RSA
2. openssl genrsa
In document difference is "Private Key" and "RSA Private Key".
Then..
What is diference between "Private Key with algorithm RSA" and "RSA Private Key"?
Best Answer
The
genpkey
command can create other types of private keys - DSA, DH, EC and maybe GOST - whereas thegenrsa
, as it's name implies, only generates RSA keys. There are equivalentgendh
andgendsa
commands.However, the OpenSSL documentation states that these
gen*
commands have been superseded by the genericgenpkey
command.In the case of your examples, both generate RSA private keys.
and
will generate a 2048 bit RSA key with the exponent set to 65537.
Simply
cat
the resulting files to see that they are both PEM format private keys; althoughopenssl rsa
encloses them inBEGIN RSA PRIVATE KEY
andEND RSA PRIVATE KEY
whileopenssl genpkey
omits theRSA
. The former is PKCS#1 format, while the latter is PKCS#8.Running
openssl rsa text -in <filename>
against both shows that they are RSA private keys with the samepublicExponent
. The newergenpkey
command has the option to change this using-pkeyopt rsa_keygen_pubexp:value
while thegenrsa
command doesn't have this option.