Help changing the KeyExchangeAlgorithm in the .NET RSACryptoServiceProvider class

Hi All,

I'm at a bit of a loss as to how I can change the RSACryptoServiceProvider's KeyExchangeAlgorithm property.

To give you some background, I am building an application that will contain the public key of our server. This application encrypts messages using that public key and then sends them off to our server. The problem is that I am using keyczar (PyCrypto) which is a python RSA library that requires the key exchange/padding to be OAEP. Unfortunately the RSACryptoServiceProvider by default uses some version of the PKCS approach (not sure which one).

Basically this results in the following error message when my server tries to decrypt messages from this application:
"KeyczarError: OAEP Decoding Error - hash is invalid"

If anybody out there is able to shed some light on this problem and help me out I would greatly appreciate it.
// this doesn't work it appears to still use the KeyExchangeAlgorithm specified in the rsa object
byte[] data = Encoding.Unicode.GetBytes("Some Message");
RSAOAEPKeyExchangeFormatter formatter = new RSAOAEPKeyExchangeFormatter(rsa);
byte[] exchange = formatter.CreateKeyExchange(data);
Array.Reverse(exchange);
base64encrypted = Convert.ToBase64String(exchange);

Open in new window

chris45Asked:
Who is Participating?
 
chris45Connect With a Mentor Author Commented:
I'm closing this question as I have had no responses and have decided to approach the problem a different way. If anyone comes across this question and is having similar issues, I found the Keyczar group to be quite helpful even though I have changed my approach.
http://groups.google.com/group/keyczar-discuss
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.