Obtaining Smart Card Reader Status

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

Obtaining Smart Card Reader Status

Douglas de Oliveira Mendes
    Hi. How do I obtain the smart card reader status? If I were using
openct, I would do:

openct-control status

    But I'm using pcsc. Can I get the smart card reader status using
opensc? How would I?

Thanks!
Douglas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status

Peter Stuge
On Thu, Jul 07, 2005 at 03:56:08PM -0300, Douglas de Oliveira Mendes wrote:
>     Hi. How do I obtain the smart card reader status? If I were using
> openct, I would do:
>
> openct-control status
>
>     But I'm using pcsc. Can I get the smart card reader status using
> opensc? How would I?

I guess you should find a PC/SC forum to ask this question in, but
perhaps you can have openct use pcscd as backend and then use
openct-control to check status?


//Peter
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Andreas Jellinghaus-2
In reply to this post by Douglas de Oliveira Mendes
On Thursday 07 July 2005 20:56, Douglas de Oliveira Mendes wrote:
>     Hi. How do I obtain the smart card reader status? If I were using
> openct, I would do:
>
> openct-control status
>
>     But I'm using pcsc. Can I get the smart card reader status using
> opensc? How would I?

I don't know either how to do that with pcsc.
But if you have opensc installed: use opensc-tool.
see options -l -n and maybe others as well.

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Andreas Jellinghaus-2
In reply to this post by Peter Stuge
On Friday 08 July 2005 15:38, Peter Stuge wrote:
> I guess you should find a PC/SC forum to ask this question in, but
> perhaps you can have openct use pcscd as backend and then use
> openct-control to check status?

no, you can only combine opensc+openct without extra middleware
or opensc+pcsc-lite+openct with pcsc-lite as middleware. but
you can't put openct on top of pcsc-lite.

Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Peter Stuge
On Fri, Jul 08, 2005 at 10:35:52PM +0200, Andreas Jellinghaus [c] wrote:
> On Friday 08 July 2005 15:38, Peter Stuge wrote:
> > perhaps you can have openct use pcscd as backend and then use
> > openct-control to check status?
>
> no, you can only combine opensc+openct without extra middleware
> or opensc+pcsc-lite+openct with pcsc-lite as middleware. but
> you can't put openct on top of pcsc-lite.

Ah, ok, I wasn't sure which way it would work. Thanks for clarifying!


//Peter
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status

Douglas de Oliveira Mendes-2
In reply to this post by Douglas de Oliveira Mendes
    I still can't discover if I have a smart card reader available.

    What I found:

struct sc_context *ctx = NULL;
bool estabilished = sc_establish_context(&ctx, "ywapa");
int readersFound = ctx->reader_count;

    But there's a problem here. reader_count is always at least 5. It
tells me even not available readers (I don't know why). Like this:

dom@jdb2:/$ opensc-tool -l
Readers known about:
Nr.    Driver     Name
0      openct     OpenCT reader (detached)
1      openct     OpenCT reader (detached)
2      openct     OpenCT reader (detached)
3      openct     OpenCT reader (detached)
4      openct     OpenCT reader (detached)

    When I connect my reader, as it is a pcsc, the reader_count goes to 6.


dom@jdb2:/$ opensc-tool -l
Readers known about:
Nr.    Driver     Name
0      pcsc       GemPC430 00 00
1      openct     OpenCT reader (detached)
2      openct     OpenCT reader (detached)
3      openct     OpenCT reader (detached)
4      openct     OpenCT reader (detached)
5      openct     OpenCT reader (detached)

    I would check then if reader_count is bigger than 5. But that's an
horrible workaround. If I attach an OpenCT reader, what I get is:

root@jdb2 / # opensc-tool -l
Readers known about:
Nr.    Driver     Name
0      openct     Towitoko Chipdrive Micro
1      openct     OpenCT reader (detached)
2      openct     OpenCT reader (detached)
3      openct     OpenCT reader (detached)
4      openct     OpenCT reader (detached)

    So, the reader_count is 5, and there is indeed a reader. What should
I do? Is there a way of removing those "detached" readers?

Douglas

Douglas de Oliveira Mendes escreveu:

>    Hi. How do I obtain the smart card reader status? If I were using
>openct, I would do:
>
>openct-control status
>
>    But I'm using pcsc. Can I get the smart card reader status using
>opensc? How would I?
>
>Thanks!
>Douglas
>_______________________________________________
>opensc-devel mailing list
>[hidden email]
>http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
>
>  
>

       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Andreas Jellinghaus-2
I have no idea if it will work, but
please give it a try: edit your opensc.conf
and change
        # reader_drivers = openct, pcsc, ctapi;
to
        reader_drivers = pcsc;

Please let us know if it works or not.

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Douglas de Oliveira Mendes-2
    But then I wouldn't be able to use openct drivers, right? That's not
good... Isn't there a simple way to list only the atached readers?

Andreas Jellinghaus [c] escreveu:

>I have no idea if it will work, but
>please give it a try: edit your opensc.conf
>and change
>        # reader_drivers = openct, pcsc, ctapi;
>to
>        reader_drivers = pcsc;
>
>Please let us know if it works or not.
>
>Regards, Andreas
>

       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Douglas de Oliveira Mendes-2
    Who sets ctx->reader_count?

Douglas de Oliveira Mendes escreveu:
    But then I wouldn't be able to use openct drivers, right? That's not
good... Isn't there a simple way to list only the atached readers?

Andreas Jellinghaus [c] escreveu:

  
I have no idea if it will work, but
please give it a try: edit your opensc.conf
and change 
       # reader_drivers = openct, pcsc, ctapi;
to
       reader_drivers = pcsc;

Please let us know if it works or not.

Regards, Andreas

    

	
	
		
_______________________________________________________ 
Yahoo! Acesso Grátis - Internet rápida e grátis. 
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel

  

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Andreas Jellinghaus-2
In reply to this post by Douglas de Oliveira Mendes-2
On Friday 15 July 2005 20:50, Douglas de Oliveira Mendes wrote:
>     But then I wouldn't be able to use openct drivers, right? That's not
> good... Isn't there a simple way to list only the atached readers?

the first thing an application does it "how many readers are there?".

and during the life time of the application the answer can't change.

but hardware can be plugged in, and it would be bad, if it had to
be plugged in before the application starts, right? that is why
opensc reserves 5 readers for openct, so those can be plugged
in later, or can be filled by existing readers.

why do you care about readers anyway? why don't you simply
check all readers, whether or not there is a card in them?

if you want to list the readers and tell the user to
insert a card into any of them - ignore the "detached"
readers.

but at least on pkcs11 level: I'm not sure if the reader
name can change once the lib has been initialized.
so such heuristics may not work well.

sorry, but the whole architectore with smart cards is
old and ugly and it shows in problems like this.
all function calls are from top level (app) to
bottom layer (i.e. usb / send bytes to reader),
but there is no way back. the best you can do is
poll / read certain attributes again and again
to see if anything changed.

I didn't investigate the details myself so far, but if
you do, it would be nice if you could post a summary
(and maybe also add it to the wiki) and if you have
suggestions how to improve opensc and openct, those
are very welcome.

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Andreas Jellinghaus-2
In reply to this post by Douglas de Oliveira Mendes-2
On Friday 15 July 2005 21:17, Douglas de Oliveira Mendes wrote:
>     Who sets ctx->reader_count?

when you initialize opensc, ctx.c looks at table
internal_reader_drivers and initialize each reader
driver (ctapi, pcsc and openct usualy). each of those
has it's own init function, and they call _sc_add_reader
to register each reader they have. that function
increases reader_count.

after opensc is initialized, it never changes. can't.

Regards, Andreas
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Peter Stuge
In reply to this post by Andreas Jellinghaus-2
On Fri, Jul 15, 2005 at 10:51:24PM +0200, Andreas Jellinghaus [c] wrote:
> I didn't investigate the details myself so far, but if
> you do, it would be nice if you could post a summary
> (and maybe also add it to the wiki) and if you have
> suggestions how to improve opensc and openct, those
> are very welcome.

I've always missed some kind of high-level design specification for
opensc and it has taken me a while to realize that I won't find one.

I've been toying with the idea of a redesign of opensc, but I'm not
sure I have enough time to get and read all required documentation to
actually create something excellent, but this reader count thing is
certainly one thing that would be nice to have working in a more
dynamic fashion if permitted by standards and practices.


//Peter
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Douglas de Oliveira Mendes-2
    Can I discover if there's a reader available using
PKCS11_enumerate_slots? How would I?


       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Stef Hoeben
Hi,

Douglas de Oliveira Mendes wrote:

>    Can I discover if there's a reader available using
>PKCS11_enumerate_slots? How would I?
>

Check the description field of the first PKCS11_SLOT struct that is
returned.

If it's equal to "Virtual slot", there's no reader available.

And it it's something else, then it's the name of the reader (and idem
for the other structs).

At least, that's how it is for OpenSC...
(And I didn't test it..)

Cheers,
Stef

_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Douglas de Oliveira Mendes-2
In reply to this post by Douglas de Oliveira Mendes-2
PKCS11_enumerate_slots(ctx, &slot, &slotCount);

    Ugh, slotCount goes to 8 when the reader is connected and 134516968
when it's not!! Someone explain this to me, please. :-D

Douglas de Oliveira Mendes escreveu:

>    Can I discover if there's a reader available using
>PKCS11_enumerate_slots? How would I?
>  
>


       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Douglas de Oliveira Mendes-2
In reply to this post by Stef Hoeben
    slot points to 0xffffffff if I have no reader attached... So, I did
this, and it worked:

if ((int)slot == -1) { noReader = true }


>
> Check the description field of the first PKCS11_SLOT struct that is
> returned.
>
> If it's equal to "Virtual slot", there's no reader available.
>
> And it it's something else, then it's the name of the reader (and idem
> for the other structs).
>
> At least, that's how it is for OpenSC...
> (And I didn't test it..)
>
> Cheers,
> Stef
>
>


       
       
               
_______________________________________________________
Yahoo! Acesso Gr?tis - Internet r?pida e gr?tis.
Instale o discador agora! http://br.acesso.yahoo.com/
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel
Reply | Threaded
Open this post in threaded view
|

Re: Obtaining Smart Card Reader Status [u]

Martin Paljak
In reply to this post by Peter Stuge
On 7/16/05, Peter Stuge <[hidden email]> wrote:
> I've always missed some kind of high-level design specification for
> opensc and it has taken me a while to realize that I won't find one.
I guess there's no such document ;(

> I've been toying with the idea of a redesign of opensc, but I'm not
The building blocks are there, just some interaction mechanisms have
to be redone.
> sure I have enough time to get and read all required documentation to
> actually create something excellent, but this reader count thing is
> certainly one thing that would be nice to have working in a more
> dynamic fashion if permitted by standards and practices.
True. I have have been toying with this issue (opensc being too
'static') but not much yet. Please note that there's a bug for reader
hotplugging in opensc trac ;) See ticket #29 at
http://www.opensc.org/opensc/ticket/29

I believe it's more important to support proper hotplugging of *one*
reader (what is the most common usage scenario) than ultra-good
support for 7 different readers each one connected through a different
access layer.

There was a separate thread about reader hotplugging in pam_pkcs11
card eventmanager. I guess there could and should be some code reuse
between opensc and pam_pkcs11 sources.


--
Martin Paljak
[hidden email]
http://martin.paljak.pri.ee/
+372.5156495 - phone
_______________________________________________
opensc-devel mailing list
[hidden email]
http://www.opensc.org/cgi-bin/mailman/listinfo/opensc-devel