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.KeyContai nerName = "NewKeyContaine r";
param.Flags = CspProviderFlag s.UseMachineKey Store;
RSACryptoServic eProvider rsaObj = new
RSACryptoServic eProvider(param );
// encrypt
byte[] arEncryptedData ;
arEncryptedData =
rsaObj.Encrypt( Session("myData ToEncrypt"), False);
Session("encryp tedData") = arEncryptedData ;
and to decrypt
// get the parameters from the container
CspParameters param = new CspParameters() ;
param.KeyContai nerName = "NewKeyContaine r";
param.Flags = CspProviderFlag s.UseMachineKey Store;
RSACryptoServic eProvider rsaObj = new
RSACryptoServic eProvider(param );
// decrypt
byte[] arDecryptedData ;
arDecryptedData =
rsaObj.Decrypt( Session("encryp tedData"), False)
But, this sample assumes that both the encrypt-part and decrypt-part have access to the SAME keyContainer named "NewKeyContaine r" (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.ExportPa rameters(True);
where
rsaParam.Expone nt and rsaParam.Modulu s 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.Expone nt and rsaParam.Modulu s 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...