PKCS11加密与RSA私钥的哈希

发布于 2025-02-10 13:51:23 字数 350 浏览 2 评论 0原文

我们正在建立一个数字签名平台。 根据用户,我们在HSM中生成RSA 2048密钥对,并发布X509数字证书。 在底线或凯德(Cades)数字签名(包裹)期间,我们获得了SHA256 HASH 32字节,需要使用用户的RSA私钥加密,以完成签名操作。

我们应该使用哪些PKCS11机制和功能使用RSA私钥加密HASH?

似乎使用C_SIGN()将CKM_SHA256_RSA_PKCS使用hash,然后签名/加密它。这不是我们想要的 - 除非我误会了。

这项工作是否可以:c_encrypt(ckm_rsa_pkcs,privateKeyhandle,hashbytes)?根据文档,ckm_rsa_pkcs使用公共密钥。

非常感谢

We are building a Digitial Signing platform.
Per user we generate a RSA 2048 key pair in an HSM, and issue a X509 digital certificate.
During PAdEs or CAdES digital signing (Enveloping) we get the SHa256 hash 32 bytes that needs to be encrypted with user's RSA private key in order to complete signing operation.

What PKCS11 mechanism and function should we use to encrypt a hash with RSA private key?

It seems using CKM_SHA256_RSA_PKCS with C_Sign() will hash the hash and then sign/encrypt it. which is not what we want - unless i am mistaken.

Would this work: C_Encrypt(CKM_RSA_PKCS, privateKeyHandle, hashBytes)? according to documentation CKM_RSA_PKCS uses public key.

Many Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宫墨修音 2025-02-17 13:51:23

是的。方法是您需要的。

byte[] Sign(IMechanism mechanism, IObjectHandler privateKeyHandle, byte[] sourceData)

参数Mechansim是通过以下方式进行的:

Factories.MechansimFactory.Create(CKM.CKM_SHA1_RSA_PKCS)

这是RSA Mechansim。为了设置其长度,您应该创建一个具有2048模量长度的私钥。

是您需要的吗?

Yes. the method Sign is what you need.

In PKCS11Interop GitHub project page, there is an example named '_20_signAndVerifyTest.cs' in which uses a method with this signature:

byte[] Sign(IMechanism mechanism, IObjectHandler privateKeyHandle, byte[] sourceData)

The argument mechansim is made through:

Factories.MechansimFactory.Create(CKM.CKM_SHA1_RSA_PKCS)

which is a RSA mechansim. for setting its length, you should create a private key with 2048 modulus length.

is it what you need?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文