OpenSSL 有关密钥的那些事儿(HOWTO keys)

简介: OpenSSL 有关密钥的那些事儿(HOWTO keys)1. 介绍(Introduction)Keys are the basis of public key algorithms and PKI.
<DRAFT!>
			OpenSSL 有关密钥的那些事儿(HOWTO keys)

1. 介绍(Introduction)

Keys are the basis of public key algorithms and PKI.  Keys usually
come in pairs, with one half being the public key and the other half
being the private key.  With OpenSSL, the private key contains the
public key information as well, so a public key doesn't need to be
generated separately.

Public keys come in several flavors, using different cryptographic
algorithms.  The most popular ones associated with certificates are
RSA and DSA, and this HOWTO will show how to generate each of them.


2. 生成 RSA 密钥(To generate a RSA key)

A RSA key can be used both for encryption and for signing.

Generating a key for the RSA algorithm is quite easy, all you have to
do is the following:

  openssl genrsa -des3 -out privkey.pem 2048

With this variant, you will be prompted for a protecting password.  If
you don't want your key to be protected by a password, remove the flag
'-des3' from the command line above.

    NOTE: if you intend to use the key together with a server
    certificate, it may be a good thing to avoid protecting it
    with a password, since that would mean someone would have to
    type in the password every time the server needs to access
    the key.

The number 2048 is the size of the key, in bits.  Today, 2048 or
higher is recommended for RSA keys, as fewer amount of bits is
consider insecure or to be insecure pretty soon.


3. 生成 DSA 密钥(To generate a DSA key)

A DSA key can be used for signing only.  This is important to keep
in mind to know what kind of purposes a certificate request with a
DSA key can really be used for.

Generating a key for the DSA algorithm is a two-step process.  First,
you have to generate parameters from which to generate the key:

  openssl dsaparam -out dsaparam.pem 2048

The number 2048 is the size of the key, in bits.  Today, 2048 or
higher is recommended for DSA keys, as fewer amount of bits is
consider insecure or to be insecure pretty soon.

When that is done, you can generate a key using the parameters in
question (actually, several keys can be generated from the same
parameters):

  openssl gendsa -des3 -out privkey.pem dsaparam.pem

With this variant, you will be prompted for a protecting password.  If
you don't want your key to be protected by a password, remove the flag
'-des3' from the command line above.

    NOTE: if you intend to use the key together with a server
    certificate, it may be a good thing to avoid protecting it
    with a password, since that would mean someone would have to
    type in the password every time the server needs to access
    the key.

-- 
Richard Levitte
目录
相关文章
|
3月前
|
Linux 开发工具
Linux yum 使用时提示 获取 GPG 密钥失败Couldn‘t open file RPM-GPG-KEY-EPEL-7
Linux yum 使用时提示 获取 GPG 密钥失败Couldn‘t open file RPM-GPG-KEY-EPEL-7
227 3
|
4月前
|
安全 网络安全
jsch 报错 no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 如何处理
【5月更文挑战第24天】jsch 报错 no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 如何处理
222 1
|
4月前
|
算法 网络安全
Unable to negotiate with 127.0.0.1 port 29215: no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 解决
【5月更文挑战第5天】Unable to negotiate with 127.0.0.1 port 29215: no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 解决
207 7
|
4月前
|
安全 网络安全
jsch 报错 no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha>问题处理方法
【5月更文挑战第10天】jsch 报错 no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha>问题处理方法
244 0
|
4月前
|
算法 网络安全
no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 问题解决
【5月更文挑战第8天】no matching host key type found. Their offer: ssh-rsa,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha> 问题解决
368 0
|
4月前
|
安全 Linux API
Keystore、Key attestation
Keystore、Key attestation
140 0
Keystore、Key attestation
|
4月前
|
算法 网络安全 数据安全/隐私保护
你知道PGP和GPG的区别 吗?
你知道PGP和GPG的区别 吗?
210 0
|
Linux 网络安全
Linux下的github 添加秘钥出错:Key is invalid. You must supply a key in OpenSSH public key for
Linux下的github 添加秘钥出错:Key is invalid. You must supply a key in OpenSSH public key for
Linux下的github 添加秘钥出错:Key is invalid. You must supply a key in OpenSSH public key for
gpg: no default secret key: 私钥不可用
gpg: no default secret key: 私钥不可用
118 0
|
PHP
如何把一行纯内容的rsa私钥,处理成php函数openssl_verify可以使用的格式
如何把一行纯内容的rsa私钥,处理成php函数openssl_verify可以使用的格式
265 0
如何把一行纯内容的rsa私钥,处理成php函数openssl_verify可以使用的格式