473,411 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

RSA Encrypt/Decrypt with OAEP.

Hi All,
I am trying to do encryption/decryption with RSA.

For encryption, I use the public key. For decryption, I use the private
key. The idea is to take a 80 byte array and encrypt it and then
decrypt that result to get the original 80 byte array. However, when I
do the decryption I am getting a "Error occurred while decoding OAEP
padding." CryptoGraphicException.
byte[] RSAResult = RSA.Encrypt(dataToDecrypt,true);

encryptedData = rsaCSP.Decrypt(dataToEncrypt, true);
I have tried using false for the OAEP parameter (all combinations) but
that only gets bad key or bad data exceptions. I looked on google and I
didn't find too much on this topic except an article suggesting having
the same size buffer which I did keep the same size.
The wierd thing is that I am doing the exact same piece of code at the
beginning of my program and it works. This code is called again in the
middle of my app and it fails. Too wierd.
Any ideas or suggestions?

Thanks guys.
Sushant Bhatia

Nov 17 '05 #1
3 5865
Sushant,
You should not cross-post your questions. And you should never cross-post
your question in so many groups!

From the description you gave, I'm quite confident that its just a bug in
your own code. However I'll refrain from further conversation on that
subject as long as it will be cross-posted.

-Valery.
http://www.harper.no/valery

"Sushant Bhatia" <su************@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hi All,
I am trying to do encryption/decryption with RSA.

For encryption, I use the public key. For decryption, I use the private
key. The idea is to take a 80 byte array and encrypt it and then
decrypt that result to get the original 80 byte array. However, when I
do the decryption I am getting a "Error occurred while decoding OAEP
padding." CryptoGraphicException.
byte[] RSAResult = RSA.Encrypt(dataToDecrypt,true);

encryptedData = rsaCSP.Decrypt(dataToEncrypt, true);
I have tried using false for the OAEP parameter (all combinations) but
that only gets bad key or bad data exceptions. I looked on google and I
didn't find too much on this topic except an article suggesting having
the same size buffer which I did keep the same size.
The wierd thing is that I am doing the exact same piece of code at the
beginning of my program and it works. This code is called again in the
middle of my app and it fails. Too wierd.
Any ideas or suggestions?

Thanks guys.
Sushant Bhatia


Nov 17 '05 #2
Hehe. Sorry. Its my first massive cross post. How do I undo?

Nov 17 '05 #3
Damn. I see why you said cross posting is bad. All posts to this one
thread are going to all the threads and its becoming big. Sorry google
groups. I'm trying to do an individual reply to this post only so that
the rest of them just die out.
Ps. Still looking for any suggestions to my wierd problem with OAEP
padding. Thanks.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: wqhdebian | last post by:
As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does...
4
by: Spikinsson | last post by:
I'm looking for a good decrypt/encrypt function, all I want is a function in this form: char* encrypt(char* normal) { ... return encrypted; } and
1
by: Benoît | last post by:
Hi, I have generated two keys : "C:>openssl req -nodes -new -x509 -keyout ben.key -out ben.crt -days 3650" I try to encrypt/decrypt a string like "JOHN" with these asymetrics keys. With the...
7
by: Matthias S. | last post by:
Hi, I had a look at the vast information on encryption in the MSDN and got pretty confused. All I want to do is to encrypt a string into an encrypted string and later decrypt that (encrypted)...
8
by: Gidi | last post by:
Hi, Is there Buid-In fuction in C# that Encrypt and Decrypt strings? i have a textbox which i'm writing into file, and i want to encrypt it before writing, i'm not looking for something fancy,...
8
by: toupeira23 | last post by:
Hello, I'm trying to encrypt passwords in my app. After discovering that there's no simple function to do this, I wrote a wrapper class which decodes a string using UTF8, encrypts it with...
4
by: Islamegy® | last post by:
I give up.. I tried everything to encrypt querystring and decrypt it back but this never success.. i use RSA encryption. I always get excption when Convert fromBase64String so i tried...
0
by: Ismail Fatih Yýldýrým | last post by:
I modified the RSACSPSample from MSDN to try out a simple commutative encryption model using RSA encryption but when i run the progrem the first encryption command works but during the second...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.