PKCS#10 从 PKCS#11 请求对象密钥对
我有一个使用 PKCS#11 的标准调用生成的 RSA 1024 密钥对。 我需要为公钥生成 PKCS#10 CSR。
MS 有 IEnroll4 dll,允许使用 createRequestWStr 引发 CSR。 示例表明您需要生成一个新的密钥对(MS CAPI 中包含 2 个对象的容器),MS 会自动提供用于生成 csr 的公钥上下文。
就我而言,我已经使用 pkcs#11 生成了一个密钥对(作为 2 个对象,但没有密钥容器)。 MS dll 不允许我继续进行。 查询 1: 有人可以指出我如何解决这个问题吗? --------------------------------------------------------- -----------------------------------------
或者,我正在考虑编写自己的代码,用于基于 RSA 标准的 CSR 生成。 我有 ASN 1.0 格式 认证请求的 ASN.1 语法为:
CertificationRequest ::= SEQUENCE {
certificationRequestInfo CertificationRequestInfo,
signatureAlgorithm SignatureAlgorithmIdentifier,
signature Signature
}
SignatureAlgorithmIdentifier ::= AlgorithmIdentifier
Signature ::= BIT STRING
CertificationRequestInfo ::= SEQUENCE {
version Version,
subject Name,
subjectPublicKeyInfo SubjectPublicKeyInfo,
attributes [0] IMPLICIT Attributes
}
Attributes ::= SET OF Attribute
QUERY 2: 如何使用上述语法? 我对这种语法完全陌生? 我应该查看哪些资源来编写自己的代码?
I have a RSA 1024 key pair generated using standard call from PKCS#11.
I need to generate a PKCS#10 CSR for the public key.
MS has the IEnroll4 dll which will allow to raise a CSR using createRequestWStr. The samples indicate that you need to generate a new key pair(a container with 2 objects in MS CAPI) and MS automatically gives the the public key context for csr generation.
In my case, I already have a key pair generated using pkcs#11(as 2 objects but no key container). MS dll is not allowing me to proceed further.
QUERY 1:
Can some body point out how I can resolve this issue.
----------------------------------------------------------------------------
Alternatively, I was thinking to write my own code for CSR generation based on RSA standards. I am having the ASN 1.0 format
The ASN.1 syntax for a Certification Request is:
CertificationRequest ::= SEQUENCE {
certificationRequestInfo CertificationRequestInfo,
signatureAlgorithm SignatureAlgorithmIdentifier,
signature Signature
}
SignatureAlgorithmIdentifier ::= AlgorithmIdentifier
Signature ::= BIT STRING
CertificationRequestInfo ::= SEQUENCE {
version Version,
subject Name,
subjectPublicKeyInfo SubjectPublicKeyInfo,
attributes [0] IMPLICIT Attributes
}
Attributes ::= SET OF Attribute
QUERY 2:
How do I use the above syntaxes? I am totally new to this syntax? Which resources should I need to look at to write my own code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要使用 PKCS#11 接口生成证书请求(即您不能使用 CSP 接口),您最好的选择是避免 IEnroll。
对于 C++,您的(免费和开源)选项似乎是研究 OpenSSL 或 Botan。 我不太喜欢 OpenSSL 的 API,但它确实有效。 我从来没有用过Botan,但看起来不错。 如果你愿意花钱的话,还有很多不错的选择。
或者,如果您想自己编写 ASN.1,您可能需要阅读 外行指南ASN.1、BER 和 DER 的子集。 正式规范在 X.208 和 X.209 中,但这些很难读。
您想要生成 ASN.1 的 DER 编码(如链接中所述)。
这是一个示例编码:
或使用优秀的 dumpasn1 实用程序 进行翻译:
If you need to generate your certificate-request with the PKCS#11-interface (i.e. you cannot use a CSP-interface instead) your best bet is to avoid IEnroll.
For C++ your (free and open source) options seems to be to look into OpenSSL or Botan. I am not terribly fond of OpenSSL's API, but it works. I have never used Botan, but it seems pretty nice. There are also many excellent choices if you are willing to pay for them.
Alternatively, if you want to write the ASN.1 yourself you probably want to read A Layman's Guide to a Subset of ASN.1, BER, and DER. The formal specifications are in X.208 and X.209, but those are hard reading.
You want to generate a DER encoding of the ASN.1 (that is described in the link).
Here is an example encoding:
or translated with the excellent dumpasn1 utility: