aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2020-11-27 15:17:56 +0900
committerNIIBE Yutaka <gniibe@fsij.org>2020-11-27 15:17:56 +0900
commitbb591222c3c5cb1a1750b1b1dd26d0bc53b347cb (patch)
tree016dbb5c3fed3c99e6a3ef361513b1d4e15d45be
parent7113263a00d8c9b09f0dfdb9590bfe2bab1bc776 (diff)
downloadgnupg-bb591222c3c5cb1a1750b1b1dd26d0bc53b347cb.tar.gz
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>
-rw-r--r--scd/apdu.h4
-rw-r--r--scd/ccid-driver.c11
-rw-r--r--scd/ccid-driver.h2
-rw-r--r--scd/iso7816.c2
4 files changed, 17 insertions, 2 deletions
diff --git a/scd/apdu.h b/scd/apdu.h
index 7c23e02fd..d042c7cde 100644
--- a/scd/apdu.h
+++ b/scd/apdu.h
@@ -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;
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c
index eed8e0320..021f9ac64 100644
--- a/scd/ccid-driver.c
+++ b/scd/ccid-driver.c
@@ -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
diff --git a/scd/ccid-driver.h b/scd/ccid-driver.h
index 232483544..18cbc87f0 100644
--- a/scd/ccid-driver.h
+++ b/scd/ccid-driver.h
@@ -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;
diff --git a/scd/iso7816.c b/scd/iso7816.c
index ef02d64cc..f14c14f69 100644
--- a/scd/iso7816.c
+++ b/scd/iso7816.c
@@ -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))