Check-in [0fda67f954]
Overview
Comment:Updated to support CKF_USER_PIN_FINAL_TRY
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0fda67f954f535b2ae7ab14ffbb7b25e982ece47
User & Date: rkeene on 2010-05-18 14:22:49
Other Links: manifest | tags
Context
2010-05-18
14:28
Updated to always flush stderr check-in: b8b081a8e4 user: rkeene tags: trunk
14:22
Updated to support CKF_USER_PIN_FINAL_TRY check-in: 0fda67f954 user: rkeene tags: trunk
14:11
Updated to keep track of required token flags check-in: 93bbed97eb user: rkeene tags: trunk
Changes

Modified cackey.c from [86c9a91f33] to [53e2f62fc8].

  3703   3703   	CACKEY_DEBUG_PRINTF("Returning CKR_FUNCTION_NOT_SUPPORTED (%i)", CKR_FUNCTION_NOT_SUPPORTED);
  3704   3704   
  3705   3705   	return(CKR_FUNCTION_NOT_SUPPORTED);
  3706   3706   }
  3707   3707   
  3708   3708   CK_DEFINE_FUNCTION(CK_RV, C_Login)(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK_UTF8CHAR_PTR pPin, CK_ULONG ulPinLen) {
  3709   3709   	int mutex_retval;
         3710  +	int tries_remaining;
  3710   3711   	int login_ret;
  3711   3712   
  3712   3713   	CACKEY_DEBUG_PRINTF("Called.");
  3713   3714   
  3714   3715   	if (!cackey_initialized) {
  3715   3716   		CACKEY_DEBUG_PRINTF("Error.  Not initialized.");
  3716   3717   
................................................................................
  3740   3741   		cackey_mutex_unlock(cackey_biglock);
  3741   3742   
  3742   3743   		CACKEY_DEBUG_PRINTF("Error.  Session not active.");
  3743   3744   		
  3744   3745   		return(CKR_SESSION_HANDLE_INVALID);
  3745   3746   	}
  3746   3747   
  3747         -	login_ret = cackey_login(&cackey_slots[cackey_sessions[hSession].slotID], pPin, ulPinLen, NULL);
         3748  +	login_ret = cackey_login(&cackey_slots[cackey_sessions[hSession].slotID], pPin, ulPinLen, &tries_remaining);
  3748   3749   	if (login_ret != CACKEY_PCSC_S_OK) {
  3749   3750   		cackey_mutex_unlock(cackey_biglock);
  3750   3751   
  3751   3752   		if (login_ret == CACKEY_PCSC_E_LOCKED) {
  3752   3753   			CACKEY_DEBUG_PRINTF("Error.  Token is locked.");
  3753   3754   
  3754   3755   			cackey_slots[cackey_sessions[hSession].slotID].token_flags |= CKF_USER_PIN_LOCKED;
  3755   3756   
  3756   3757   			return(CKR_PIN_LOCKED);
  3757   3758   		} else if (login_ret == CACKEY_PCSC_E_BADPIN) {
  3758   3759   			CACKEY_DEBUG_PRINTF("Error.  Invalid PIN.");
  3759   3760   
  3760   3761   			cackey_slots[cackey_sessions[hSession].slotID].token_flags |= CKF_USER_PIN_COUNT_LOW;
         3762  +
         3763  +			if (tries_remaining == 1) {
         3764  +				cackey_slots[cackey_sessions[hSession].slotID].token_flags |= CKF_USER_PIN_FINAL_TRY;
         3765  +			}
  3761   3766   
  3762   3767   			return(CKR_PIN_INCORRECT);
  3763   3768   		}
  3764   3769   
  3765   3770   		CACKEY_DEBUG_PRINTF("Error.  Unknown error returned from cackey_login() (%i)", login_ret);
  3766   3771   
  3767   3772   		return(CKR_GENERAL_ERROR);
  3768   3773   	}
  3769   3774   
  3770         -	cackey_slots[cackey_sessions[hSession].slotID].token_flags &= ~(CKF_USER_PIN_LOCKED | CKF_USER_PIN_COUNT_LOW | CKF_LOGIN_REQUIRED);
         3775  +	cackey_slots[cackey_sessions[hSession].slotID].token_flags &= ~(CKF_USER_PIN_LOCKED | CKF_USER_PIN_COUNT_LOW | CKF_LOGIN_REQUIRED | CKF_USER_PIN_FINAL_TRY);
  3771   3776   
  3772   3777   	cackey_sessions[hSession].state = CKS_RO_USER_FUNCTIONS;
  3773   3778   
  3774   3779   	mutex_retval = cackey_mutex_unlock(cackey_biglock);
  3775   3780   	if (mutex_retval != 0) {
  3776   3781   		CACKEY_DEBUG_PRINTF("Error.  Unlocking failed.");
  3777   3782