O
Olli Goessler
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>p9it6uYADkh+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
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>p9it6uYADkh+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