[Pcsclite-muscle] Know the interface connection type with a card

Antoine FERRON aferron at cardhoc.com
Thu Aug 25 13:58:46 PDT 2022


Thanks, I have tried what you suggest. And as I was afraid of, in Windows this never gives you a hint of the interface type. One can't know using SCARD_ATTR_CURRENT_PROTOCOL_TYPE if this is contact or not.

Here's an example, in Windows :
connection.getAttrib(SCARD_ATTR_CURRENT_PROTOCOL_TYPE)
Contact interface :
[2, 0, 0, 0]
Contactless interface :
[2, 0, 0, 0]
No difference at all. This can't be used as a discriminator whether we talk to a smartcard using the contact or the wireless interface, at least in Windows. And this is pretty much the heart of my initial question, how can I know in a reliable and easy way.  Now, I think that this is not possible.
So far, in our software, I combine various heuristic information, to estimate whether this is a contact connection or not. This is pretty reliable to tell the interface type, still quite complex and long to do it.

Regards, AF

-----Original Message-----
From: pcsclite-muscle <pcsclite-muscle-bounces at lists.infradead.org> On Behalf Of Ludovic Rousseau
Sent: 24 August 2022 18:08
To: pcsclite-muscle at lists.infradead.org
Subject: Re: [Pcsclite-muscle] Know the interface connection type with a card

Le mar. 16 août 2022 à 12:53, Antoine FERRON <aferron at cardhoc.com> a écrit :
>
> > SCardGetAttrib with SCARD_ATTR_CURRENT_PROTOCOL_TYPE should get you 
> > what you want...
> > Forgot to mention that T=CL is probably encoded as T=15
>
> Well, I tried similar things, and this provides always 1, 2 or 3 (T0, T1, T0/T1), at least on Windows. It never provides 8 nor 15 value. Maybe in Linux ?
> For now, I'm using pyscard connection.getProtocol(), and this is the same? This reads SCARD_ATTR_CURRENT_PROTOCOL_TYPE ? You think SCARD_ATTR_CURRENT_PROTOCOL_TYPE will provide a different value from connection.getProtocol() ? That will provide 8 or 15 on Windows? To me, the Winscard interface never tells you about contactless protocol used.

connection.getProtocol() will not return what you want.
Use something like attrib =
card_connection.getAttrib(SCARD_ATTR_CURRENT_PROTOCOL_TYPE)

See https://ludovicrousseau.blogspot.com/2020/04/scardattrchannelid-and-usb-devices.html

Bye

--
 Dr. Ludovic Rousseau

_______________________________________________
pcsclite-muscle mailing list
pcsclite-muscle at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/pcsclite-muscle


More information about the pcsclite-muscle mailing list