使用 RSA 公钥解密数据 [英] Decrypt data using an RSA public key
问题描述
首先,这不是错字,我想解密 使用 public 密钥.这样做的目的是挑战第三方以确保他们确实拥有与公钥对应的私钥.基本上,我会发送一些随机数据,他们会用他们的私钥对其进行加密,我会使用公钥对其进行解密,并将解密后的值与我发送的随机数据进行比较.我相信这是公钥加密中非常标准的程序,但由于某种原因,使用公钥解密似乎是禁忌.
First off, that is not a typo, I want to decrypt using a public key. The purpose for doing this is to challenge a third party to ensure they do, in fact, have the private key that corresponds to the public key. Basically, I would send some random data, they would encrypt it with their private key, I would decrypt it using the public key and compare the decrypted value to the random data that I sent. I believe this is a pretty standard procedure in public key crypto but for some reason decrypting with a public key seems to be taboo.
我只是在 .NET 2.0 中使用 RSACryptoServiceProvider
.但是,当我调用 Decrypt
时,它会抛出带有消息 Bad Key
的 CryptographicException
.密钥还不错(我可以 Encrypt
没有问题),但它似乎不会让我只用公钥解密.是什么赋予了?这一定是可以做到的.
I am simply using the RSACryptoServiceProvider
in .NET 2.0. However, when I call Decrypt
it throws a CryptographicException
with message Bad Key
. The key is not bad (I can Encrypt
with no problem), but it appears as though it will not let me decrypt with just the public key. What gives? This must be possible to do.
推荐答案
我认为公认的术语是签名.他们用私钥签名,而你用公钥验证.我承认我不理解底层数学,但我的理解是签名实际上只是用私钥加密.
I think the recognized term is signing. They sign with the private key, and you verify with the public key. I admit I don't understand the low-level math as well as I should, but my understanding is signing is really just encrypting with the private key.
使用 RSACryptoServiceProvider
的签名和验证方法系列.事实上,SignHash
其实说的是用私钥加密".
Use RSACryptoServiceProvider
's sign and verify family of methods. In fact, SignHash
actually says, "encrypting it with the private key."
这篇关于使用 RSA 公钥解密数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!