I'm trying to generate an RSA key pair using openssl with a custom bit-length. Using the openssl genrsa
command, passing the bit-length at the end of the command would work. But as genrsa
is show depricated in the man page( man openssl-genrsa
), I've chosen the genpkey
command instead. The man page shows several options for generating the key including the algorithm to use, but there isn't any option to specify the bit-length.
This is the command I used: openssl genpkey -algorithm rsa -out pkey.pem -outform PEM
I'm new to openssl and Public Key Encryption, so please forgive me if the question is too basic.
What you are looking for is -pkeyopt option. The text for this is as follows:
Set the public key algorithm option opt to value. The precise set of options supported depends on the public key algorithm used and its implementation. See "KEY GENERATION OPTIONS" and "PARAMETER GENERATION OPTIONS" below for more details.
For RSA, the options are:
rsa_keygen_bits:numbits The number of bits in the generated key. If not specified 2048 is used
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out pkey.pem -outform PE
I think this should do what you want, where 2048 is the number of bits you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.