diff options
author | Jakub Jelen <jjelen@redhat.com> | 2019-06-10 15:08:24 +0200 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2019-07-04 16:05:09 +0200 |
commit | fac5b61fbcc17647a89d216fa927d6ee7cd5dcc7 (patch) | |
tree | 3d8a9deaa82cb078414dcd8e94f5f78c2a0e5f67 /src | |
parent | 1c00b79c9e6e616b27169fc296ce542b69fb3634 (diff) |
When we talk with Windows drivers, pretend to know how much pin prompts remains
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/card_7816.c | 2 | ||||
-rw-r--r-- | src/msft.c | 2 | ||||
-rw-r--r-- | src/vcard.c | 21 | ||||
-rw-r--r-- | src/vcard.h | 4 | ||||
-rw-r--r-- | src/vcardt.h | 2 |
5 files changed, 30 insertions, 1 deletions
diff --git a/src/card_7816.c b/src/card_7816.c index 4309361..6dd4dae 100644 --- a/src/card_7816.c +++ b/src/card_7816.c @@ -707,7 +707,7 @@ vcard7816_vm_process_apdu(VCard *card, VCardAPDU *apdu, break; } /* handle pin count if possible (not possible now) */ - count = vcard_emul_get_login_count(card); + count = vcard_get_login_count(card); if (count < 0) { *response = vcard_make_response( VCARD7816_STATUS_ERROR_DATA_NOT_FOUND); @@ -48,6 +48,8 @@ msft_applet_container_process_apdu(VCard *card, VCardAPDU *apdu, /* Windows proprietary tag */ tag = (apdu->a_p1 & 0xff) << 8 | (apdu->a_p2 & 0xff); if (tag == 0x7f68) { + /* Assuming the driver is on Windows */ + vcard_set_compat(card, VCARD_COMPAT_WINDOWS); *response = vcard_response_new(card, msft_get_data, sizeof(msft_get_data), apdu->a_Le, VCARD7816_STATUS_SUCCESS); ret = VCARD_DONE; diff --git a/src/vcard.c b/src/vcard.c index e94ee5d..e178c0e 100644 --- a/src/vcard.c +++ b/src/vcard.c @@ -32,6 +32,7 @@ struct VCardStruct { VCardEmul *vcard_private; VCardEmulFree vcard_private_free; VCardGetAtr vcard_get_atr; + unsigned int compat; }; VCardBufferResponse * @@ -323,3 +324,23 @@ vcard_get_private(VCard *vcard) return vcard->vcard_private; } +/* Get remaining login count for the current card */ +int +vcard_get_login_count(VCard *card) +{ + int rv = vcard_emul_get_login_count(card); + + /* Windows drivers are not very happy with the answer we can give here + * so lets assume the card still have all the attempts unlocked here */ + if (rv == -1 && card->compat & VCARD_COMPAT_WINDOWS) { + return 3; + } + return rv; +} + +/* Set compat bits for the given cards. See VCARD_COMPAT_* options */ +void +vcard_set_compat(VCard *card, unsigned int set) +{ + card->compat |= set; +} diff --git a/src/vcard.h b/src/vcard.h index 46bbb74..a524bcd 100644 --- a/src/vcard.h +++ b/src/vcard.h @@ -82,5 +82,9 @@ void vcard_set_buffer_response(VCard *card, VCardBufferResponse *buffer); VCardType vcard_get_type(VCard *card); /* get the private data */ VCardEmul *vcard_get_private(VCard *card); +/* Get remaining login count for the current card */ +int vcard_get_login_count(VCard *card); +/* Set compat bits for the given cards. See VCARD_COMPAT_* options */ +void vcard_set_compat(VCard *card, unsigned int set); #endif diff --git a/src/vcardt.h b/src/vcardt.h index 0589d13..e70d665 100644 --- a/src/vcardt.h +++ b/src/vcardt.h @@ -14,6 +14,8 @@ #define MAX(x, y) ((x) > (y) ? (x) : (y)) #endif +#define VCARD_COMPAT_WINDOWS 0x01 + typedef struct VCardStruct VCard; typedef struct VCardAPDUStruct VCardAPDU; typedef struct VCardResponseStruct VCardResponse; |