From minfrin at sharp.fm  Mon Mar 22 11:57:25 2021
From: minfrin at sharp.fm (Graham Leggett)
Date: Mon, 22 Mar 2021 13:57:25 +0200
Subject: [Pcsclite-muscle] Which APIs are needed to read multiple smartcards
 in multiple readers?
Message-ID: <DF0425C5-6798-4BBB-AD5F-893E1125B1C6@sharp.fm>

Hi all,

I am trying to develop an application that reads one or more smartcards, and I need to do so without the end user being asked any questions.

Most specifically, if the end user plugs in two smartcard readers made by two different manufacturers, and those readers in turn contain two different smartcards made by two different manufacturers (different ATRs), I need this to Just Work(TM). Obviously drivers for both readers and smartcards need to be present, that?s a given.

My understanding is that pcsclite (PC/SC) will give me an API that allows me to access all (supported) plugged in readers, and allows me to not care about the details of reader drivers. I can call APIs like SCardListReaders() and friends, and I can return the ATRs of smartcards using SCardGetStatusChange().

So far so good.

Now that my code knows that multiple readers are present, and knows the ATRs of the cards, what API do I use to read the smartcards themselves? I am assuming the API is PKCS11.

Most specifically, is there a library that I should be using that will use the correct PKCS11 driver corresponding to the inserted smartcard, and will handle routing the calls to the correct driver and the same smartcard?

Where I am struggling is that I can find a lot of code that tries to connect to one smartcard and one smartcard only. I want to give the end user a good experience where if they plug in multiple cards  the multiple cards ?just work? and nothing weird happens from the end user?s perspective.

I understand that NSS is one such library that can handle multiple PKCS11 drivers at once. Is NSS what I should be using, or can this be done with PKCS11 directly?

Regards,
Graham
?



From ludovic.rousseau at gmail.com  Tue Mar 30 16:52:28 2021
From: ludovic.rousseau at gmail.com (Ludovic Rousseau)
Date: Tue, 30 Mar 2021 17:52:28 +0200
Subject: [Pcsclite-muscle] Which APIs are needed to read multiple
 smartcards in multiple readers?
In-Reply-To: <DF0425C5-6798-4BBB-AD5F-893E1125B1C6@sharp.fm>
References: <DF0425C5-6798-4BBB-AD5F-893E1125B1C6@sharp.fm>
Message-ID: <CAGstE8CAO+nibgqO_yytgRvQk2O+hQ2W=YxpO-pT1DNXjYOaBA@mail.gmail.com>

Le lun. 22 mars 2021 ? 12:58, Graham Leggett <minfrin at sharp.fm> a
?crit :> Hi all,

Hello Graham,

Sorry for the delay. Your email was in my gmail spam folder.

> I am trying to develop an application that reads one or more smartcards, and I need to do so without the end user being asked any questions.
>
> Most specifically, if the end user plugs in two smartcard readers made by two different manufacturers, and those readers in turn contain two different smartcards made by two different manufacturers (different ATRs), I need this to Just Work(TM). Obviously drivers for both readers and smartcards need to be present, that?s a given.
>
> My understanding is that pcsclite (PC/SC) will give me an API that allows me to access all (supported) plugged in readers, and allows me to not care about the details of reader drivers. I can call APIs like SCardListReaders() and friends, and I can return the ATRs of smartcards using SCardGetStatusChange().
>
> So far so good.

Exact.
You can play with pcsc_scan and connect/disconnect your readers,
insert/remove the cards.
https://ludovicrousseau.blogspot.com/2014/03/level-1-smart-card-support-on-gnulinux.html

> Now that my code knows that multiple readers are present, and knows the ATRs of the cards, what API do I use to read the smartcards themselves? I am assuming the API is PKCS11.
>
> Most specifically, is there a library that I should be using that will use the correct PKCS11 driver corresponding to the inserted smartcard, and will handle routing the calls to the correct driver and the same smartcard?
>
> Where I am struggling is that I can find a lot of code that tries to connect to one smartcard and one smartcard only. I want to give the end user a good experience where if they plug in multiple cards  the multiple cards ?just work? and nothing weird happens from the end user?s perspective.
>
> I understand that NSS is one such library that can handle multiple PKCS11 drivers at once. Is NSS what I should be using, or can this be done with PKCS11 directly?

The important question are:
- what are your smart cards?
- do you have the PKCS#11 library corresponding to your cards?

Bye

-- 
 Dr. Ludovic Rousseau


