Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How? Encrypt using private key

1 view
Skip to first unread message

Tyler Laing

unread,
Jan 11, 2005, 5:55:03 PM1/11/05
to
I want to encrypt some data with a private key. How?

As far as I know, public/private key cryptology is supposed to allow for
data to be encrypted by either key and decrypted with the other key.

Given this, why is it that everyingthing in .NET (as far as I can see) only
allows for encrypting data using a public key? Surely there are situations
where encrypting data with a private key is useful. I fully understand public
key encryption's usefullness for passing a symetric key, but here's my
situation.

I have clients running an app. I want to send them some data. I do not care
who reads this data. I only care about 2 things.

1) No one but me could have written that data.
2) The data can not be altered without being corrupted.

Encrypting said data using my private key seems it would do just that. But
how do I use .NET to do so?

Thanks in advance

Ed Kaim

unread,
Jan 11, 2005, 8:14:56 PM1/11/05
to
Use a hash.

"Tyler Laing" <Tyler...@discussions.microsoft.com> wrote in message
news:C799B7A9-9DB0-40D3...@microsoft.com...

Sergey Bogdanov

unread,
Jan 12, 2005, 1:47:35 AM1/12/05
to
To encrypt data using a private key you can you RSACryptoServiceProvider
from
http://www.opennetcf.org/sourcebrowse/view.aspx?f=d:/sites/OpenNETCF/InetPub/wwwroot/Source/OpenNETCF/Security/Cryptography/RSACryptoServiceProvider.cs

RSACryptoServiceProvider csp = new RSACryptoServiceProvider();
byte [] encryptedData = csp.EncrpytValue(yourData)
string rsaObj = csp.ToXmlString(false); // export RSA object with
private key


Best regards,
Sergey Bogdanov

Tyler Laing

unread,
Jan 12, 2005, 1:51:05 PM1/12/05
to
RSACryptoServiceProvider is designed such that
encrypt can only be done using the public key,
and decrypt can only be done using the private
key. I would like the functionality to do the
opposite.

Thanks

Sergey Bogdanov

unread,
Jan 12, 2005, 2:13:19 PM1/12/05
to
As I correctly understood you, there are two requirements:

1) No one but me could have written that data.
2) The data can not be altered without being corrupted.

The sender has a private key, the recipient has a public key. Before the
sender will send data it uses SignData method to approve that he is
correct author and no one can't modify this data (otherwise a
verification of signature will fail). When the recipient will recieved
data it must call VerifyData to ensure that no one modify this data.

HTH,
Sergey Bogdanov
http://www.sergeybogdanov.com

Tyler Laing

unread,
Jan 12, 2005, 2:49:08 PM1/12/05
to
Hashing is one-way, so if I hashed the data and sent the hash then I couldn't
read the data, but rather just the hash right?

Perhaps I could sign a hash, then send the original data along with the
signed hash. That would be enough to verify that the data is valid and that
it was sent from me.

Thanks

Tyler Laing

unread,
Jan 12, 2005, 3:01:02 PM1/12/05
to
SignData, yes that looks like it will work. If I understand that correctly,
SignData creates a hash of my data, then signs it or rather encrypts the hash
using my private key.

So I would need to send the original data along with the signed hash, the
client could read the original data and also verify it thus satisfying my
requirements.

Thanks

0 new messages