Commit Graph

47 Commits

Author SHA1 Message Date
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
martin 6f52711280 CT-API: Fix the mess left from broken [3931] and some pieces from [4118].
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4395 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-01 12:28:23 +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
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 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
martin c398f55373 Allow to turn off CT-API support
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3850 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-15 18:03:04 +00:00
martin d672fde449 Remove sc_error and sc_ctx_suppress_errors_* in favor of sc_debug/fprintf
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3721 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:46:59 +00:00
martin 9862d431e8 Fix typo
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3667 c6295689-39f2-0310-b995-f0e70906c6a9
2009-03-21 11:17:14 +00:00
martin 2e2a998f10 Remove some unused/prehistoric defines.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3614 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-15 21:23:09 +00:00
alonbl e237574742 Plug&Play support
This is not the best solution, but focus on smallest code change.

Changes:

1. Add detect_readers() to reader opts, this adds new readers to the end
   of the readers list until list is full.

2. Add sc_ctx_detect_readers() that calls readers' detect_readers().

3. Fixup pcsc_lock() so that it reconnect to the card and report proper
   error so caller may be notified if session was lost.

4. Allow context to be created without readers.

5. Call sc_ctx_detect_readers() from PKCS#11 C_GetSlotList with NULL_PTR.

6. Allow no reader at detect_card, as reader my be removed.

7. Since I broke ABI, I updated the external module version requirement
   to match OpenSC version. In the future a separate version should be
   maintained for each interface, this should be unrelated to the package
   version.

Alon

---

svn merge -r 3480:3505 https://www.opensc-project.org/svn/opensc/branches/alonbl/pnp

M    src/tools/opensc-tool.c
M    src/pkcs11/pkcs11-global.c
M    src/pkcs11/slot.c
M    src/libopensc/reader-pcsc.c
M    src/libopensc/internal-winscard.h
M    src/libopensc/ctx.c
M    src/libopensc/reader-ctapi.c
M    src/libopensc/libopensc.exports
M    src/libopensc/reader-openct.c
M    src/libopensc/opensc.h


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3506 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-29 17:01:19 +00:00
aj b3ad2f9dd2 convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3084 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:31:17 +00:00
nils 7164006b44 enable APDU logging again
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3062 c6295689-39f2-0310-b995-f0e70906c6a9
2006-11-23 22:40:01 +00:00
ludovic.rousseau 2b4e6a5e98 fix a memory leak that occurs when the APDU exchange fails
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2919 c6295689-39f2-0310-b995-f0e70906c6a9
2006-04-27 20:44:24 +00:00
nils 383602b6fe - move logging to the reader driver
- log APDUs only if DEBUG is defined (sensitive APDUs should
  never be logged and we cannot know whether a APDU is sensitive
  or not => enable APDU logging only in a non-production debug
  build)
- remove OPENSC_DONT_LOG_SENSITIVE configure option as it's 
  needed anymore 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2868 c6295689-39f2-0310-b995-f0e70906c6a9
2006-03-03 22:56:41 +00:00
martin e1ef4ec241 Remove the disconnect action from internal reader api
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2861 c6295689-39f2-0310-b995-f0e70906c6a9
2006-03-01 09:45:09 +00:00
nils ca2a5e11fd - move APDU encoding to the reader layer
- remove APDU masquerading code, it shouldn't be necessary
  anymore


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2831 c6295689-39f2-0310-b995-f0e70906c6a9
2006-02-05 19:00:01 +00:00
aj 4801c7eadd check if scconf_find_blocks returned NULL
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2714 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-05 21:38:33 +00:00
nils 47d2baf5a3 use calloc instead of malloc + memset
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2600 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-17 09:40:12 +00:00
nils 55418c5ac3 log dlerror message when dlopen failed
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2596 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-16 20:31:06 +00:00
nils f6c95792fe let src/libopensc/ compile with -Wall -W -Wno-unused-parameter -Werror
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2546 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-07 08:33:55 +00:00
aj ff62b88e1c big configure update.
use pkg-config for openct, openssl, pcsc.
do not compilke libp11. do not compile sslengines.
remove scdl. use libltdl instead.
use libassuan.m4 macro for m4 detection.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2528 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-01 14:01:58 +00:00
bert 2d97002824 API fixup: use defined type instead of struct for exposed structs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2232 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-08 20:59:35 +00:00
aet 16b1b6e5a2 - Add experimental multi-slot support for CT-API
and CT-BCS 1.0 enhancements. (Bernhard Froehlich <ted@convey.de>)
- Enable CT-API for win32


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2111 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-29 10:49:48 +00:00
nils 3158fa3e05 merge Martin Paljak's ccid pinpad changes from the OPENSC_0_9 branch to the cvs head
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2095 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-24 11:31:11 +00:00
aet 82712c45b8 - Add dynamic loading support for win32, Bernhard Froehlich <ted@convey.de>
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2076 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-16 14:24:57 +00:00
aet fb0889a9cc - fixed a typo, pointed out by Bernhard Froehlich <ted@convey.de>
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2054 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-04 19:45:05 +00:00
aet 55e170e0ac - Build / warning fixes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2014 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-15 13:53:36 +00:00
nils ef8df66b5d sc_module_*() -> scdl_*()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1947 c6295689-39f2-0310-b995-f0e70906c6a9
2004-10-20 06:53:14 +00:00
nils d0de68566f sc_module_*() -> scdl_*()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1946 c6295689-39f2-0310-b995-f0e70906c6a9
2004-10-18 21:35:24 +00:00
okir 5dda541b7e - made apdu_masquerade functionality available to all readers, not just pcsc
- added new parameters max_send_size and max_recv_size, roughly corresponding
  to the old max_le (SC_APDU_CHOP_SIZE) parameter. You can now set this
  chop limit per driver class (pcsc, openct, ctapi), which sets
  driver->max_{send,recv}_size. This value is copied to
  card->max_{send,recv}_size in sc_connect_card, and can be overridden
  by the card driver.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1683 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-18 16:35:28 +00:00
aet e66bb1ef16 Remove gcc specific code from usbtoken/openct drivers, untested.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1417 c6295689-39f2-0310-b995-f0e70906c6a9
2003-09-04 16:41:49 +00:00
aet 5616dba08e - Stop using unflexible automake conditionals when
building PC/SC, OpenCT or USBToken support,
  use ifdef's directly in source.
- Because of above, add HAVE_PCSCLITE for winconfig.h
- Remove unnecessary includes for log.h, opensc.h and
  errors.h in libopensc sources, they're already taken
  care by internal.h.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1406 c6295689-39f2-0310-b995-f0e70906c6a9
2003-09-03 09:28:55 +00:00
aet 763fc16704 Rename libopensc specific error/debug to sc_error/sc_debug
We should have done this ages ago.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1392 c6295689-39f2-0310-b995-f0e70906c6a9
2003-08-25 14:21:18 +00:00
okir 127f94ad37 - added pinpad support for OpenCT
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1215 c6295689-39f2-0310-b995-f0e70906c6a9
2003-06-23 12:56:36 +00:00
okir 5b1eb43b93 - add some support for card removal in pkcs11
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@867 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-19 17:47:07 +00:00
okir 9acca0e724 - Implemented new PIN verify/change/unblock framework. All PIN operations
are routed through sc_pin_cmd(), which builds the APDU and either passes
  it to the card directly, or to the card reader along with a request to
  read the PIN(s) from the reader's keypad.

  Currently, entering PIN in the standard way (i.e. via the application)
  should still work - I have verified GPK and eToken; Cryptoflex verify
  should work as well. Anything else needs additional testing, and support
  for keypad input in particular (I cannot test this at the moment for
  lack of a suitable reader).


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@811 c6295689-39f2-0310-b995-f0e70906c6a9
2002-12-23 18:47:27 +00:00
aet 3dccd63989 - C++ support. Compiles with gcc/g++ for Linux, otherwise
completely untested.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@574 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-19 14:23:31 +00:00
aet 11c937991b Change calling convention for sc_module_close()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@474 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-05 18:10:17 +00:00
jey 22636c2df9 - Added SC_ERROR_FILE_ALREADY_EXISTS
- Changed call convention for reader finish()
- CT-API driver now frees its resources correctly
- Added year 2002 to some of the copyright statements
- sc_pkcs15_decipher() and sc_pkcs15_compute_signature()
  now select only the parent DF of the private key file


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@463 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-05 14:46:44 +00:00
aet d81d10ba90 Upgrade sources to use new headers, part #1
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@458 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-05 10:44:51 +00:00
jey d232bf29dd - ctapi_release() now calls CT_close(), as it should
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@437 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-04 09:20:44 +00:00
aet b308cabd5f - Upgrade scldap to use scconf_parse_entries();
- Fix compiler warnings for ct-api driver, untested.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@407 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-31 15:26:25 +00:00
aet 8f6ffee6a9 - Minor cleanups to build process
- Add header check for dlfcn.h
- Add internal functions sc_module_{open,close,get_address}
- Use environ instead __environ for scldap_search, should be
  more portable.
- Fix compiler warnings noticed by Tru64 / AIX cc


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@401 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-27 13:13:54 +00:00
jey 59d4e9b7be - Added support for CT-API
- Improved config file loading
- Implemented ATR parsing


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@396 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-26 11:38:40 +00:00