Skip to content

Commit

Permalink
Keep track of card resets by other contexts in minidriver
Browse files Browse the repository at this point in the history
Most of the cards supported by OpenSC do not support the "logout" method
required to deauthenticate a card.

This means that the only way to deauthenticate the card without removing it
from reader is to reset it.

This is done by Base CSP if we return SCARD_E_UNSUPPORTED_FEATURE from
CardDeauthenticate() in minidriver, which we do if calling "logout" card
method fails.

If this happens, all users of this card will lose its state and at least
some cards (OpenPGP card and cards having multiple applets) will be
non-functional in currently active minidriver contexts as they need some
initialization after reset.

This makes it really hard to use card from multiple applications as some
Windows libraries (like WinHTTP used by IE and WebDAV client) prefer to
deauthenticate card after only a few seconds of inactivity (with PIN cached
for future operations).

Keep a list (critical section protected) of other minidriver contexts which
are using this reader (and so this card) to make sure all of them will be
reinitialized after the card is reset by Base CSP or some other user.

There are other reasons (like card handles changed) where a card needs to
be reinitialized, too.

This solution isn't most optimal possible, but at least makes these cards
work properly - for more detailed discussion about card reset issue please
have a look at description of commit "Provide notification about and handle
card resets by other contexts".

Signed-off-by: Maciej S. Szmigiero <[email protected]>
  • Loading branch information
maciejsszmigiero committed Jan 28, 2017
1 parent 2a9e175 commit f2df771
Show file tree
Hide file tree
Showing 3 changed files with 717 additions and 127 deletions.
1 change: 1 addition & 0 deletions src/minidriver/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src
opensc_minidriver@LIBRARY_BITNESS@_la_SOURCES = minidriver.c minidriver.exports versioninfo-minidriver.rc
opensc_minidriver@LIBRARY_BITNESS@_la_LIBADD = \
$(top_builddir)/src/libopensc/libopensc.la \
$(top_builddir)/src/common/libcompat.la \
$(OPTIONAL_OPENSSL_LIBS) \
-lbcrypt -lcrypt32 -lrpcrt4
opensc_minidriver@LIBRARY_BITNESS@_la_LDFLAGS = $(AM_LDFLAGS) \
Expand Down
3 changes: 2 additions & 1 deletion src/minidriver/Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ TARGET = opensc-minidriver.dll
OBJECTS = minidriver.obj versioninfo-minidriver.res
LIBS = $(TOPDIR)\src\libopensc\opensc_a.lib \
$(TOPDIR)\src\pkcs15init\pkcs15init.lib \
$(TOPDIR)\src\common\libscdl.lib
$(TOPDIR)\src\common\libscdl.lib \
$(TOPDIR)\src\common\common.lib

all: $(TARGET)

Expand Down
Loading

0 comments on commit f2df771

Please sign in to comment.