是否可以使用 RsaCryptoServiceProvider 调用 SignHash 和VerifyHash,而无需昂贵的 OID 查找?

发布于 2024-12-07 23:58:41 字数 490 浏览 5 评论 0原文

我需要使用 RSA(密钥大小 1024 位)每秒签署和验证大约一百条消息。

为了对消息进行签名,我使用 SHA2 计算数据的哈希值,然后将哈希值传递给 SignHash。

rsaCryptoServiceProvider.SignHash(hashOfData, "SHA2");

为了验证签名,我使用

rsaCryptoServiceProvider.VerifyHash(hashOfData, "SHA2", signature);

使用 null 调用这些方法会引发异常。同样,使用

CryptoConfig.MapNameToOid("SHA2")

也会联系域控制器并花费大量时间。

我也尝试过使用 SHA1 和 MD5 进行相同的操作。有什么方法可以跳过 SignHash 和VerifyHash 的 OID 查找吗?

I need to sign and verify around a hundred messages / sec using RSA (Key size 1024 bit).

For signing the message I am calculating the hash of the data using SHA2 and then passing the hash to SignHash.

rsaCryptoServiceProvider.SignHash(hashOfData, "SHA2");

To verify the signature I use

rsaCryptoServiceProvider.VerifyHash(hashOfData, "SHA2", signature);

Calling these methods with null throws an exception. Similarly, using

CryptoConfig.MapNameToOid("SHA2")

also contacts the domain controller and takes a lot of time.

I have tried the same with SHA1 and MD5 too. Is there any way I can skip the OID lookup for both SignHash and VerifyHash?

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

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

发布评论

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

评论(1

亚希 2024-12-14 23:58:41

似乎传递 null 作为第二个参数会强制使用 SHA1。使用任何其他算法都需要 Oid 查找。

It seems that passing null as the second parameter forces the use of SHA1. Using any other algorithm requires a Oid lookup.

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