Hello,
I am using a code like the one below in ASP .NET as I am signing a string with a random generated RSAParameters. I would like to use prive and public keys from a .pfx file, located on the server. How can I import the keys into the RSAParameters
private
void Page_Load(object sender, System.EventArgs e){
if
(!IsPostBack){
RSACryptoServiceProvider rCSP =
new RSACryptoServiceProvider();RSAParameters rsaPrivateParam =
new RSAParameters();rsaPrivateParam = rCSP.ExportParameters(
true); Session["param"] = rsaPrivateParam;}
byte[] result; byte[] strToSign;RSACryptoServiceProvider rsaCSP =
new RSACryptoServiceProvider();strToSign = generateHash("This is the string to sign");
RSAParameters rsaPrivateParams =
new RSAParameters();rsaPrivateParams = (RSAParameters) Session["param"];
rsaCSP.ImportParameters(rsaPrivateParams);
result = rsaCSP.SignHash(strToSign, CryptoConfig.MapNameToOID("SHA1"));
}private
byte[] generateHash(string MessageString){
byte[] HashValue;UnicodeEncoding UE =
new UnicodeEncoding(); byte[] MessageBytes = UE.GetBytes(MessageString);SHA1Managed SHhash =
new SHA1Managed();HashValue = SHhash.ComputeHash(MessageBytes);
return HashValue;}
Thanks,
Alex

How to import public and prive key in RSA parameters
wooks
You can use the X509Certificate2 class to open a PFX file. That will expose both a PublicKey and PrivateKey property, which has the RSA key data you need to do your encryption.
-Shawn
Perseid