diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2020-09-28 06:29:51 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2020-09-28 06:29:51 +0200 |
commit | 684a52dffa8b7f79b26fe53b3ab10d7748a8fb37 (patch) | |
tree | faee17a4e9bceeea9e43412a3fc9c4d5d1b157f3 /scd/ccid-driver.c | |
parent | keyboxd: Make use of the config table (diff) | |
download | gnupg2-684a52dffa8b7f79b26fe53b3ab10d7748a8fb37.tar.xz gnupg2-684a52dffa8b7f79b26fe53b3ab10d7748a8fb37.zip |
scd: Change handling of SPR532 card reader.
* scd/ccid-driver.c (ccid_vendor_specific_init): Put some workaround
for SPR532 initialization.
(ccid_slot_status): Send ESCape command after GetSlotStatus.
GnuPG-bug-id: 5065
Fixes-commit: 4fae55f8ee11b3f710524e5e8b8a91b159949f2d
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd/ccid-driver.c')
-rw-r--r-- | scd/ccid-driver.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c index 345d385dd..888d70367 100644 --- a/scd/ccid-driver.c +++ b/scd/ccid-driver.c @@ -1272,9 +1272,14 @@ ccid_vendor_specific_init (ccid_driver_t handle) } else if (handle->id_vendor == VENDOR_SCM) { - DEBUGOUT ("sending escape sequence to switch to a case 1 APDU\n"); - r = send_escape_cmd (handle, (const unsigned char*)"\x80\x02\x00", 3, - NULL, 0, NULL); + /* + * It seems that SEQ may be out of sync between host and the card reader, + * and SET_INTERFACE doesn't reset it. Make sure it works at the init. + */ + abort_cmd (handle, 0); + r = libusb_clear_halt (handle->idev, handle->ep_intr); + DEBUGOUT_1 ("libusb_clear_halt intr: %s\n", libusb_error_name (r)); + r = 0; } if (r != 0 && r != CCID_DRIVER_ERR_CARD_INACTIVE @@ -2407,7 +2412,15 @@ ccid_slot_status (ccid_driver_t handle, int *statusbits, int on_wire) /* Setup interrupt transfer at the initial call of slot_status with ON_WIRE == 0 */ if (handle->transfer == NULL && handle->ep_intr >= 0) - ccid_setup_intr (handle); + { + ccid_setup_intr (handle); + if (handle->id_vendor == VENDOR_SCM) + { + DEBUGOUT ("sending escape sequence to switch to a case 1 APDU\n"); + send_escape_cmd (handle, (const unsigned char*)"\x80\x02\x00", 3, + NULL, 0, NULL); + } + } *statusbits = 0; return 0; |