Giter Club home page Giter Club logo

Comments (2)

dengert avatar dengert commented on June 19, 2024

Can you get an opensc-debug.log?

  • Show if FireFox is requesting probs for smart cards and at frequency

  • Show what card the card driver or drivers are sending the probs.

The first two APDUs like from card-piv.c checking for DISCOVERY OBJECT when PIV is active application.
The second looks SELECT AID for PIV application, with response Application not found.

The rest could be from card-piv.c trying to test for a CAC CCC object or from card-cac.c.

In all the cases status show the card not have the object or application.

Is this causing problems with with the card/token you are trying to use?

I have Firefox 115.9esr on Ubuntu 22.04 and it does not appear to be probing.

from opensc.

frankmorgner avatar frankmorgner commented on June 19, 2024

I think that constantly probing the card if it is an unrecognized one, should be contained in every version of OpenSC. However, previous versions had less applet-based card drivers and had simpler detection mechanisms, which may be the reason why this problem wasn't recognized earlier. Due to some compilation problem, the earliest version I was able to test is 0.24.0, which also contains this problem.

The problem lies within card_detect() from slot.c:

  1. If a token is present (sc_detect_card_presence())
  2. and the card is not already known (p11card->card == NULL
  3. then a new connection is made (sc_connect_card()
  4. and the card's PKCS#15 profile is bound.
  5. If one of steps 2 to 4 fails, then we go to fail, which calls sc_pkcs11_card_free() and leads to sc_pkcs11_card_free(p11card);.

Step 1 to 5 are running in a loop, because we're not keeping track between the different runs.

I think, what should work now as a fix, would be setting pkcs11_enable_InitToken to true, because the token will then be kept inside some slot even though it was not recognized. This, however, may not always desirable, because, for example, some other process could not make an exclusive connection.

A different solution would be to create a second sc_context_t and use this to watch state changes of specific readers (sc_wait_for_event() with timeout set to 1). Only when this context detects a new card, the card probing should be executed.
Why use a new context rather than the existing one? It is likely, that we will loose the event state somewhere in libopensc. For example, reader-pcsc.c uses sc_wait_for_event() in many callbacks, which may accidentally drop events, that the PKCS#11 layer will not notice.

So again, I think this kind of problem should be present in all versions of OpenSC. If you think otherwise, please perform git bisect to point to a specific commit that introduced this problem. If we have this kind of context, we maybe find some simpler resolution to the constant card probing.

from opensc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.