Background: I have been provided with a private key (XXX.key) and its password. Also, I have an application that was developed for PocketPC that uses windows mobile 6 (.NET Compact Edition 3.5). Scenario: I need to sign a message using the following steps: 1. Encrypt the message using SHA1 algorithm. 2. With the private key provided, sign the digestion using RSA Algorithm. 3. Convert the result to its equivalent string representation encoded with base 64 digits. I am able to implement the first step with the following lines:
// Step 1
string message = "this message will be encrypted";
byte[] messageBytes = Encoding.UTF8.GetBytes(message);
SHA1 sha1 = SHA1.Create();
byte[] digestion = sha1.ComputeHash(messageBytes, 0, messageBytes.Length);
// Step 2 Here I need to sign with the private key.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
// Step 3
string signedMessage = Convert.ToBase64String();
It is worth to mention that these steps MUST be implemented in the app for the Pocket which doesn’t have access to internet. My problem is that I don’t know how put the private key in the RSA algorithm. Also, I’m not an expert in security stuff. Please, do not tell me why I need to do this in this way; I didn’t design it this way. Does anyone know to implement the second step?? Thanks in advance.