问题
One of my client needs a tool to decrypt their emails.
They are using smart card for encryption/decryption.
As of now they are using a tool which asks them to enter their PUBLIC KEY. After giving a valid PUBLIC KEY, combination of PUBLIC and PRIVATE KEYS on SMART CARD will help them to decrypt their emails.
We are working on a tool which could be a windows service(which runs in the background) and decrypt all the emails with our prompting the user for public key again and again.
We are using C# to develop this tool and from the blogs I got to know that we need to Microsoft CSP to achieve this functionality. I think the below code will be able to use the smart card container and read the private key. But I am not sure how to provide the public key to this and decrypt the email.
CspParameters csp = new CspParameters(1, "Microsoft Base Smart Card Crypto Provider");
// CspParameters csp = new CspParameters(1, "Microsoft Strong Cryptographic Provider");
csp.Flags = CspProviderFlags.UseDefaultKeyContainer;
// Initialize an RSACryptoServiceProvider object using
// the CspParameters object.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
Can anybody correct me if I am in a wrong direction? And also please shed some light to proceed further.
来源:https://stackoverflow.com/questions/18189138/c-sharp-decrypt-emails-by-reading-keys-on-smart-card