473,386 Members | 1,943 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,386 software developers and data experts.

RSACryptoServiceProvider public/private-key question

Hi Guys, (sorry for my bad english)

i have a question for the following problem:

With the RSACryptoServiceProvider object...

Application A:
// Generate a public/private key pair.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(512);

this.initSettings.privatekey = rsa.ToXmlString(true);
this.tbxPublicKeyValue.Text = rsa.ToXmlString(false);

....i create a key pair in applikation A (client) and export this as XML string contains the public and the private part.

(this.initSettings.privatekey = rsa.ToXmlString(true)) from the keys for application A. I use this key part to encrypt.

and the public part (this.tbxPublicKeyValue.Text = rsa.ToXmlString(false)) for application B (PKI-server dummy) to decrypt.
Now i copied the public part (this.tbxPublicKeyValue.Text) to the Source from application B and import the xml-string:

Application B:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(512);
rsa.FromXmlString("<RSAKeyValue><Modulus>p9it6uYAD kh+3QSowBGeIIn8rrBykGG7iAMZXpLZiPlbWcFeySCT9IrcA/C3DjW2qcDsjoR45l87SAHcFktCGw==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
if i use encrytion in application A, the stored (as xml-string) public/private part (this.initSettings.privatekey) is imported :

// Generate a public/private key pair.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(512);
rsa.FromXmlString(this.initSettings.privatekey);
With this imported key(s) a byte-array are encrypted:

byte[] signchallenge = rsa.Encrypt(challengeRi, false);

and after send the array to application B should be decrypted:

try
{
decResult = rsa.Decrypt(signature, false);
}
catch (Exception ex)
{
this.SetEntry(ex.Message);
continue;
}

My problem, by the decryption i get the exception "invalid key"....

I copy the public/private part (this.initSettings.privatekey-string) to the import-method from the RSA objekts in application B then
the decryption is ok.

Many thanks for your help and
any guides greatly appreciated
Olli

May 4 '07 #1
0 2436

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

Similar topics

1
by: Marian Dvorsky | last post by:
There are two methods in RSACryptoServiceProvider to verify signed data: VerifyData(byte buffer, object halg, byte signature) VerifyHash(byte rgbHash, string str, byte rgbSignature) What is...
0
by: Sam johnson | last post by:
Hi I'm using the RSACryptoServiceProvider class in one of my applications, but I still don't know what to enter as a first param in the following construction dim rsa as new...
3
by: quo | last post by:
two questions: 1) Does this program demonstrate the basic difference between public and private access? It appears correct to say that instances of a class cannot directly call a private...
19
by: qazmlp | last post by:
class base { // other members public: virtual ~base() { } virtual void virtualMethod1()=0 ; virtual void virtualMethod2()=0 ; virtual void virtualMethod3()=0 ;
3
by: DaveLessnau | last post by:
In a book on Data Structures that I'm reading, the authors are describing various linked lists and trees. In these, they start with some form of node class. What's driving me crazy is that they...
0
by: HoloDoc | last post by:
Using VB.NET 2003 with .NET 1.1. I am using RSACryptoServiceProvider to encrypt various information. This generally is fine. As part of development for Arabic, i changed option: Control Panel...
10
by: darrel | last post by:
I'm still trying to sort out in my head the differences between public and shared when referring to declaring properties or variables. This is my understanding: shared - akin to a 'global'...
4
by: funVB2005fun | last post by:
I am not quite sure what I am getting into but I would like to have a loop that read from a flat file to create some public properties in a class. I am going after this to try and create more...
2
by: =?Utf-8?B?R2FicmllbCBNw6luZGV6?= | last post by:
Hello everyone. I have a small class that encapsulates some functionallity to work with the RSACryptoServiceProvider. Here is the code of the class i'm using: public class dsRSA { private...
0
by: NavinJ | last post by:
I want to encrypt an object of my Windows Forms application using RSACryptoServiceProvider class and then serialize the encrypted object. The problem is, the RSACryptoServiceProvider.Encrypt()...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.