Ticket #1: 2046.patch

File 2046.patch, 3.2 KB (added by aj, 7 years ago)

this patch from HEAD propably fixes the issue

  • opensc/src/include/winconfig.h

    ---------------------
    PatchSet 2046 
    Date: 1970/01/01 01:33:25
    Author: sth
    Branch: HEAD
    Tag: (none) 
    Log:
    Have the option add a delay before resending an APDU (after a 6CXX response). Is needed for most current belpic cards on fast readers
    
    Members: 
    	src/include/winconfig.h:1.17->1.18 
    	src/libopensc/card-belpic.c:1.3->1.4 
    	src/libopensc/card.c:1.73->1.74 
    	src/libopensc/opensc.h:1.143->1.144 
    
    RCS file: /cvsroot/opensc/src/include/winconfig.h,v
    retrieving revision 1.17
    retrieving revision 1.18
    diff -u -r1.17 -r1.18
     
    5454 
    5555#define PATH_MAX _MAX_PATH 
    5656 
    57 #define sleep(t) Sleep((t) * 1000) 
    58  
    5957#ifndef VERSION 
    6058#define VERSION "0.9.4" 
    6159#endif 
  • opensc/src/libopensc/card-belpic.c

    RCS file: /cvsroot/opensc/src/libopensc/card-belpic.c,v
    retrieving revision 1.3
    retrieving revision 1.4
    diff -u -r1.3 -r1.4
     
    10081008                                     SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE, 0); 
    10091009        } 
    10101010 
     1011        /* V1 applets have a problem: if the card sends a 6C XX (only XX bytes available), 
     1012         * and we resend the command too soon (i.e. the reader is too fast), the card 
     1013         * doesn't respond. So we build in a delay. */ 
     1014        card->wait_resend_apdu = 40; 
     1015 
    10111016        /* State that we have an RNG */ 
    10121017        card->caps |= SC_CARD_CAP_RNG; 
    10131018 
  • opensc/src/libopensc/card.c

    RCS file: /cvsroot/opensc/src/libopensc/card.c,v
    retrieving revision 1.73
    retrieving revision 1.74
    diff -u -r1.73 -r1.74
     
    260260        if (apdu->sw1 == 0x6C && apdu->resplen == 0) { 
    261261                apdu->resplen = orig_resplen; 
    262262                apdu->le = apdu->sw2; 
     263                /* Fix for cards (e.g. belpic) that need a delay on fast readers */ 
     264                if (card->wait_resend_apdu != 0) 
     265                        msleep(card->wait_resend_apdu); 
    263266                r = sc_transceive(card, apdu); 
    264267                if (r != 0) { 
    265268                        sc_unlock(card); 
  • opensc/src/libopensc/opensc.h

    RCS file: /cvsroot/opensc/src/libopensc/opensc.h,v
    retrieving revision 1.143
    retrieving revision 1.144
    diff -u -r1.143 -r1.144
     
    179179/* A 64-bit uint, used in sc_current_time() */ 
    180180#ifndef _WIN32 
    181181typedef unsigned long long sc_timestamp_t; 
     182#define msleep(t)       usleep((t) * 1000) 
    182183#else 
    183184typedef unsigned __int64 sc_timestamp_t; 
     185#define msleep(t)       Sleep(t) 
     186#define sleep(t)        Sleep((t) * 1000) 
    184187#endif 
    185188 
    186189/* Event masks for sc_wait_for_event() */ 
     
    440443        struct sc_slot_info *slot; 
    441444 
    442445        unsigned long caps, flags; 
     446        unsigned int wait_resend_apdu;  /* Delay (msec) before responding to an SW12 = 6CXX */ 
    443447        int cla; 
    444448        u8 atr[SC_MAX_ATR_SIZE]; 
    445449        size_t atr_len;