Have the option add a delay before resending an APDU (after a 6CXX response). Is needed for most current belpic cards on fast readers

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2117 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
sth 2005-01-30 19:20:38 +00:00
parent 5e0453fb8a
commit b59fb4597e
4 changed files with 12 additions and 2 deletions

View File

@ -54,8 +54,6 @@
#define PATH_MAX _MAX_PATH
#define sleep(t) Sleep((t) * 1000)
#ifndef VERSION
#define VERSION "0.9.4"
#endif

View File

@ -1008,6 +1008,11 @@ static int belpic_init(struct sc_card *card)
SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE, 0);
}
/* V1 applets have a problem: if the card sends a 6C XX (only XX bytes available),
* and we resend the command too soon (i.e. the reader is too fast), the card
* doesn't respond. So we build in a delay. */
card->wait_resend_apdu = 40;
/* State that we have an RNG */
card->caps |= SC_CARD_CAP_RNG;

View File

@ -260,6 +260,9 @@ int sc_transmit_apdu(struct sc_card *card, struct sc_apdu *apdu)
if (apdu->sw1 == 0x6C && apdu->resplen == 0) {
apdu->resplen = orig_resplen;
apdu->le = apdu->sw2;
/* Fix for cards (e.g. belpic) that need a delay on fast readers */
if (card->wait_resend_apdu != 0)
msleep(card->wait_resend_apdu);
r = sc_transceive(card, apdu);
if (r != 0) {
sc_unlock(card);

View File

@ -179,8 +179,11 @@ extern "C" {
/* A 64-bit uint, used in sc_current_time() */
#ifndef _WIN32
typedef unsigned long long sc_timestamp_t;
#define msleep(t) usleep((t) * 1000)
#else
typedef unsigned __int64 sc_timestamp_t;
#define msleep(t) Sleep(t)
#define sleep(t) Sleep((t) * 1000)
#endif
/* Event masks for sc_wait_for_event() */
@ -440,6 +443,7 @@ struct sc_card {
struct sc_slot_info *slot;
unsigned long caps, flags;
unsigned int wait_resend_apdu; /* Delay (msec) before responding to an SW12 = 6CXX */
int cla;
u8 atr[SC_MAX_ATR_SIZE];
size_t atr_len;