I'm at a bit of a loss as to how I can change the RSACryptoServiceProvider's
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);
base64encrypted = Convert.ToBase64String(exchange);