OpenSSL:genrsa 与 genpkey?

Eva*_*oll 15 openssl

为什么 OpenSSL 提供了两个有如此多重叠的实用程序

genpkey

OpenSSL> genpkey -
Usage: genpkey [options]
where options may be
-out file          output file
-outform X         output format (DER or PEM)
-pass arg          output file pass phrase source
-<cipher>          use cipher <cipher> to encrypt the key
-engine e          use engine e, possibly a hardware device.
-paramfile file    parameters file
-algorithm alg     the public key algorithm
-pkeyopt opt:value set the public key algorithm option <opt>
                   to value <value>
-genparam          generate parameters, not key
-text              print the in text
NB: options order may be important!  See the manual page.
Run Code Online (Sandbox Code Playgroud)

并且genrsa

OpenSSL> genrsa -
usage: genrsa [args] [numbits]
 -des            encrypt the generated key with DES in cbc mode
 -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)
 -seed
                 encrypt PEM output with cbc seed
 -aes128, -aes192, -aes256
                 encrypt PEM output with cbc aes
 -camellia128, -camellia192, -camellia256
                 encrypt PEM output with cbc camellia
 -out file       output the key to 'file
 -passout arg    output file pass phrase source
 -f4             use F4 (0x10001) for the E value
 -3              use 3 for the E value
 -engine e       use engine e, possibly a hardware device.
 -rand file:file:...
                 load the file (or the files in the directory) into
                 the random number generator
Run Code Online (Sandbox Code Playgroud)

Debian 中的文档对此也很奇怪,

   genpkey   Generation of Private Key or Parameters.
   genrsa    Generation of RSA Private Key. Superceded by genpkey.
Run Code Online (Sandbox Code Playgroud)

genpkey替代品吗?如果有,怎么没有-des3?而且,我们如何为其添加密码并指定密钥长度?

Mic*_*elZ 11

它清楚地表明genrsa已被 取代genpkey,所以是的,genpkey是替代品。

您可以3des使用-cipher参数将密码更改为

此外,它应该告诉您要添加密码,请使用-pass参数

你可以在这里找到更多信息

  • 因为 -h 的全部目的是提供命令的概要。也就是说,我刚刚发现 `genpkey` 实际上记录在它自己的手册页中。那很有意思。整个项目应该朝着 git-core 的方向发展,手册页都以 openssl- 为前缀,并且 ui 允许 `openssl help genpkey` 来呈现手册页。tldr; 更好的文档会有所帮助。 (9认同)
  • 大声笑,这太疯狂了……`-pkeyopt rsa_keygen_bits:numbits`。 (3认同)