Commit Graph

76 Commits

Author SHA1 Message Date
vtarasov 16abe7f3a7 pkcs11: Ticket #353: in pkcs15init framework allocate only one slot with uninitialized token ...
aldo, when allocating existing slot to the card, return an error if there is no more free virtual slot.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5434 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-09 17:11:13 +00:00
martin b1ff1abb1b Fix and change ignored readers feature introducsed in r4626 for Windows. strcasestr is GNU specific extension.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4630 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-16 08:59:14 +00:00
martin a938d3b67f Implement simple reader ignoring, to exclude readers from OpenSC PKCS#11 module.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4624 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-15 09:33:18 +00:00
martin ea7a0ac9a1 pkcs11: move the slot list size check to slot creation.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4419 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-16 13:43:10 +00:00
martin bfe5b4a965 style: space -> tab
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4418 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-16 13:43:05 +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
s 0f74f69695 fix: memory leak (but see FIXME)
==21111== 1,360 (120 direct, 1,240 indirect) bytes in 1 blocks are definitely lost in loss record 107 of 109
==21111==    at 0x4C24F0D: realloc (vg_replace_malloc.c:476)
==21111==    by 0x409D23: sc_pkcs11_register_mechanism (mechanism.c:44)
==21111==    by 0x410595: pkcs15_bind (framework-pkcs15.c:3160)
==21111==    by 0x4085DD: card_detect (slot.c:214)
==21111==    by 0x408887: initialize_reader (slot.c:114)
==21111==    by 0x404C50: C_Initialize (pkcs11-global.c:247)
==21111==    by 0x4034C9: main
==21111==
==21111== LEAK SUMMARY:
==21111==    definitely lost: 120 bytes in 1 blocks



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4388 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-30 07:56:34 +00:00
s a91e77187b fix: memory leak - next object missed out to release
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4387 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-30 07:52:14 +00:00
viktor.tarasov 0400a2dc35 pkcs11: make possible context dependent 'sc' to 'cryptoki' error conversion
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4262 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-21 10:51:13 +00:00
ludovic.rousseau bcba5c94a7 Fix slot.c:151: warning: ‘p11card’ may be used uninitialized in this
function


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4171 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 20:09:19 +00:00
ludovic.rousseau 227cb82612 Fix slot.c:234: warning: function declaration isn’t a prototype
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4170 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 20:08:30 +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 0244baa494 pkcs11:
- slots, sessions and objects are kept as lists.
  - change the way slots, cards and readers are managed.
  - re-implement C_WaitForSlotEvent(/C_Finalize) as written in PCKS#11 v2.20, canceling pending blocking calls.
  - implement a "virtual hotplug slot" with a floating slot id to keep NSS working with C_WaitForSlotEvent with a new reader.
    NSS does not call C_GetSlotList(NULL) to re-fetch the list of available slots if C_WaitForSlotEvent returns an event in an already known slot ID.
    By changing the ID of a slot whenever a reader attached  NSS/Firefox can be tricked into recognizing new readers when waiting for events with C_WaitForSlotEvent.
  - change (possibly break something) sc_to_cryptoki_error() to not have side-effects
  - Implement CKU_CONTEXT_SPECIFIC in C_Login to implement CKA_ALWAYS_AUTHENTICATE (keys with user consent) 
 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3935 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 20:45:02 +00:00
martin 0876222c5f Make PKCS#11 module default slot configuration more sensible:
* Increase default slot count to 16, which equals 4 concurrent readers by default
  * 2 OpenCT + 2 PC/SC on Linux for example
 * Rename num_slots to slots_per_card
 * Rename internal PKCS#11 variables, remove unneeded defines.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3619 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-16 16:44:35 +00:00
ludovic.rousseau 6b89748111 slot_get_token(): return CKR_TOKEN_NOT_PRESENT if CKF_TOKEN_PRESENT is
not set.

Thanks to Douglas E. Engert for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2008-October/011361.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3583 c6295689-39f2-0310-b995-f0e70906c6a9
2008-10-10 09:39:27 +00:00
ludovic.rousseau 001f03f18d card_removed(): warning: comparison between signed and unsigned
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3582 c6295689-39f2-0310-b995-f0e70906c6a9
2008-10-09 13:05:13 +00:00
ludovic.rousseau 6eb3ecd107 card_initialize(): correctly associate a reader to each virtual slot.
Thanks to Douglas E. Engert for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2008-October/011359.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3581 c6295689-39f2-0310-b995-f0e70906c6a9
2008-10-09 12:59:02 +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
alonbl 56a4322c34 Convert constant SC_PKCS11_MAX_VIRTUAL_SLOTS to configuration option.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3404 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-06 15:04:29 +00:00
aj 5db87927d4 convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3086 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:33:15 +00:00
aj 198b68a6d3 shorten string, fixing #98.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3009 c6295689-39f2-0310-b995-f0e70906c6a9
2006-08-27 18:25:43 +00:00
aj b07df40932 change more opensc.org references to opensc-project.org till dns is back.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2818 c6295689-39f2-0310-b995-f0e70906c6a9
2006-01-22 21:15:07 +00:00
nils ad647c66fa use sc_ctx_get_reader
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2676 c6295689-39f2-0310-b995-f0e70906c6a9
2005-10-30 21:44:05 +00:00
nils 5123be2b85 add two new functions
sc_reader_t *sc_ctx_get_reader(sc_context_t *ctx, unsigned int i);
	unsigned int sc_ctx_get_reader_count(sc_context_t *ctx);
to access the reader_count and the sc_reader objects (to avoid accessing
the sc_context members directly).
Use these functions in src/pkcs11 + error checking to avoid accessing
invalid sc_reader objects.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2595 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-16 10:18:55 +00:00
aj bf6808e3d8 "smart card" not "smartcard" or "SmartCard".
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2354 c6295689-39f2-0310-b995-f0e70906c6a9
2005-06-16 19:35:31 +00:00
aet df5e357694 - Whitespace cleanup from me and Martin Paljak
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2181 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-11 20:09:34 +00:00
nils 14ff6bdfc5 fix indent again
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2084 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-19 19:52:08 +00:00
nils cb5d576267 some indent fixes from Martin Paljak plus some additional changes from me
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2083 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-19 18:15:43 +00:00
sth 1c51a8f0dd Fix: if a card couldnt be read (e.g. inverted upside down), allow to retry it later when asked
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1817 c6295689-39f2-0310-b995-f0e70906c6a9
2004-07-09 15:33:35 +00:00
aj 4b4c20196b better checking for null values.
found and fixed reported by Victor Tarasov <vtarasov@idealx.com>


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1777 c6295689-39f2-0310-b995-f0e70906c6a9
2004-04-21 21:11:06 +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
sth a8724bea78 In slot_initialize(): Bugfix in a memset and added a pool_initialize()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1218 c6295689-39f2-0310-b995-f0e70906c6a9
2003-06-24 11:11:49 +00:00
sth ca6a27e429 remove/insert fix: restore the slot->reader in slot_token_removed
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@943 c6295689-39f2-0310-b995-f0e70906c6a9
2003-03-07 14:18:55 +00:00
sth 32f532a782 fix: clear the CK_SLOT_INFO flags in slot_token_removed
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@936 c6295689-39f2-0310-b995-f0e70906c6a9
2003-03-03 13:03:59 +00:00
sth 0036545ffa fix in C_GetSlotInfo that previously cleared the slotDescription and didnt clear the CKF_TOKEN_PRESENT flag
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@934 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-28 12:47:32 +00:00
okir 870d9d9f66 - made card_detect() available to everyone
- C_GetSlotInfo now always does card detection, but only for the
  reader which which the slot is associated


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@913 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-17 14:57:51 +00:00
okir cf6037314f - Introduce locks around all pkcs11 operations, in case the caller
is multithreaded and wants to access us from different threads.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@912 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-17 14:21:38 +00:00
sth 58985e51c2 reset first_free_slot during C_Initialize
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@908 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-14 16:59:23 +00:00
okir 1c66025798 - Each reader now gets a fixed range of slots
- Each slot now shows the reader name in the description field


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@903 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-10 14:08:29 +00:00
okir 4ff3821a0a - suppress bogus insertion events
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@897 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-03 12:32:43 +00:00
okir 5276bbb1c4 - merged Stef's WaitForSlotEvent patches
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@895 c6295689-39f2-0310-b995-f0e70906c6a9
2003-02-03 12:20:54 +00:00
sth 16dfb55118 the slot's slotDescription is now the reader name
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@888 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-28 15:39:47 +00:00
sth dfc01ab7ed typo fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@885 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-27 13:43:06 +00:00
sth a383ed91d5 added return value + fix (needed if hide_empty_slots = true
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@883 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-27 13:17:08 +00:00
okir 69f8588f47 - added card_detect_all
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@868 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-20 09:50:33 +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 0af2a35b9c - Another go at the empty slot/empty token issue
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@857 c6295689-39f2-0310-b995-f0e70906c6a9
2003-01-13 21:38:43 +00:00
okir 0babb91194 - Allow the admin to configure how many slots are used per card
(opensc.conf; pkcs11.num_slots)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@804 c6295689-39f2-0310-b995-f0e70906c6a9
2002-12-21 16:45:37 +00:00
okir c3b479fc82 - in case of an invalid session/object handle, return OBJECT_HANDLE_INVALID
or SESSION_HANDLE_INVALID instead of FUNCTION_DAILED


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@721 c6295689-39f2-0310-b995-f0e70906c6a9
2002-11-22 09:10:10 +00:00