Hi,

think I found a bug in the CT-API driver for Linux for the Towitoko terminals. The 
problem is how the driver handles NULL-bytes (0x60), which are sent by the card to 
signal the host that it needs more time (and therefore prevent the host from timing 
out).

0x60-bytes are _NOT_ NULL-bytes if they are part of the response. For example, if the 
card sends a response "0x61, 0x60", then it indicates the host that 0x60 bytes are 
available for download from the card.

In contrast, in the sequence "0x60, 0x60, 0x90, 0x00", 0x60 is indeed a NULL-byte. 
That case is correctly taken care of by the driver. To also get the former case right, 
the code in file "tow_chpdv-drv-1.0/src/ct-api/ctapi.c" should be changed to:

    [...]
    // If NULL byte (0x60) is received
    if(status==0x60 && status_size==0) { /* added "&& status_size==0" */
      null_bytes++;
      if(null_bytes>=200) { /* changed from 12 to 200 */
        *lr=0;
        return(ERR_TRANS);
      }
      continue;
    }
    [...]

I recommend changing the maximum number of NULL-bytes to at least 200, since 12 is way 
too small (at least in my case).

Maybe the author can apply the changes?

         -Chris.


***************************************************************
Linux Smart Card Developers - M.U.S.C.L.E.
(Movement for the Use of Smart Cards in a Linux Environment)
http://www.linuxnet.com/smartcard/index.html
***************************************************************

Reply via email to