SCardConnect() returns unresponsive card

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

SCardConnect() returns unresponsive card

Gökçenur CANLI
Hello,

I am use PCSC-lite 1.8.20, ccid 1.4.26 for Microchip SEC1110 smart card reader.
I used your sample C code (https://ludovicrousseau.blogspot.com.tr/2010/04/pcsc-sample-in-c.html) and I have a problem on SCardConnect(). Sometimes connection is successful. However, generally SCardConnect() returns "Card is unresponsive".

Operating system: Ubuntu 14.04.5
log.txt is attached.

Any suggestion or information will be appreciated.

Regards.
Gokce.

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

log.txt (10K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Ludovic Rousseau
2017-05-18 10:54 GMT+02:00 Gökçenur CANLI <[hidden email]>:
Hello,

Hello,
 

I am use PCSC-lite 1.8.20, ccid 1.4.26 for Microchip SEC1110 smart card reader.
I used your sample C code (https://ludovicrousseau.blogspot.com.tr/2010/04/pcsc-sample-in-c.html) and I have a problem on SCardConnect(). Sometimes connection is successful. However, generally SCardConnect() returns "Card is unresponsive".

Operating system: Ubuntu 14.04.5
log.txt is attached.

Any suggestion or information will be appreciated.

From your log file the card is responding correctly.
But you have not executed your program so I can't find any error in it.

Please generate a new log file and reproduce the problem so usable error trace is present in the log file.

Bye

--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Gökçenur CANLI

Hello,

I executed my program and reproduced problem again. New log file is attached.

Regards.

On 18-05-2017 12:03, Ludovic Rousseau wrote:
2017-05-18 10:54 GMT+02:00 Gökçenur CANLI <[hidden email]>:
Hello,

Hello,
 

I am use PCSC-lite 1.8.20, ccid 1.4.26 for Microchip SEC1110 smart card reader.
I used your sample C code (https://ludovicrousseau.blogspot.com.tr/2010/04/pcsc-sample-in-c.html) and I have a problem on SCardConnect(). Sometimes connection is successful. However, generally SCardConnect() returns "Card is unresponsive".

Operating system: Ubuntu 14.04.5
log.txt is attached.

Any suggestion or information will be appreciated.

From your log file the card is responding correctly.
But you have not executed your program so I can't find any error in it.

Please generate a new log file and reproduce the problem so usable error trace is present in the log file.

Bye

--
 Dr. Ludovic Rousseau


_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

--
Gökçenur CANLI
Ar-Ge Mühendisi
UDEA Elektronik A.Ş. ODTÜ Teknokent
Gümüş Bloklar K1-3 Ofis Alanı
Çankaya/ANKARA
Tel : + 90 (312) 210 19 82
Fax: +90 (312) 210 19 97

Signature

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

newLog.txt (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Ludovic Rousseau
2017-05-18 12:10 GMT+02:00 Gökçenur CANLI <[hidden email]>:

Hello,

I executed my program and reproduced problem again. New log file is attached.


This log is not complete.
Your first log was correctly generated. Please use the same method.

Thanks

--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Gökçenur CANLI

Sorry for wrong one, generated updated log is attached.


On 18-05-2017 14:22, Ludovic Rousseau wrote:
2017-05-18 12:10 GMT+02:00 Gökçenur CANLI <[hidden email]>:

Hello,

I executed my program and reproduced problem again. New log file is attached.


This log is not complete.
Your first log was correctly generated. Please use the same method.

Thanks

--
 Dr. Ludovic Rousseau


_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

--
Gökçenur CANLI
Ar-Ge Mühendisi
UDEA Elektronik A.Ş. ODTÜ Teknokent
Gümüş Bloklar K1-3 Ofis Alanı
Çankaya/ANKARA
Tel : + 90 (312) 210 19 82
Fax: +90 (312) 210 19 97

Signature

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

updated_log.txt (18K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Francois Grieu-3
In reply to this post by Gökçenur CANLI
On 2017-05-18 at 12:10, Gökçenur CANLI wrote:
 > (..) New log file is attached.

This log contains
00000016 Card ATR: 3B 9F 96 81 31 FE 45 80 65 54 43 12 21 08 31 C0 73 F6 21 80
81 05 9A
In this TA1 is 96h, meaning the card suggests that the reader attempts a PPS/PTS
negociatione to use of an F/D ratio of 512/32=16, that is a bit rate 1/16 of the
clock, which is usually between 3.5 to 5MHz, thus a bit rate on the tune of 250
kbit/s. The log shows that the reader attempts to do this, and it fails:
00019824 prothandler.c:124:PHSetProtocol() PTS failed (612), using T=1


On 2017-05-17 at 15:52, Gökçenur CANLI wrote:
 > I am having trouble with SCardTransmit() when using Microchip SEC1110 smart
card reader.
 > I sent  APDU commands to smart card sequentially. After a while,  Linux
"select()" function in MessageReceive(in winscard_msg.c) blocks my program and
never remove blocking when using SCardTransmit.

This is consistent with unreliable operation of the smart card reader at high
communication speed. Notice that it has been formally certified to meet EMV
specifications ( EMV 4.3 book 1, available at no charge at
http://www.emvco.com/specifications.aspx?id=223 ), but these specify only TA1 of
11h, 12h, or 13h; that is F/D of 372, 186, or 93; and the certification report (
http://ww1.microchip.com/downloads/en/DeviceDoc/EMV%20report%20-%20CETECOM.PDF )
shows the tests did not explore lower F/D / higher communications speeds. There
are quite a few hardware and a lot of software resons that ISO 7816-3
reader/card communication can fail at high speed; reader implementors get it
right only after many years; and most often they move to other priorities before
that (based on observation of the industry since ISO 7816-3:1989 was still a draft).

Possible ways to save the day:
- use another reader;
- manage to reconfigure the card to ask for a lower speed (TA1 of 11h, 12h, or
13h) or skip TA1 altogether;
- reconfigure the reader (or its driver) to not attempt PPS/PTS negociation, or
attempt TA1 = 13h even though the card suggests otherwise.

If their is a way to do any of the later point with Pcsclite, I want to learn how!

   Francois Grieu

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Ludovic Rousseau
In reply to this post by Gökçenur CANLI
2017-05-18 13:29 GMT+02:00 Gökçenur CANLI <[hidden email]>:

Sorry for wrong one, generated updated log is attached.


00000002 ifdhandler.c:1081:IFDHSetProtocolParameters() Negotiate IFSD at 254
00000003 sending: 00 C1 01 FE 3E
00000003 -> 000000 6F 05 00 00 00 00 0D 00 00 00 00 C1 01 FE 3E
00000966 <- 000000 80 04 00 00 00 00 0D 00 00 00 92 82 00 10
00000005 received: 92 82 00 10
00000002 sending: 00 C1 01 FE 3E
00000003 -> 000000 6F 05 00 00 00 00 0E 00 00 00 00 C1 01 FE 3E
00000769 <- 000000 80 04 00 00 00 00 0E 00 00 00 92 82 00 10
00000005 received: 92 82 00 10
00000002 sending: 00 C1 01 FE 3E
00000003 -> 000000 6F 05 00 00 00 00 0F 00 00 00 00 C1 01 FE 3E
00000767 <- 000000 80 04 00 00 00 00 0F 00 00 00 92 82 00 10
00000005 received: 92 82 00 10
00000002 prothandler.c:124:PHSetProtocol() PTS failed (612), using T=1

The reader fails to negociate the IFSD (Information Field Size for CCID for protocol T = 1)

The value returned by the reader "92 82 00 10" is very strange (bogus?).
The CCID driver tries 3 times the same command and then gives up.

As Francois Grieu wrote in another email (thanks for that) this card can use a very fast communication.
Your reader [1] defines:
dwDefaultClock: 4.800 MHz [3]
and
dwMaxDataRate: 826000 bps [4]

So the card could communicate at 300 kbits/s.

Your card is not yet in my list. Could you add it using [2]? Or tell us what this smart card is?


Francois proposed different solutions to solve the problem.
There is no easy way to force a TA1 in the driver. Maybe the simplest fix would be to change the value of dwMaxDataRate for this reader and use a (much) lower value instead.

Proposed patch:
--- /var/folders/5h/3d1x67_x5g30t36wypgxpmpc0000gn/T//sbZS7a_ccid.c 2017-05-18 14:33:20.000000000 +0200
+++ src/ccid.c  2017-05-18 14:33:18.000000000 +0200
@@ -87,6 +87,10 @@ int ccid_open_hack_pre(unsigned int read
            ccid_descriptor->dwMaxDataRate = 9600;
            break;
 
+       case MICROCHIP_SEC1100:
+           ccid_descriptor->dwMaxDataRate = 12903;
+           break;
+
        case ElatecTWN4:
            /* use a timeout of 400 ms instead of 100 ms in CmdGetSlotStatus()
             * used by CreateChannelByNameOrChannel()


12903 is a very low value. This is the lowest/default data rate of the reader (dwDataRate [5])
You can increase it up to 826000 and see when the reader fails.

Bye

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: SCardConnect() returns unresponsive card

Gökçenur CANLI

Dear Ludovic and Francois,

Changing dwMaxDataRate was solved my all (SCardConnect() - SCardTransmit()) problems. Thank you for all helps and valuable information.

* My smart card is test Electronic Identity card of The Scientific and Technological Research Council of Turkey.

Regards.

Gokcenur.

On 18-05-2017 15:36, Ludovic Rousseau wrote:
2017-05-18 13:29 GMT+02:00 Gökçenur CANLI <[hidden email]>:

Sorry for wrong one, generated updated log is attached.


00000002 ifdhandler.c:1081:IFDHSetProtocolParameters() Negotiate IFSD at 254
00000003 sending: 00 C1 01 FE 3E
00000003 -> 000000 6F 05 00 00 00 00 0D 00 00 00 00 C1 01 FE 3E
00000966 <- 000000 80 04 00 00 00 00 0D 00 00 00 92 82 00 10
00000005 received: 92 82 00 10
00000002 sending: 00 C1 01 FE 3E
00000003 -> 000000 6F 05 00 00 00 00 0E 00 00 00 00 C1 01 FE 3E
00000769 <- 000000 80 04 00 00 00 00 0E 00 00 00 92 82 00 10
00000005 received: 92 82 00 10
00000002 sending: 00 C1 01 FE 3E
00000003 -> 000000 6F 05 00 00 00 00 0F 00 00 00 00 C1 01 FE 3E
00000767 <- 000000 80 04 00 00 00 00 0F 00 00 00 92 82 00 10
00000005 received: 92 82 00 10
00000002 prothandler.c:124:PHSetProtocol() PTS failed (612), using T=1

The reader fails to negociate the IFSD (Information Field Size for CCID for protocol T = 1)

The value returned by the reader "92 82 00 10" is very strange (bogus?).
The CCID driver tries 3 times the same command and then gives up.

As Francois Grieu wrote in another email (thanks for that) this card can use a very fast communication.
Your reader [1] defines:
dwDefaultClock: 4.800 MHz [3]
and
dwMaxDataRate: 826000 bps [4]

So the card could communicate at 300 kbits/s.

Your card is not yet in my list. Could you add it using [2]? Or tell us what this smart card is?


Francois proposed different solutions to solve the problem.
There is no easy way to force a TA1 in the driver. Maybe the simplest fix would be to change the value of dwMaxDataRate for this reader and use a (much) lower value instead.

Proposed patch:
--- /var/folders/5h/3d1x67_x5g30t36wypgxpmpc0000gn/T//sbZS7a_ccid.c 2017-05-18 14:33:20.000000000 +0200
+++ src/ccid.c  2017-05-18 14:33:18.000000000 +0200
@@ -87,6 +87,10 @@ int ccid_open_hack_pre(unsigned int read
            ccid_descriptor->dwMaxDataRate = 9600;
            break;
 
+       case MICROCHIP_SEC1100:
+           ccid_descriptor->dwMaxDataRate = 12903;
+           break;
+
        case ElatecTWN4:
            /* use a timeout of 400 ms instead of 100 ms in CmdGetSlotStatus()
             * used by CreateChannelByNameOrChannel()


12903 is a very low value. This is the lowest/default data rate of the reader (dwDataRate [5])
You can increase it up to 826000 and see when the reader fails.

Bye


_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

--
Gökçenur CANLI
Ar-Ge Mühendisi
UDEA Elektronik A.Ş. ODTÜ Teknokent
Gümüş Bloklar K1-3 Ofis Alanı
Çankaya/ANKARA
Tel : + 90 (312) 210 19 82
Fax: +90 (312) 210 19 97

Signature

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle