scd:ccid-driver: Fix pinpad error handling for cancel/timeout.

* scd/apdu.h (SW_HOST_UI_CANCELLED, SW_HOST_UI_TIMEOUT): New.
* scd/ccid-driver.h (CCID_DRIVER_ERR_UI_CANCELLED): New.
(CCID_DRIVER_ERR_UI_TIMEOUT): New.
* scd/ccid-driver.c (bulk_in): Handle PIN input cancel/timeout error.
* scd/iso7816.c (map_sw): Support SW_HOST_UI_CANCELLED and
SW_HOST_UI_TIMEOUT.

--

GnuPG-bug-id: 4614
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2020-11-27 15:17:56 +09:00
parent 7113263a00
commit bb591222c3
4 changed files with 17 additions and 2 deletions

View File

@ -81,7 +81,9 @@ enum {
SW_HOST_USB_NO_DEVICE = 0x10024,
SW_HOST_USB_BUSY = 0x10026,
SW_HOST_USB_TIMEOUT = 0x10027,
SW_HOST_USB_OVERFLOW = 0x10028
SW_HOST_USB_OVERFLOW = 0x10028,
SW_HOST_UI_CANCELLED = 0x10030,
SW_HOST_UI_TIMEOUT = 0x10031
};
struct dev_list;

View File

@ -2148,7 +2148,16 @@ bulk_in (ccid_driver_t handle, unsigned char *buffer, size_t length,
}
}
if (CCID_COMMAND_FAILED (buffer))
print_command_failed (buffer);
{
int ec;
ec = CCID_ERROR_CODE (buffer);
print_command_failed (buffer);
if (ec == 0xEF)
return CCID_DRIVER_ERR_UI_CANCELLED;
else if (ec == 0xF0)
return CCID_DRIVER_ERR_UI_TIMEOUT;
}
/* Check whether a card is at all available. Note: If you add new
error codes here, check whether they need to be ignored in

View File

@ -116,6 +116,8 @@ enum {
#define CCID_DRIVER_ERR_USB_BUSY 0x10026
#define CCID_DRIVER_ERR_USB_TIMEOUT 0x10027
#define CCID_DRIVER_ERR_USB_OVERFLOW 0x10028
#define CCID_DRIVER_ERR_UI_CANCELLED 0x10030
#define CCID_DRIVER_ERR_UI_TIMEOUT 0x10031
struct ccid_driver_s;
typedef struct ccid_driver_s *ccid_driver_t;

View File

@ -96,6 +96,8 @@ map_sw (int sw)
case SW_HOST_USB_BUSY: ec = GPG_ERR_EBUSY; break;
case SW_HOST_USB_TIMEOUT: ec = GPG_ERR_TIMEOUT; break;
case SW_HOST_USB_OVERFLOW: ec = GPG_ERR_EOVERFLOW; break;
case SW_HOST_UI_CANCELLED: ec = GPG_ERR_CANCELED; break;
case SW_HOST_UI_TIMEOUT: ec = GPG_ERR_TIMEOUT; break;
default:
if ((sw & 0x010000))