C# 如何知道智能卡上保留的pin码号码
我在唱一张智能卡和一个令牌,我有一个代码来检查他们的PIN码,但我想知道如果密码不正确,在被阻止之前仍然保留的PIN码的数目 这是我的代码:C# 如何知道智能卡上保留的pin码号码,c#,rsa,C#,Rsa,我在唱一张智能卡和一个令牌,我有一个代码来检查他们的PIN码,但我想知道如果密码不正确,在被阻止之前仍然保留的PIN码的数目 这是我的代码: public static bool IsValidPasswordForCertificate(X509Certificate2 certificate, string password) { CspParameters csp = new CspParameters(); try { RSACryptoServicePr
public static bool IsValidPasswordForCertificate(X509Certificate2 certificate, string password)
{
CspParameters csp = new CspParameters();
try
{
RSACryptoServiceProvider rsaEncryptor = (RSACryptoServiceProvider)certificate.PrivateKey;
csp.KeyContainerName = rsaEncryptor.CspKeyContainerInfo.KeyContainerName;
csp.ProviderName = rsaEncryptor.CspKeyContainerInfo.ProviderName;
csp.ProviderType = rsaEncryptor.CspKeyContainerInfo.ProviderType;
}
catch (Exception)
{
throw;
}
//Import the password to the csp details
try
{
SecureString secure = new SecureString();
foreach (char c in password)
secure.AppendChar(c);
csp.KeyPassword = secure;
}
catch (Exception)
{
throw;
}
//Try to import the csp and password details to the provider
try
{
RSACryptoServiceProvider prov = new RSACryptoServiceProvider(csp);
}
catch (CryptographicException ex)
{
if (ex.Message.Contains("wrong PIN"))
return false;
}
catch (Exception)
{
throw;
}
return true;
}
如果pin不正确,将抛出加密异常,并在此或之后,了解智能卡/令牌将被阻止之前pin的重试次数。捕获(异常){throw;}阻止的目的是什么?调试?只是为了捕捉任何其他调试异常