c# - How to know the numbers of pin code remained on a smart card -
i'm sing smart card , token , have code checks pin code them, want catch number of pin remains until blocked if password incorrect.
this code:
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 password csp details try { securestring secure = new securestring(); foreach (char c in password) secure.appendchar(c); csp.keypassword = secure; } catch (exception) { throw; } //try import csp , password details provider try { rsacryptoserviceprovider prov = new rsacryptoserviceprovider(csp); } catch (cryptographicexception ex) { if (ex.message.contains("wrong pin")) return false; } catch (exception) { throw; } return true; }
if pin incorrect, cryptographicexception thrown, , in or after this, know numbers of retries pin that's left until smart card/token block.
Comments
Post a Comment