Hi,
Using the RSA-crypto algorithm in .NET , when actually encrypting/decrypting, all the code samples I ran into always used something like, to encrypt :
// create keypair and store in container
CspParameters param = new CspParameters();
param.KeyContainerName = "NewKeyContainer";
param.Flags = CspProviderFlags.UseMachineKeyStore;
RSACryptoServiceProvider rsaObj = new
RSACryptoServiceProvider(param);
// encrypt
byte[] arEncryptedData;
arEncryptedData =
rsaObj.Encrypt(Session("myDataToEncrypt"), False);
Session("encryptedData") = arEncryptedData;
and to decrypt
// get the parameters from the container
CspParameters param = new CspParameters();
param.KeyContainerName = "NewKeyContainer";
param.Flags = CspProviderFlags.UseMachineKeyStore;
RSACryptoServiceProvider rsaObj = new
RSACryptoServiceProvider(param);
// decrypt
byte[] arDecryptedData;
arDecryptedData =
rsaObj.Decrypt(Session("encryptedData"), False)
But, this sample assumes that both the encrypt-part and decrypt-part have access to the SAME keyContainer named "NewKeyContainer" (located on the same machine ???) THIS IS NO REAL-LIFE SCENARIO I would say.
I would like to implement following scenario :
The client encrypts data using ONLY the public-key of the generated keypair and the server decrypts the data using ONLY the private-key and where the client does not the private-key stored on his machine nowhere !!!
How do you do that ???
I think, I'm not sure though, I know how to obtain the separate keys namely using (correct me if I'm wrong)
RSAParameters rsaParam;
rsaParam = rsaObj.ExportParameters(True);
where
rsaParam.Exponent and rsaParam.Modulus are used to encrypt and represent the public key (is this correct what I pretend ?)
and rsaParam.D represents the private key.
But how to use only rsaParam.Exponent and rsaParam.Modulus to encrypt on the client and rsaParam.D on the server ??
thanks very much for any help !!
greetings
Chris
************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...