PKCS#11: Implement more token flags that describe available PIN retries.

git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3731 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
martin 2009-09-14 10:05:40 +00:00
parent f6d4da7919
commit a614dff522
2 changed files with 11 additions and 0 deletions

View File

@ -71,6 +71,7 @@ struct sc_pkcs15_pin_info {
u8 pad_char;
struct sc_path path;
int tries_left;
int max_tries;
unsigned int magic;
};

View File

@ -677,6 +677,14 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
snprintf(tmp, sizeof(tmp), "%s", card->label);
}
slot->token_info.flags |= CKF_LOGIN_REQUIRED;
if (pin_info->tries_left >= 0) {
if (pin_info->tries_left == 1)
slot->token_info.flags |= CKF_USER_PIN_FINAL_TRY;
else if (pin_info->tries_left == 0)
slot->token_info.flags |= CKF_USER_PIN_LOCKED;
else if (pin_info->max_tries && pin_info->tries_left && pin_info->tries_left < pin_info->max_tries)
slot->token_info.flags |= CKF_USER_PIN_COUNT_LOW;
}
} else
snprintf(tmp, sizeof(tmp), "%s", card->label);
strcpy_bp(slot->token_info.label, tmp, 32);
@ -689,6 +697,8 @@ static void pkcs15_init_slot(struct sc_pkcs15_card *card,
slot->token_info.ulMaxPinLen = 8;
slot->token_info.ulMinPinLen = 4;
}
if (card->flags & SC_PKCS15_CARD_FLAG_EMULATED)
slot->token_info.flags |= CKF_WRITE_PROTECTED;
sc_debug(context, "Initialized token '%s'\n", tmp);
}