Commit Graph

186 Commits

Author SHA1 Message Date
martin 44cf3d06ae MiniDriver: rename cardmod to minidriver in source.
Also change some grammar, whitespace (reported by git) and wording (Opensc->OpenSC) issues.
Add some comments here and there.

See http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016261.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5329 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-12 07:40:12 +00:00
martin cd3012f55e Fix #340: ignore pinpad properties of readers known to be broken.
On Mac OS X the HP smart card keyboard claims secure PIN entry support but the PIN is transmitted to host.
Disregard the pinpad flag for this reader. Other readers claiming pinpad support but having problems to follow in this list.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5273 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-29 11:36:45 +00:00
ludovic.rousseau f1170e009a Fix compiler warning
reader-pcsc.c: In function 'refresh_attributes':
reader-pcsc.c:339: warning: declaration of 'rv' shadows a previous local
reader-pcsc.c:273: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5258 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 15:46:51 +00:00
ludovic.rousseau f7f6213d24 Fix compiler warning
reader-pcsc.c: In function 'refresh_attributes':
reader-pcsc.c:337: warning: declaration of 'state' shadows a previous local
reader-pcsc.c:272: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5257 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 15:45:41 +00:00
martin 711cbda2e0 PC/SC: Add "PIN length not in range" interpretation to PC/SC pinpad code.
This way this condition won't get translated to a generic -1200 error, as 0x6403 is not a known SW.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5217 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-02 14:18:09 +00:00
martin ffb46d2573 core: reanimate the sc_dlopen API for dynamic loading
* shift libpkcs11 from src/pkcs11 to src/common as it is not used to implement the OpenSC PKCS#11 module
 * invent a "libscdl" mini library that implements either libltdl based dynamic loading or uses native interfaces
 * drop hard requirement for libltl to build OpenSC
 * native Windows build does not need libltdl any more
 * specify CNGSDK include dir to find cardmod.h. CNGSDK only registers with a handful of compilers

Deals with #323

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5201 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-16 19:02:11 +00:00
dengert 0a9d507556 Fixes to cardmod:
The registry in no longer used to pass the
    handles provided by BaseCSP. sc_ctx_use_reader
    is used instead.  (uses r5190)

    A decryption routine was added as it is needed by login.

    Key container names are based on the card serial
    number and cert ID. The must be unique as they
    are searched for in the certificate store to 
    find the card to insert in some situations. 

    If the handles change, the association to the reader
    and card is refreshed as it may be a different card
    or reader.  (uses r5127)

    Extra low lowel debugging was added. To use
    it the CARDMOD_LOW_LEVEL_DEBUG but be defined in
    cardmod.c This can log entries before and sc_context
    is established. 

    The use of "texte" was replaced, as it looked like there 
    could be buffer overflows. It was replaced with a 
    loghex routine.

    SC_ALGORITHM_RSA_HASH_MD5_SHA1 can now be used
    (IE uses this.) 
       
    Several other bugs were fixed.

The code can now bue used for AD login, and was tested
with swaping cards duirng login, and with several readers. 
The code is still experimental, and for login to work,
the dlls were moved to system32. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5192 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-09 17:52:00 +00:00
dengert d3b3faa91a Add sc_ctx_use_reader as a reader driver operation.
It is used by cardmod to pass in pointers to the PC/SC handles 
provided by the caller of cardmod. Other drivers will return
an error if this routine called. 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5190 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-09 14:33:52 +00:00
ludovic.rousseau a4e314e453 Add missing check code for NULL before dereferencing
reader-pcsc.c:1076:3: warning: Dereference of null pointer (loaded from variable
      'event_reader')
                *event_reader = NULL;
                ^~~~~~~~~~~~~
reader-pcsc.c:1098:3: warning: Dereference of null pointer (loaded from variable
      'event')
                *event = 0;
                ^~~~~~
reader-pcsc.c:1137:6: warning: Dereference of null pointer (loaded from variable
      'event_reader')
                                        *event_reader = ...
                                        ^~~~~~~~~~~~~
reader-pcsc.c:1112:6: warning: Dereference of null pointer (loaded from variable
      'event_reader')
                                        *event_reader = NULL;
                                        ^~~~~~~~~~~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5161 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 21:32:28 +00:00
vtarasov a576582701 libioensc: use 'struct sc_atr' instead of 'u8 *atr, size_t atr_len'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5061 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 17:18:58 +00:00
martin 6af2bc07c3 PC/SC: don't try to use SCARD_SHARE_DIRECT if there is a card in the reader. This can confuse some card/reader combos.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5054 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 08:55:12 +00:00
martin c911c2ffeb PC/SC: add additional flags to indicate readers which are in use and readers which are in exclusive mode.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5015 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-02 12:54:51 +00:00
vtarasov 795dbf0342 win32: change path to the OpenSC registry keys
Now it begins with "SOFTWARE\\OpenSC Project\\..." .


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4940 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-12 10:30:07 +00:00
martin 7ab591a684 libopensc: make sc_reset() take an additional parameter "do_cold_reset" which will unpower the card.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4896 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-30 11:22:31 +00:00
martin 5c32c15b60 Revert a protocol forcing change from [4873] which was a mistake.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4892 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 13:56:27 +00:00
martin c1c3aa1d55 PC/SC: make (dis)connect actions configurable, SCardDisconnect, SCardEndTransaction and SCardReconnect
actions can now be configured via opensc.conf in better detail.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4891 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 13:56:19 +00:00
martin 77c8cfc37d pcsc: a change in ATR will not always mean a changed card, rely on PC/SC layer for card change information.
One of the few cards that has two different ATR-s is the EstonianEid card. The changing ATR (especially if
it has different protocol information and historical bytes) can cause confusion in many places, like
Microsoft BaseCSP or certain versions of pcsc-lite.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4890 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 13:35:06 +00:00
martin c6eb9d3d92 PC/SC: move protocol (T=0/T=1) selection to reader-pcsc.c, where it is used.
Also, check fot the required protocol before connecting to the card and use the forced prtocol instead of re-connecting.

See http://lists.drizzle.com/pipermail/muscle/2010-November/008671.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4873 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-08 12:37:22 +00:00
flc 23b64f88d2 fix sc_pkcs15_card_t struct change in cardmod.c and issue in reader_pcsc.c for cardmod part too
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4809 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-15 13:37:37 +00:00
flc 3076fe265c Fix patch [4709] for cardmod until build in one static dll
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4808 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-15 08:07:34 +00:00
martin 6410da59a9 PC/SC: better detection of card changing events.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4798 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-06 07:54:08 +00:00
martin 14752f0c43 Remove now unused variables.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4787 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 15:12:10 +00:00
martin 75a10198fc PC/SC: simplify reader state detection.
This needs to be improved further, based on revision 5278 of pcsc-lite.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4784 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 14:58:45 +00:00
martin ebdc92407e PC/SC: move reader feature detection to a separate function. Don't detect features of a reader that is in exclusive mode.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4783 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 14:58:29 +00:00
martin 72d961beb2 Fix #216: initial go with multiple reader subsystem removal.
* One sc_context has only a single reader driver.
 * remove dynamic reader driver loading capabilities
 * remove opensc-tool -R command
 * change the internal API, we don't need to pass around a "driver data" pointer as it can be found directly from the context.
 * check in ./configure for only a single enabled reader driver

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4709 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-11 13:00:47 +00:00
martin a3d02dd63c CT-API, PC/SC: truncating atr_len makes no sense.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4648 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-25 08:32:42 +00:00
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
ludovic.rousseau 947c3291db Use SCARD_READERSTATE instead of SCARD_READERSTATE_A
SCARD_READERSTATE_A is not used by Microsoft API and is no more
defined/used by pcsc-lite >= 1.6.2

Thanks to Josef Windorfer for the bug report
http://www.opensc-project.org/pipermail/opensc-user/2010-August/004235.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4626 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-15 14:57:34 +00:00
martin 5c2c12bb78 Trac #244: Fix structure packing on Apple and SUN. Fix display detection by updating structure definitions.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4611 c6295689-39f2-0310-b995-f0e70906c6a9
2010-07-26 13:16:37 +00:00
martin 3cfc64ee6b style: // -> /* */
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4412 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-11 07:35:45 +00:00
viktor.tarasov 73c516a7a0 pkcs11: resolve 'endless polling' in C_WaitForSlotEvent()
http://www.opensc-project.org/pipermail/opensc-devel/2010-April/013947.html

Tested with Firefox 3.6.3 in WinXP SP3 .




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4363 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-19 09:18:38 +00:00
flc 9e74991250 Add cardmod pcsc protocol detection
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4288 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-05 09:31:44 +00:00
ludovic.rousseau 70b649e01b Use (const char *) for static C-strings
Fix
reader-pcsc.c: In function ‘pcsc_detect_readers’:
reader-pcsc.c:856: warning: initialization discards qualifiers from pointer target type
reader-pcsc.c:884: warning: initialization discards qualifiers from pointer target type
reader-pcsc.c:894: warning: initialization discards qualifiers from pointer target type


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4211 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-02 13:51:51 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
flc 3d23ea782b cardmod updates:
- Add comment to opensc.conf
- Use opensc log in cardmod
- Minor corrections on cardmod pcsc driver


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4036 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-17 07:51:52 +00:00
alonbl f636cc1862 cardmod - build fixups and mingw stuff
1. Add --enable-cardmod to autoconf to enable feature explicitly.

2. Modify opensc-cardmod.dll to always have bitness suffix eg opensc-cardmod32.dll

3. Remove complex cardmod.h detection, could not find any reason for this.

4. Make cardmod.inf a template and inject opensc version into its version string.

5. More minor autoconf/automake cleanups.

6. Remove internal-winscard.h usage in cardmod.c as cardmod.h already includes winscard.h

7. DllMain is not exportable.

Notes:

1. I may caused other build not to work, will happy to work it out.

2. Cannot find reason why cardmod.inf cardmod-westcos.reg should reside in bin directory.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4003 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-05 21:39:28 +00:00
flc 0e03c6d5cf add cardmod a minidrivers for windows
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4001 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-05 13:05:25 +00:00
martin 314a31f867 [PC/SC / MacOSX] Try to connect to the card twice.
On OS X, when you insert a card, securityd sequentially starts all found Tokend-s to see if a card can be handled with one.
If a non-tokend application waits for a card insertion with sc_wait_for_event and tries to connect to the card right after the system sees it, it will fail with "The reader is in use by another application" 95% of the time.
With this hack connecting to the card succeeds 95% of the time with the probable penalty of an extra second on initialization for non-tokend clients.

This should only affect applications that wait for card insertion events.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3991 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-03 15:46:44 +00:00
martin 36992b4001 [PC/SC] detect other events besides card insertion/removal
* remove whitespace.
 * don't use SC_MAX_READERS and allocate memory dynamically.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3987 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-03 09:54:02 +00:00
martin 92debb4b5e PC/SC: Do not try to watch 0 readers on OS X
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3977 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-02 12:01:36 +00:00
martin d006b1845e libopensc:
- Remove slot abstraction from internal API and all reader drivers. CT-API (from where it all comes from) readers with multiple slots (if still found) can be presented as separate readers, OpenCT should remove the slot abstraction, PC/SC never knew about it. None of the tools knew how to use slots.
 - Add sc_cancel (translates to SCardCancel)
 - Re-implement sc_wait_for_event; support a blocking call.
 - Replace the "int reader" API with "* sc_reader_t" style; add "Get reader by name" functionality.
 - Remove "action" parameter from sc_disconnect_card() (was not used)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3931 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:25:08 +00:00
martin cbfa2dd939 Missing piece from r3912
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3928 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 12:50:37 +00:00
martin cd9e666926 SC_ERROR_MEMORY_FAILURE signals EEPROM failures on card. Failures to allocate memory on host result in SC_ERROR_OUT_OF_MEMORY.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3927 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 12:38:34 +00:00
viktor.tarasov 490e02b349 after Martin's suggestion: for pcsc do not use '0' protocol when detecting readers
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3879 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-03 10:47:51 +00:00
viktor.tarasov 4f52e7bba8 reader-pcsc::pcsc_transmit() add log message with the reader's name
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3857 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-17 12:12:17 +00:00
martin 36f26b6357 Do not duplicate reader name in private structure.
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3812 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-10 10:05:51 +00:00
martin 56fb57603b Merge [3758:3783/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3785 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-22 09:18:16 +00:00
martin 4196e9f156 PC/SC: Log enabled options.
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3774 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-13 08:29:29 +00:00
martin 91815f380a PC/SC: better separation between OpenSC and PC/SC types.
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3758 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-05 19:59:05 +00:00