Groups | Blog | Home
all groups > dotnet security > october 2004 >

dotnet security : decrypt using public key only with RSA


David Gardner
10/27/2004 9:11:02 PM
I have someone who has given me a string that was encrypted with their RSA
private key. I tried to import their RSA public key and decrypt their strng
but I get "Bad Key." as the response:

'Verify the signature is authentic using the sender's public key.
Dim rsa As New RSACryptoServiceProvider

rsa.FromXmlString(publicKey)

Dim SignatureDecrypted() As Byte = rsa.Decrypt(signature, False)

Any help would be appreciated.

David Gardner
Rob Teixeira
10/29/2004 12:03:01 AM
From what I understand, the .NET RSA (and the underlying RSA Crypto Provider
for win32) support direct encryption with public keys and decryption with
private keys (the opposite of what you're expecting here). The idea is that
you distribute your public key to anyone, they encrypt a message with your
public key, and you are the only one who can decrypt it. For security
reasons, the opposite doesn't quite work. If you encrypt something with your
private key, anyone with the public key (and you have to assume anyone can
have it) can decrypt it.

Encrypting with a private key is typically only a means to create a
signature (since only the person with the private key can decrypt a piece of
text that everyone with his public key can use to verify). For doing that,
you can use the SignData and VerifyData methods of the
RSACryptoServiceProvider class.

-Rob Teixeira

[quoted text, click to view]

AddThis Social Bookmark Button