gpt4 book ai didi

openssl - 什么是公钥 header 和公钥信息?

转载 作者:行者123 更新时间:2023-12-04 14:38:42 27 4
gpt4 key购买 nike

我正在尝试查找什么是公钥 header 和公钥信息。我使用 openssl 以及公钥模数转储了 C 格式的证书。它将公钥信息和公钥 header 列为公钥。但我无法使用 openssl.exe rsa -pubin -inform DER -text -noout < publickey.der 转储这些字段用于在我的服务器上生成的公钥。

谁能解释一下数字证书中这些字段的意义是什么,它们对所有公钥都一样吗?无法在 openssl 上获取此信息,只是提到 DER 编码将具有额外的页眉和页脚。

最佳答案

我从未听说过公钥 header ...您能举个例子吗?

公钥信息可能是 X.509 证书中公钥通常编码的标准方式,格式为 SubjectPublicKeyInfo attribute .这些 SubjectPublicKeyInfos 可以变成一个公钥文件(我假设这就是你想要做的?如果我错了请纠正我!)该部分还告诉你在哪里可以找到有关特定算法的信息,他们引用了 RSA RFC 3279 . SubjectPublicKeyInfo 定义如下:

SubjectPublicKeyInfo  ::=  SEQUENCE  {
algorithm AlgorithmIdentifier,
subjectPublicKey BIT STRING }

RFC 3279 说:

The rsaEncryption OID is intended to be used in the algorithm fieldof a value of type AlgorithmIdentifier. The parameters field MUSThave ASN.1 type NULL for this algorithm identifier.

进一步:

The RSA public key MUST be encoded using the ASN.1 type RSAPublicKey:

  RSAPublicKey ::= SEQUENCE {
modulus INTEGER, -- n
publicExponent INTEGER } -- e

因此它是包含相关数据的 subjectPublicKey 字段 - 例如,您可以使用 OpenSSL 的 x509 命令获取这些值:

openssl x509 -in certificate.cer -inform DER -noout -text

打印出来(对于 PEM 证书,删除 -inform DER):

Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (1024 bit)
Modulus:
00:cb:c2:...
Exponent: 65537 (0x10001)

还有一个巧妙的技巧,您可以使用 x509 直接生成 PEM RSA 公钥文件:

openssl x509 -inform DER -in certificate.cer -pubkey -noout > pubkey.pem

并且您的公钥以 PEM 编码导出。

关于openssl - 什么是公钥 header 和公钥信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10812588/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com