簡體   English   中英

如何使用PKCS11Interop獲取加密令牌(Smartcard)的密碼失敗計數

[英]How to get password failure count of crypto token (Smartcard) using PKCS11Interop

我有.Net應用程序,可以使用PKCS11Interop庫與加密令牌(智能卡)進行交互,用戶可以在其中登錄令牌並生成密鑰對和簽名。

如果用戶輸入了錯誤的密碼,則多次令牌將被鎖定,我如何才能獲得嘗試登錄令牌的剩余次數。

在互聯網上搜索時,我遇到了Net.Pkcs11Interop.HighLevelAPI.TokenInfo.TokenFlags,其中包含此信息

CKF_USER_PIN_COUNT_LOW 0x00010000 True if an incorrect user login
PIN has been entered at least
once since the last successful
authentication.
CKF_USER_PIN_FINAL_TRY 0x00020000 True if supplying an incorrect
user PIN will cause it to
become locked.
CKF_USER_PIN_LOCKED 0x00040000 True if the user PIN has been locked. User login to the token
is not possible

但是這些是布爾值,我需要剩下的確切重試次數。

PKCS#11 API沒有提供剩余的確切重試次數。 如您TokenFlags ,它確實通過TokenFlags提供了類似的信息:

// Get token info
TokenInfo tokenInfo = slot.GetTokenInfo();

if (tokenInfo.TokenFlags.UserPinCountLow)
{
    // An incorrect user login PIN has been entered at least once since the last successful authentication
}

if (tokenInfo.TokenFlags.UserPinFinalTry)
{
    // Supplying an incorrect user PIN will make it to become locked
}

if (tokenInfo.TokenFlags.UserPinLocked)
{
    // User PIN has been locked. User login to the token is not possible.
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM