Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VpcdReader.cpp stuck in loop when connecting several times #46

Closed
kaoh opened this issue Apr 15, 2015 · 3 comments
Closed

VpcdReader.cpp stuck in loop when connecting several times #46

kaoh opened this issue Apr 15, 2015 · 3 comments

Comments

@kaoh
Copy link

kaoh commented Apr 15, 2015

I'm using this project to write unit tests for Java Card applet running inside jCardSim. So I have implemented a Vpicc connector to the Vpcd driver. The problem is occurring when running multiple tests and closing and reconnecting to the driver for each test. The first test often succeeds, but for the other tests more often no card is present anymore when listing the terminal and trying to connect. This behavior is not deterministic, I assume a timing condition or some inconsistent state in the driver.

I have debugged the driver and see the following behavior:

  • VpcdReader.cpp server is running and vicc_present in vpcd.c detects a card and my Vpicc connector is passing an ATR correctly.
  • VpcdReader::signalInsertion set cardPresent to true and the waitInsertIpr is triggered.
  • VpcdReader.cpp server is still running and executes vicc_present in vpcd.c detects a card and my Vpicc connector is passing an ATR correctly` every second.
  • VpcdReader::signalInsertion is called but cardPresent is already set to true, waitInsertIpr is NULL.
  • The last two points are looping forever

My assumption:

  • Reader::IoSmartCardIsPresent which was called in the beginning, is never called again, so I assume any SCardListReaders never sees a card inserted again, so the connections can never be established again.

Do you have any idea what is going wrong?

@frankmorgner
Copy link
Owner

Currently I have no idea. I am very regularly using the Linx version of vpcd, which does not show this behavior. But this may be a bug in the Windows driver, I need to look closer at the problem.

jCardSim itself has implemented a backed to the virtual driver, see https://jcardsim.org/blogs/work-jcardsim-through-pcsc-virtual-reader. The pipe-interface is also part of my driver, you simply need to change BixVReader.ini (see https://www.codeproject.com/Articles/134010/An-UMDF-Driver-for-a-Virtual-Smart-Card-Reader for details) and you can connect directly from jCardSim via pipe. The pipe-Interface may be better tested...

@kaoh
Copy link
Author

kaoh commented Apr 15, 2015

The pipe interface is not working for me. The connection seems to be not closed correctly. I get the error "All pipes are busy", although I have closed the pipe from the Java side. I have to restart the driver the release the pipe again, which is worse compared to the socket behavior.

Do you know any API method on the windows side which let me tell the UMDF driver "Hey, the card is present again." which can be called from the driver itself when no IWDFIoRequest is pending?

@frankmorgner
Copy link
Owner

Sorry, I can't reproduce the problem on my machine. I tried the following:

  1. connect a card to the reader/socket
  2. run some APDUs (crypto, actually)
  3. disconnect the card
  4. goto 1

I also tried to disconnect the card while the tests were running, which threw an error that the card was removed. This all works as expected.

Without more evidence I suppose that the problem is in your client-side implementation. Also, you indicated that vicc_present only succeeds every second time, this should not happen. The same way of exchanging data is used for transmitting the APDUs. I think you should fix this issue and you will also solve the APDU problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants