summaryrefslogtreecommitdiffstats
path: root/scd/ccid-driver.c
diff options
context:
space:
mode:
authorNIIBE Yutaka <gniibe@fsij.org>2019-04-04 08:58:21 +0200
committerNIIBE Yutaka <gniibe@fsij.org>2019-04-04 08:58:21 +0200
commitf1cf799a37f320d33cae445c74f3fc1936dd9995 (patch)
tree5d2cfb94a1d66f6da47e97f72bfdd7d05caddf03 /scd/ccid-driver.c
parentgpg: Improve the code to decrypt using PIV cards. (diff)
downloadgnupg2-f1cf799a37f320d33cae445c74f3fc1936dd9995.tar.xz
gnupg2-f1cf799a37f320d33cae445c74f3fc1936dd9995.zip
scd: Better handling of timeout and time extension.
* scd/ccid-driver.c (CCID_CMD_TIMEOUT_LONGER): Remove. (ccid_transceive): Don't use x4 blindly for bBWI, but use dynamically determined value. Use value from variable wait_more for bulk_in. Set wait_more by the value of time extension request. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd/ccid-driver.c')
-rw-r--r--scd/ccid-driver.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/scd/ccid-driver.c b/scd/ccid-driver.c
index 69df17355..dca8340ba 100644
--- a/scd/ccid-driver.c
+++ b/scd/ccid-driver.c
@@ -110,8 +110,6 @@
/* CCID command timeout. */
#define CCID_CMD_TIMEOUT (5*1000)
-/* OpenPGPcard v2.1 requires huge timeout for key generation. */
-#define CCID_CMD_TIMEOUT_LONGER (60*1000)
/* Depending on how this source is used we either define our error
output to go to stderr or to the GnuPG based logging functions. We
@@ -3094,7 +3092,7 @@ ccid_transceive (ccid_driver_t handle,
msg[0] = PC_to_RDR_XfrBlock;
msg[5] = 0; /* slot */
msg[6] = seqno = handle->seqno++;
- msg[7] = 4; /* bBWI */
+ msg[7] = (wait_more ? wait_more : 1); /* bBWI */
msg[8] = 0; /* RFU */
msg[9] = 0; /* RFU */
set_msg_len (msg, tpdulen);
@@ -3120,7 +3118,7 @@ ccid_transceive (ccid_driver_t handle,
msg = recv_buffer;
rc = bulk_in (handle, msg, sizeof recv_buffer, &msglen,
via_escape? RDR_to_PC_Escape : RDR_to_PC_DataBlock, seqno,
- wait_more? CCID_CMD_TIMEOUT_LONGER: CCID_CMD_TIMEOUT, 0);
+ (wait_more ? wait_more : 1) * CCID_CMD_TIMEOUT, 0);
if (rc)
return rc;
@@ -3150,6 +3148,7 @@ ccid_transceive (ccid_driver_t handle,
(!(msg[pcboff] & 0x80) && (msg[pcboff] & 0x20)?
" [more]":""));
+ wait_more = 0;
if (!(tpdu[1] & 0x80))
{ /* This is an I-block. */
retries = 0;
@@ -3295,9 +3294,7 @@ ccid_transceive (ccid_driver_t handle,
/* Wait time extension request. */
unsigned char bwi = tpdu[3];
- /* Check if it's unusual value which can't be expressed in ATR. */
- if (bwi > 15)
- wait_more = 1;
+ wait_more = bwi;
msg = send_buffer;
tpdu = msg + hdrlen;