mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
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>
This commit is contained in:
parent
2c9b68f28d
commit
f1cf799a37
@ -110,8 +110,6 @@
|
|||||||
|
|
||||||
/* CCID command timeout. */
|
/* CCID command timeout. */
|
||||||
#define CCID_CMD_TIMEOUT (5*1000)
|
#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
|
/* 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
|
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[0] = PC_to_RDR_XfrBlock;
|
||||||
msg[5] = 0; /* slot */
|
msg[5] = 0; /* slot */
|
||||||
msg[6] = seqno = handle->seqno++;
|
msg[6] = seqno = handle->seqno++;
|
||||||
msg[7] = 4; /* bBWI */
|
msg[7] = (wait_more ? wait_more : 1); /* bBWI */
|
||||||
msg[8] = 0; /* RFU */
|
msg[8] = 0; /* RFU */
|
||||||
msg[9] = 0; /* RFU */
|
msg[9] = 0; /* RFU */
|
||||||
set_msg_len (msg, tpdulen);
|
set_msg_len (msg, tpdulen);
|
||||||
@ -3120,7 +3118,7 @@ ccid_transceive (ccid_driver_t handle,
|
|||||||
msg = recv_buffer;
|
msg = recv_buffer;
|
||||||
rc = bulk_in (handle, msg, sizeof recv_buffer, &msglen,
|
rc = bulk_in (handle, msg, sizeof recv_buffer, &msglen,
|
||||||
via_escape? RDR_to_PC_Escape : RDR_to_PC_DataBlock, seqno,
|
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)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -3150,6 +3148,7 @@ ccid_transceive (ccid_driver_t handle,
|
|||||||
(!(msg[pcboff] & 0x80) && (msg[pcboff] & 0x20)?
|
(!(msg[pcboff] & 0x80) && (msg[pcboff] & 0x20)?
|
||||||
" [more]":""));
|
" [more]":""));
|
||||||
|
|
||||||
|
wait_more = 0;
|
||||||
if (!(tpdu[1] & 0x80))
|
if (!(tpdu[1] & 0x80))
|
||||||
{ /* This is an I-block. */
|
{ /* This is an I-block. */
|
||||||
retries = 0;
|
retries = 0;
|
||||||
@ -3295,9 +3294,7 @@ ccid_transceive (ccid_driver_t handle,
|
|||||||
/* Wait time extension request. */
|
/* Wait time extension request. */
|
||||||
unsigned char bwi = tpdu[3];
|
unsigned char bwi = tpdu[3];
|
||||||
|
|
||||||
/* Check if it's unusual value which can't be expressed in ATR. */
|
wait_more = bwi;
|
||||||
if (bwi > 15)
|
|
||||||
wait_more = 1;
|
|
||||||
|
|
||||||
msg = send_buffer;
|
msg = send_buffer;
|
||||||
tpdu = msg + hdrlen;
|
tpdu = msg + hdrlen;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user