Help changing the KeyExchangeAlgorithm in the .NET RSACryptoServiceProvider class

Posted on 2009-04-23
Last Modified: 2012-05-06
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);


base64encrypted = Convert.ToBase64String(exchange);

Open in new window

Question by:chris45
    1 Comment

    Accepted Solution

    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.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now