On Wed, Apr 16, 2008 at 12:08 PM, Blomen Stefan <[EMAIL PROTECTED]> wrote:
> Hi,
Hello,
> opensc (reader-pcsc.c) uses the following code to determine that a smartcard
> was removed and (another card) inserted again:
>
>
> /* If we aren't sure if the card state changed, check if
> * the card handle is still valid. If the card changed,
> * the handle will be invalid. */
> slot->flags &= ~SC_SLOT_CARD_CHANGED;
> if (maybe_changed) {
> if (old_flags & SC_SLOT_CARD_PRESENT) {
> DWORD readers_len = 0, state, prot, atr_len =
> 32;
> unsigned char atr[32];
> LONG rv = SCardStatus(pslot->pcsc_card, NULL,
> &readers_len,
> &state, &prot, atr, &atr_len);
> if (rv == (LONG)SCARD_W_REMOVED_CARD)
> slot->flags |= SC_SLOT_CARD_CHANGED;
> }
> else
> slot->flags |= SC_SLOT_CARD_CHANGED;
>
>
>
> On Windows, SCardStatus (realised by MS) returns SCARD_W_REMOVED_CARD, and
> everything is fine. On Linux, SCardStatus (realised by pcsc-lite) returns
> SCARD_W_RESET_CARD. Does anybody have an idea which implementation "is
> right"? Is it an issue of pcsc (return SCARD_W_REMOVED_CARD in any case), or
> opensc which has to evaluate both (or maybe even other) returncodes?
What is the problem you have on Linux and you do not have on Windows?
The value SC_SLOT_CARD_CHANGED is only used in
./src/libopensc/reader-pcsc.c (with the code you cite above) and in
./src/pkcs11/slot.c with:
/* If the card was changed, disconnect the current one */
if (rc & SC_SLOT_CARD_CHANGED) {
sc_debug(context, "%d: Card changed\n", reader);
/* The following should never happen - but if it
* does we'll be stuck in an endless loop.
* So better be fussy. */
if (!retry--)
return CKR_TOKEN_NOT_PRESENT;
card_removed(reader);
goto again;
}
The comment is a bit scary :-)
--
Dr. Ludovic Rousseau
_______________________________________________
opensc-devel mailing list
[email protected]
http://www.opensc-project.org/mailman/listinfo/opensc-devel