C# Decrypt emails by reading keys on smart card

大城市里の小女人 提交于 2019-12-11 06:06:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!