<div dir="ltr">Hello François,<br><div><div class="gmail_extra"><br><div class="gmail_quote">2017-10-27 12:03 GMT+02:00 Francois Grieu <span dir="ltr"><<a href="mailto:fgrieu@gmail.com" target="_blank">fgrieu@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am trying to issue a ScardControl to a Smart Card reader. The code works under Windows (Identiv driver 4.65), but fails with 0x80100016 (SCARD_E_NOT_TRANSACTED) under Linux Centos 6, pcscd 1.5.2<br>
<br>
Am I missing something obvious?<br>
<br>
If that matters: the reader is a Teo by Xiring/Ingenico SCR35xx (USB\VID_04E6&PID_5410) recognizable by having a green-only led, when the Omnikey variant (USB\VID_076B&PID_A022) has a led that briefly goes from green to red on card insertion. The ScardControl is intended to adjust the clock frequency to 8 MHz (after ATR and PPS negociation). It fails, and CLK remains as the default (I guess 4.8 MHz).<br>
<br>
The code goes:<br>
<br>
// SCM Microsystems Inc. SCR35xx (USB\VID_04E6&PID_5410) control code to change Clk<br>
//<br>
// To be issued only on this reader, after ATR and PPS negotiation, and after<br>
// deep considerations on the risks.<br>
//<br>
// Second parameter controls the clock frequency, according to  f = 48/(48-n) MHz<br>
//   n : 36   37       38     39       4   41       42   43    44<br>
//   f :  4    4.364    4.8    5.333   6    6.857    8    9.6  12 MHz<br>
//<br>
// Many causes conspire to make use of this call risky:<br>
//<br>
// * For n>36 and absent a declaration in the ATR, f is larger than the minimum<br>
//   for cards (5 MHz during ATR, 4 MHz after) specified by ISO/IEC 7816-3).<br>
//   However:<br>
//   - In my practice, the hardware of integrated circuits used for Smart Cards<br>
//     manufactured after 2005 (resp. 1995) is explicitly specified to at least<br>
//     8 MHz (resp. 5 MHz), and commonly 10 MHz.<br>
//   - Usually, their software also works to that frequency;<br>
//   - Commonly, it implements the turnaround delay specified by EMV when the<br>
//     direction of communication on I/O changes;<br>
//   - When that later condition applies at least, n = 42 works reliably,<br>
//     and I have yet to see n = 43 fail.<br>
//   - A card's TA1 (if present) states a value of  f  that the card promises<br>
//     if usable; for example, TA1=B7h is a promises that the card accepts<br>
//     f = 10 MHz. If it then accepts a PPS to<br>
//   - a card can advertise<br>
//<br>
// * Propagation delays and capacitance conspire to deform clock.<br>
//<br>
// * For n odd and n>40 (perhaps n=39), the duty cycles is out of<br>
//   ISO/IEC 7816-3 specs ( 40% to 60% ); however, in practice, cards are<br>
//   quite tolerant on that if neither the maximum frequency nor minimum low<br>
//   and high time are violated.<br>
//<br>
// * There is no insurance that when the clock switches, there is no glitch<br>
//   violating said minimums.<br>
//<br>
// * ISO/IEC 7816-3 specs is ambiguous about if a card with TA1=00h or no TA1<br>
//   must accept Clk about 4 MHz beyond the ATR; however, it is safe to assume<br>
//   that any card made after 1995 does.<br>
//<br>
// * The values to use for the SCR35xx are undocumented AFAIK; the control code<br>
//   is documented for another SCM reader, search CCID_ESC_CLK_FREQUENCY, or<br>
//   <a href="http://www.epsys.no/downloads/pdf/RM_MAXX_lite.pdf" rel="noreferrer" target="_blank">http://www.epsys.no/downloads/<wbr>pdf/RM_MAXX_lite.pdf</a><br>
//<br>
    const uint8_t rControlCode[2] = { 0x1F, 42 }; // n = 42, f = 48/(48-n) = 8 MHz<br>
    uint8_t vBuf[4];    // placeholder for possible result (ignored)<br>
    vResult = SCardControl (<br>
        gReaderTable[Nb].gCardHandle,<br>
        SCARD_CTL_CODE( 0xDAC ),<br>
        rControlCode,<br>
        sizeof(rControlCode),<br>
        vBuf,<br>
        sizeof(vBuf),<br>
        &dwState<br>
        );<span class="gmail-HOEnZb"></span></blockquote><div><br></div><div>My CCID driver does not know this SCARD_CTL_CODE( 0xDAC ) code.</div><div>Maybe you can use a Xiring or Omnikey (proprietary) driver with support of this control code.</div><div><br></div><div>Bye<br clear="all"></div></div><br>-- <br><div class="gmail_signature"> Dr. Ludovic Rousseau</div>
</div></div></div>