为什么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.
和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
Debian中的文档对此也真的很奇怪,
genpkey Generation of Private Key or Parameters.
genrsa Generation of RSA Private Key. Superceded by genpkey.
是genpkey
替代品吗?如果是这样,怎么会没有-des3
呢?而且,我们如何在其中添加密码并指定密钥长度?
genrsa
和genpkey
实际上是不同的。使用生成的密钥的ASN.1结构genrsa
是pkcs#1,而使用生成的密钥genpkey
是pkcs#8。如果那还不够糟糕,那么如果您使用genpkey -outform der
它,那就回到pkcs#1。随着EC,它甚至更糟的是,不知何故genec
丢失,而是存在ecparam -genkey
,不知何故ecparam -genkey
,genpkey -outform pem
,genpkey -outform der
都有着不同的ASN.1结构。