Commit Graph

768 Commits

Author SHA1 Message Date
martin 2ea78bf741 Amend r5201: also move libltdl build properties to the right Makefile and other leftovers.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5203 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-17 07:45:36 +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
vtarasov f2924672d8 pkcs15: add 'aid' parameter to the prototype of the 'bind' functions ...
prepare for the multi-application support


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5041 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-05 14:21:04 +00:00
andre 1b7585480c openssl.c: Fixes comparsion between signed and unsigned
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5036 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-03 16:20:19 +00:00
andre be3e50aa96 framework-pkcs15.c: Fixes two warnings:
1 x comparsion between signed und unsigned
1 x unused parameter 'flags'

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5035 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-03 15:10:18 +00:00
martin abcdb86c4e Fix #302: in C_Logout silently ignore missing card specific logout hooks.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4998 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-29 10:45:01 +00:00
andre 30bf0f17a8 pkcs11-object.c: Add missing initializers.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4966 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-17 19:09:24 +00:00
andre b58592d297 mechanism.c: Removal of unused variables.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4965 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-17 18:47:41 +00:00
andre 1a5c0aea24 framework-pkcs15.c: Avoid some warnings if the macro USE_PKCS15_INIT is undefined. That is always the case if build without OpenSSL.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4964 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-17 17:54:07 +00:00
dengert bf28607dd3 More ENABLE_OPENSSL changes so sc_pkcs11_register_sign_and_hash_mechanism
will not fail. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4963 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-17 17:12:22 +00:00
andre 82824402f4 framework-pkcs15init.c: Add missing initializers.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4962 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-17 16:30:12 +00:00
andre 6b10272caa framework-pkcs15.c: More specific log messages. Enables better tracking of errors.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4953 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-16 03:56:49 +00:00
andre 3cfe542813 Textual output of SC_ERROR_* return codes in debug messages.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4948 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-14 03:08:17 +00:00
andre f1293c372d pkcs11-display: Fixing some type mismatches that the compiler complains about.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4943 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-13 06:28:37 +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
s 0dba036837 add to r4904: fix calculating of signature size for CKK_GOSTR3410
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4930 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-09 07:23:10 +00:00
andre 559e4f3dc4 framework-pkcs15 [pkcs15_logout]: Better propagation of errors
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4928 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-08 03:31:07 +00:00
dengert c2fe4609a9 Modifications to support EC and ECDSA for
emulated cards. True PKCS#15 cards with EC 
will need additional changes. 

Main changes are in framework-pkcs15.c, mechanism.c,
padding.c, pkcs15-algo.c and pkcs15-sec.c 
where switch statements for key type, and testing
of flags was modified to make it easier to add 
additional key types in the future. 

The code was tested using RSA and ECDSA using a PIV card 
from pkcs11-tool, OpenSSL and Thunderbird with 
modifications to NSS-3.12.7 to get ECDSA to sign e-mail. 

Only named curves are supported for ECDSA, ECDH is still 
needed. pkcs11-tool has only minimal changes need to work 
with the -O option to list EC keys. 

One additional line was added to pkcs15-sec.c which 
should get GOSTR sign to work. 

libp11 and engine do not yet have EC support. 

 --This line, and those below, will be ignored--

M    src/tools/piv-tool.c
M    src/tools/pkcs11-tool.c
M    src/pkcs11/framework-pkcs15.c
M    src/pkcs11/mechanism.c
M    src/pkcs11/pkcs11-object.c
M    src/libopensc/pkcs15-prkey.c
M    src/libopensc/card-piv.c
M    src/libopensc/padding.c
M    src/libopensc/cardctl.h
M    src/libopensc/pkcs15-algo.c
M    src/libopensc/libopensc.exports
M    src/libopensc/pkcs15-piv.c
M    src/libopensc/pkcs15-sec.c


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4904 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-01 20:08:42 +00:00
dengert c34caeb662 Support for ECC keys (part 1) header files and
support routines. Add definitions for EC keys,
parameters and extensions to structures. 
Add the sc_card_find_ec_alg, sc_pkcs15_decode_pubkey_ec,
sc_pkcs15_encode_pubkey_ec, sc_pkcs15emu_add_ec_prkey,
sc_pkcs15emu_add_ec_pubkey routines. 
Only EC named curves are currently supported. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4902 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-30 19:13:48 +00:00
dengert 137a7282ad Allow emulation routine to setup an emulated object
to be used instead of trying to read a file.
This will be used  with the ECC code. 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4901 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-30 15:57:01 +00:00
dengert e642436fc6 SPY does not process CKA_ALWAYS_AUTHENTICATE
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4900 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-30 15:32:58 +00:00
martin b33a44fdf0 pkcs11: clean up mechanism registration
* check for out of memory conditions
 * register SHA256 as well
 * key generation depends on onboard key generation capabilities, not OpenSSL

Further adjustments are needed.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4894 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 14:22:09 +00:00
martin 113dfda494 EstEID: add support for v 3.0 cards with 2048b keys
* Detect different cards based on ATR-s and on card objects
 * Set the card name from the ATR table
 * Conditionally add support for 2048b keys
 * Add workarounds for broken MULTOS and JavaCard cards.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4893 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 14:22:01 +00:00
andre 636b0c1d27 framework-pkcs15: Do not populate the unwrap capability, because the corresponding function C_UnwrapKey isn't implemented.
http://www.opensc-project.org/opensc/browser/trunk/src/pkcs11/pkcs11-object.c?rev=4885#L969

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4886 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 00:58:12 +00:00
andre 0eb404b2e6 pkcs11-display.c: more detailed less verbose output of CK_ATTRIBUTE lists
http://www.opensc-project.org/pipermail/opensc-devel/2010-November/015321.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4881 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-25 00:20:21 +00:00
dengert 09131a4e9f Fix support for CKU_ALWAYS_AUTHENTICATE and CKU_CONTEXT_SPECIFIC
spy segfaulted if CKU_CONTEXT_SPECIFIC was used,
pkcs11-session was reseting the userType before calling 
framework.  Framework will now see CKU_CONTEXT_SPECIFIC
and use slot->login_user to determine which PIN was used
to create the original session, and will send the PIN
to the card. It does not treats CKU_CONTEXT_SPECIFIC 
as a full login, only a reassertion of the PIN. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4880 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-24 20:28:30 +00:00
andre 5a183a8dc7 framework-pkcs15.c: new logic to discover objects that were hidden before PIN verification
pkcs15.c: object search continues with normal processing, even if enumeration of some files failed
pkcs15.h: obsolete prototype removed
pkcs15-syn.c: now obsolete function sc_pkcs15emu_postponed_load removed

fixes: #266

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4877 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-18 23:31:08 +00:00
ludovic.rousseau 9c433a9cce pkcs11-object.c: In function ‘C_DigestInit’:
pkcs11-object.c:455: warning: label ‘out’ defined but not used


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4864 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-06 17:00:09 +00:00
ludovic.rousseau 98fdeaa0b6 C_LoadModule(): Fix compiler warning
libpkcs11.c:58: warning: format ‘%lx’ expects type ‘long unsigned int’,
but argument 3 has type ‘int’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4858 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-06 16:49:00 +00:00
martin 8af1b60afd PC/SC: temporarily disable blocking C_WaitForSlotEvent until a checked version for pcsc-lite 1.5.3-1.6.4 exists.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4835 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-28 13:33:50 +00:00
martin 8156095b46 FIXME: Don't issue SCardCancel unless the environment is known not to hang (part 1)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4833 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-28 09:44:22 +00:00
dengert bd93b97674 Additianl changes to r4805 which made cert->pubkey a pointer to sc_pkcs15_pubkey_t
Thanks to Andre Zepezauer for pointing out most of these. 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4828 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-25 20:58:02 +00:00
dengert 0f2a44b33e sc_pkcs15_pubkey_from_cert now uses parse_x509_cert without OpenSSL.
sc_pkcs15_cert now has pointer to sc_pkcs15_pubkey, allowing it to 
be removed and used separatly.  
sc_pkcs15_pubkey now has pointer to sc_algorithm_id to faclitate
addition of other key algorithms and their parameters. 
Various code changes to free these structures and references
to the structures have been changed. 



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4805 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-12 15:26:45 +00:00
martin dfe8a014b9 Fix leftover from r4646
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4795 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-06 07:15:32 +00:00
martin 50f99a20f8 libopensc: move TokenInfo fields from sc_pkcs15_card_t to a separate structure.
Thanks to Andre Zepezauer for the patch.

See http://www.opensc-project.org/pipermail/opensc-devel/2010-September/015076.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4788 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 15:44:58 +00:00
martin 283ac67229 pkcs11-spy: log matching objects in hex. Patch from Andre Zepezauer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4781 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 14:42:01 +00:00
dengert 573a1de4d6 Allow c_FindObjectsInit to find unlimited objects - #258
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4760 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-22 14:41:50 +00:00
martin 528b7ae7c7 pkcs11: move around CKR_ARGUMENTS_BAD check
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4749 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-21 16:11:40 +00:00
martin 93da2252c7 pkcs11: #250: refresh PIN counters and associated token flags on every call to C_GetTokenInfo
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4692 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-05 16:53:08 +00:00
martin 2f440e63ca pkcs11: Remove the comment about max_tries==1 and CKF_USER_PIN_FINAL_TRY
Assuming the driver has correctly set max_tries to 1 then PKCS#11 is very clear about it:
"""
True if supplying an incorrect user PIN will it to become locked.
"""

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4687 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-05 16:52:36 +00:00
martin 4697cc386b libpkcs11: Print error messages from PKCS#11 module loading
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4672 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-02 13:38:56 +00:00
viktor.tarasov 9acc8c44af pkcs11: #250: update slot PIN flags when verifying slot's auth object
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4671 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-02 09:19:27 +00:00
martin 27ed902ce0 Add a FIXME for keys>2048b
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4667 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 11:46:37 +00:00
martin 15b6f29013 Whitespace fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4663 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 06:23:32 +00:00
martin 8c9666d631 pkcs11: C_SeedRandom is not implemented by OpenSC nor most smart cards, nor does it fit well into PKCS#15 concept.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4662 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 06:23:26 +00:00
martin 12a1e9d49b pkcs15: don't override TokenInfo PRNG flag. pkcs11: announce CKF_RNG if the card driver supports it, bypassing PKCS#15.
GET CHALLENGE and RNG don't match 1:1 anyway.

Thanks to Andre Zepezauer for noticing this.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4661 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 06:23:17 +00:00
martin 4f03502b60 pkcs11: check PKCS#11 function parameters for obvious errors and return CKR_ARGUMENTS_BAD early without locking the module.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4647 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-23 14:47:14 +00:00
martin 9a63e03e9a pkcs11/pkcs15-init: remove automagic software key generation. Remove software based secret key handling from PKCS#11.
Support for importing cleartext keys is left untouched, but all transparent key generation by either opensc-pkcs11.so or pkcs15-init is removed, to make the operation with cleartext keys visible to the user and his explicit wish.
OpenSC is a PKCS#11 library for accessing keys protected by a smart card. Key material in software is not protected by smart cards and can leave a false sense of security to the user.

http://www.opensc-project.org/pipermail/opensc-devel/2010-April/013877.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4646 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-23 14:47:07 +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 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 fde87a8c6e pkcs11: remove outdated config entry parsing.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4625 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-15 09:34:13 +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 02f4507564 pkcs11: Patch from Andre Zepezauer to remove max_virtual_slots allocation.
See http://www.opensc-project.org/pipermail/opensc-devel/2010-June/014356.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4417 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-16 13:42:59 +00:00
ludovic.rousseau e6803d9ca0 Use CK_RV (defined as unsigned long) instead of int for the type the
return code of C_* functions

Thanks to Martin Vogt for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2010-June/014351.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4415 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-16 11:43:10 +00:00
ludovic.rousseau eab7adea12 pkcs11-global.c: In function ‘C_WaitForSlotEvent’:
pkcs11-global.c:624: warning: unused variable ‘ii’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4414 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-16 11:32:21 +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 06028a7f9e fix:
openssl (lock_dbg_cb): already locked (mode=9, type=30) at eng_list.c:360                                      
openssl (lock_dbg_cb): not locked (mode=10, type=30) at eng_table.c:186\

Thanks to Jan Just Keijser for development and patch
http://www.opensc-project.org/pipermail/opensc-devel/2010-June/014314.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4398 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-05 08:51:37 +00:00
s 7f3f6dec6b fix: 'openssl: double free or corruption' (load gost engine before loading engine_pkcs11 (which loading gost engine))
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4397 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-04 22:23:47 +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
s c5c649e0ea fix: memory leak
example:

int main()
{
        C_Initialize(NULL);
        C_Finalize(NULL);
        return 0;
}

==4625== 592 (504 direct, 88 indirect) bytes in 1 blocks are definitely lost
in loss record 9 of 10
==4625==    at 0x4C24137: calloc (vg_replace_malloc.c:418)
==4625==    by 0x407FD9: create_slot (slot.c:80)
==4625==    by 0x40452C: C_Initialize (pkcs11-global.c:243)
==4625==    by 0x40342A: main
==4625==
==4625== 4,736 (4,032 direct, 704 indirect) bytes in 8 blocks are definitely
lost in loss record 10 of 10
==4625==    at 0x4C24137: calloc (vg_replace_malloc.c:418)
==4625==    by 0x407FD9: create_slot (slot.c:80)
==4625==    by 0x408102: initialize_reader (slot.c:108)
==4625==    by 0x4044E0: C_Initialize (pkcs11-global.c:247)
==4625==    by 0x40342A: main
==4625==
==4625== LEAK SUMMARY:
==4625==    definitely lost: 4,536 bytes in 9 blocks



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4386 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-30 07:31:31 +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
viktor.tarasov ffc9f8efc6 pkcs11: by default do not lock login
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4359 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-19 08:17:53 +00:00
s 46def8b86c fix: loading openssl engine with GOST algorithms
Thanks to Jan Just Keijser, Martin Paljak, Andreas Jellinghaus, Robert Relyea, Dimitrios Siganos

see:
http://www.opensc-project.org/pipermail/opensc-devel/2010-April/013956.html
http://www.opensc-project.org/pipermail/opensc-devel/2010-April/013966.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4347 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-13 21:57:28 +00:00
viktor.tarasov ed610517d7 plcs11: set default value for 'lock_login' to 'true' as it' stated by
the commets in opensc.con.in

At the origin there were problem of signing with Feitian card, noted by
Ludovic.

http://www.opensc-project.org/pipermail/opensc-devel/2010-May/014180.html




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4346 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-13 17:47:04 +00:00
viktor.tarasov ac41eba3ac win32: merge the branches/vtarasov/opensc-sm.trunk
update win32 compilation;
Unix style line ending in src/pkcs15init/pkcs15-oberthur.h;
variables declaration issue in src/tools/cardos-tool.c.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4280 c6295689-39f2-0310-b995-f0e70906c6a9
2010-05-01 12:15:36 +00:00
ludovic.rousseau ba04831e34 sc_to_cryptoki_error(): check for the validity of ctx outside of the
for loop to make the code more natural


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4263 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-21 11:57:10 +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
viktor.tarasov 1966822aa7 fix 201: thanks to Christian Hohnstaedt: delete objects in pkcs11
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4259 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-20 15:11:58 +00:00
ludovic.rousseau 7a0578c670 set_cka_label(): remove a possibly invalid memory access
See
http://www.opensc-project.org/pipermail/opensc-devel/2010-April/013990.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4245 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-17 18:51:34 +00:00
viktor.tarasov 2fdfe2574d pkcs11: Christian Hohnstaedt's patch: convert CKA_LABEL to the null-terminated pkcs15 label
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4243 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-15 15:37:55 +00:00
viktor.tarasov 801fdcefe2 pkcs11, libopensc, pkkcs15init: not use C99 designated initializers
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4238 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-14 11:36:40 +00:00
viktor.tarasov 3d6eaca830 pkcs11 for win32: add source for display functions
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4237 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-14 11:34:11 +00:00
ludovic.rousseau ad1dddabf3 use explict field names in the static initialisation to make it more
robust to code change


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4195 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-02 11:43:09 +00:00
martin 5957c7a880 Fix a line ordering error.
Thanks to Roland Schwarz

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4194 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-01 14:37:33 +00:00
alonbl e61f5964d7 Fix r4182, LIBS must never go into LDFLAGS
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4187 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-30 06:35:00 +00:00
ludovic.rousseau d67f3f93f6 Use the correct integer type.
Fix openssl.c:182: warning: passing argument 3 of ‘EVP_DigestFinal’ from
incompatible pointer type


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4186 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-29 14:34:02 +00:00
ludovic.rousseau 30d43413be Add missing (optional) initializer
Fix
openssl.c:42: warning: missing initializer openssl.c:42: warning: (near initialization for ‘openssl_sha1_mech.sign_init’)
openssl.c:53: warning: missing initializer openssl.c:53: warning: (near initialization for ‘openssl_sha256_mech.sign_init’)
openssl.c:63: warning: missing initializer openssl.c:63: warning: (near initialization for ‘openssl_sha384_mech.sign_init’)
openssl.c:73: warning: missing initializer openssl.c:73: warning: (near initialization for ‘openssl_sha512_mech.sign_init’)
openssl.c:96: warning: missing initializer openssl.c:96: warning: (near initialization for ‘openssl_md5_mech.sign_init’)
openssl.c:106: warning: missing initializer openssl.c:106: warning: (near initialization for ‘openssl_ripemd160_mech.sign_init’)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4185 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-29 14:30:03 +00:00
ludovic.rousseau cb5a21c5fa Use a temporary pointer to avoid a pointer cast.
Fix pkcs11-display.c:137: warning: dereferencing type-punned pointer
will break strict-aliasing rules


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4184 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-29 14:19:26 +00:00
ludovic.rousseau 7d782f63a3 Link libpkcs11 to $(LTLIB_LIBS) since the lib uses ld_dlopen(), etc.
Fix a compilation error for src/tools/pkcs11-tool:
/usr/bin/ld: ../../src/pkcs11/.libs/libpkcs11.a(libpkcs11.o): in function C_UnloadModule:libpkcs11.c:78: error: undefined reference to `lt_dlclose'
/usr/bin/ld: ../../src/pkcs11/.libs/libpkcs11.a(libpkcs11.o): in function C_LoadModule:libpkcs11.c:36: error: undefined reference to `lt_dlinit'
/usr/bin/ld: ../../src/pkcs11/.libs/libpkcs11.a(libpkcs11.o): in function C_LoadModule:libpkcs11.c:43: error: undefined reference to `lt_dlopen'
/usr/bin/ld: ../../src/pkcs11/.libs/libpkcs11.a(libpkcs11.o): in function C_LoadModule:libpkcs11.c:52: error: undefined reference to `lt_dlsym'


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4182 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-29 13:30:33 +00:00
ludovic.rousseau 66fc414db7 Fix framework-pkcs15init.c:175: warning: initialization from
incompatible pointer type


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4172 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 20:16:46 +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
ludovic.rousseau bdd4477c29 Fix sc-pkcs11.h:328: warning: function declaration isn’t a prototype
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4169 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 20:06:56 +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 02768fb5dc remove "split-key" option and emulat sign for sign,decrypt keys with padding
and decrypt() for cardos.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4113 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-13 22:52:51 +00:00
viktor.tarasov af1bf44cef framework-pkcs15: fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4104 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-10 15:03:20 +00:00
viktor.tarasov 052881c38f libopensc: in pkcs15 PIN commands 'pin_info' parameter replaced by 'pin_object'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4103 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-10 09:23:01 +00:00
viktor.tarasov b6cd025106 pkcs11 framework-pkc15: at user login try to do the postponed private keys load
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4099 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-09 17:38:08 +00:00
viktor.tarasov e47baeaf9e pkcs11: configuration option to report as zero the CKA_ID of CA certificates
In fact, the middleware of the manufacturer of the gemalto (axalto, gemplus) cards
reports the CKA_ID of CA certificates as '0'.

But it's not true for the others middlewares (Oberthur), NSS (afais) and PKCS#11 standard.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4095 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-09 15:43:16 +00:00
viktor.tarasov 54d2b20fe2 pkcs11 framework: change prototype of the 'login' method
It gives the access to the 'slot' object inside the framework method 'login'.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4094 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-09 15:05:29 +00:00
viktor.tarasov c837196134 libopensc: homogenize name of 'struct sc_pkcs15_card' parameters and variables
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4090 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-08 12:32:35 +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 cf4ec4ab3f #47: C_SignRecover is not implemented at the moment, don't give any promises with C_SignRecoverInit either.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4071 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-24 14:06:04 +00:00
viktor.tarasov 128e066176 pkcs11: no pincache concept at the pkcs11 level -- it's implemented at the pkcs15 one
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4049 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-20 22:16:19 +00:00
s c4509d3c7b fix SIGABRT (r4028)
*** glibc detected *** invalid pointer: 0x00007fff9e9f7670 ***
Program received signal SIGABRT, Aborted.
0x00007f971d0a8ea5 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007f971d0a8ea5 in raise () from /lib64/libc.so.6
#1  0x00007f971d0aaab3 in abort () from /lib64/libc.so.6
#2  0x00007f971d0e7d58 in __libc_message () from /lib64/libc.so.6
#3  0x00007f971d0ed7e8 in malloc_printerr () from /lib64/libc.so.6
#4  0x00007f971d0efda6 in free () from /lib64/libc.so.6
#5  0x0000000000410f5c in pkcs15_gen_keypair (p11card=0x72aec0, slot=<value optimized out>,
    pMechanism=<value optimized out>, pPubTpl=<value optimized out>, ulPubCnt=<value optimized out>,
    pPrivTpl=<value optimized out>, ulPrivCnt=6, phPubKey=0x7fff9e9f7e50, phPrivKey=0x7fff9e9f7e58)
    at framework-pkcs15.c:1763 /* see opensc-0.11.13 */
#6  0x0000000000409a6e in C_GenerateKeyPair


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4032 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-15 20:55:12 +00:00
s 22f9b2930e fix memory leaks
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4028 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-12 17:23:02 +00:00
martin b9f844c367 [PKCS#11] use combined constants for events
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3989 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-03 10:10:43 +00:00
alonbl a6f9f023a0 [WINDOWS] Remove tool specific file description support resource file
The implementation was based on the previous MSC build, each tool had its own
description in version resource.

This change sets a single version resource to all files, and produces much
simpler build.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3980 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-02 14:50:42 +00:00
aj 4b2fe63ac2 build only one shared library instead of many.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3971 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-01 15:12:53 +00:00
viktor.tarasov 9eebe0e1a5 pkcs11: by default do not create slot for the User PUK (thanks to Andreas)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3957 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 14:15:13 +00:00
viktor.tarasov 55f7f02e18 remove debug message
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3955 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 12:42:19 +00:00
viktor.tarasov 031bfc7a07 pkcs11: parametrize disabling of the slot for PUK
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3953 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 12:14:48 +00:00
viktor.tarasov ae046cc460 pkcs11: do not create slot for PUK
Ignore PUK for the 'normal' pkcs11 also, not only for 'one-pin-pkcs11'.




git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3952 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-28 08:28:25 +00:00
s 33228c7cbc cleanup and correct style
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3945 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 16:04:19 +00:00
s 723bcc41ff fix: use of uninitialised value - return parameter (phObject) from C_CreateObject and C_GenerateKeyPair
(In function 'pkcs15_add_object': warning: unused parameter 'pHandle')

Example (C_CreateObject):
Breakpoint 3, C_CreateObject (hSession=134587040, pTemplate=0x8049160, ulCount=5, phObject=0xbff55560)
    at pkcs11-object.c:57
57              rv = sc_pkcs11_lock();
(gdb) x/x phObject
0xbff55560:     0xffffffff
(gdb) finish
0xb7f5c6c0 17:15:09.969 [opensc-pkcs11] framework-pkcs15.c:657:pkcs15_add_object: Setting object handle of 0x0 to 0x805ab80
Run till exit from #0  C_CreateObject (hSession=134587040, pTemplate=0x8049160, ulCount=5,
    phObject=0xbff55560) at pkcs11-object.c:57
0x080487a4 in main ()
Value returned is $1 = 0
(gdb) x/x 0xbff55560
0xbff55560:     0xffffffff
(gdb) c
Continuing.

Breakpoint 4, C_DestroyObject (hSession=134587040, hObject=4294967295) at pkcs11-object.c:106
106             rv = sc_pkcs11_lock();
(gdb) p/x hObject
$2 = 0xffffffff
(gdb) finish
Run till exit from #0  C_DestroyObject (hSession=134587040, hObject=4294967295) at pkcs11-object.c:106
0xb7f5c6c0 17:15:56.581 [opensc-pkcs11] pkcs11-object.c:110:C_DestroyObject: C_DestroyObject(hSession=0x805a2a0, hObject=0xffffffff)
0x080487cb in main ()
Value returned is $3 = 130



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3944 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 14:50:35 +00:00
s 66f9ccaa94 fix SIGSEGV:
$ pkcs11-tool --slot 5 --login --pin "12345678" --label 1 --type data --private --write-object tmp.txt
Generated Data Object:
Data object 0
...
$ pkcs11-tool --slot 5 -O --login --pin "12345678"
Data object 135436368
  label:          '1'
  application:    '1'
  app_id:         -1
  flags:           modifiable private
...
(gdb) run
Starting program: /usr/local/bin/pkcs11-tool --slot 5 --login --pin "12345678" --label 1 --type data --delete-object

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1210333504 (LWP 7193)]
0xb7cc8181 in slot_token_removed (id=5) at slot.c:319
319                     if (object->ops->release)
(gdb) bt
#0  0xb7cc8181 in slot_token_removed (id=5) at slot.c:319
#1  0xb7cc82dd in card_removed (reader=0x811bdf0) at slot.c:132
#2  0xb7cc43e7 in C_Finalize (pReserved=0x0) at pkcs11-global.c:298
#3  0x08050fc0 in main (argc=11, argv=0xbf98d6f4) at pkcs11-tool.c:677


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3943 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-27 12:22:50 +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 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 612d66655d Introduce SC_ERROR_NOT_ENOUGH_MEMORY <=> CKR_DEVICE_MEMORY.
When trying to import a too large keyfile as a data object, TrueCrypt received a CKR_GENERAL_ERROR before this.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3926 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-23 19:12:52 +00:00
martin d43ea3f065 Remove strange characters.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3905 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-10 21:58:48 +00:00
viktor.tarasov e2dae6b97b Unlock User PIN with PKCS#11:
One of the three unblock methods can be activated from the 'opensc-pkcs11' section of opensc.conf:
- C_SetPin() in the unlogged sesssion;
- C_SetPin() in the CKU_SPECIFIC_CONTEXT session;
- C_InitPin() in CKU_SO session (inspired by Pierre Ossman).
-- This last one works, for a while, only for the pkcs15 cards without SOPIN auth object.
   For the pkcs15 cards with SOPIN, this method will be useful for the cards 
   that do not have then modes '00' and '01' of ISO command 'RESET RETRY COUNTER'.

Test commands:
# pkcs11-tool --module ./opensc-pkcs11.so --slot 0 --unlock-pin --puk "123456" --new-pin "9999"
# pkcs11-tool --module ./opensc-pkcs11.so --slot 0 --unlock-pin -l --login-type context-specific --puk "123456" --new-pin "9999"
# pkcs11-tool --module ./opensc-pkcs11.so --slot 0 --init-pin -l --new-pin "9999"



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3901 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-08 15:41:07 +00:00
s 7cf8760f9f Fix: any of these calls
C_CreateObject(hSession, NULL_PTR, 1, NULL_PTR);
C_GetAttributeValue(hSession, hObject, NULL_PTR, 1);
C_SetAttributeValue(hSession, hObject, NULL_PTR, 1);
C_FindObjectsInit(hSession, NULL_PTR, 1);
C_FindObjects(hSession, NULL_PTR, 0, NULL_PTR);
C_FindObjects(hSession, NULL_PTR, 1, NULL_PTR);
C_FindObjects(hSession, NULL_PTR, 1, pulObjectCount);
C_DigestInit(hSession, NULL_PTR);
C_SignInit(hSession, NULL_PTR, hKey);
C_SignRecoverInit(hSession, NULL_PTR, hKey);
C_DecryptInit(hSession, NULL_PTR, hKey);
C_VerifyInit(hSession, NULL_PTR, hKey);
C_GenerateKeyPair(hSession, NULL_PTR, pubKeyTmpl, arraysize(pubKeyTmpl),
prvKeyTmpl, arraysize(prvKeyTmpl), &hPubKey, &hPrvKey);
C_GenerateKeyPair(hSession, pMechanism, pubKeyTmpl,
arraysize(pubKeyTmpl), NULL_PTR, 1, &hPubKey, &hPrvKey);
C_GenerateKeyPair(hSession, pMechanism, NULL_PTR, 1, prvKeyTmpl,
arraysize(prvKeyTmpl), &hPubKey, &hPrvKey);
=>
Segmentation fault

Remark: Allow calls:
C_FindObjectsInit(hSession, NULL_PTR, 0)
C_GenerateKeyPair(hSession, pMechanism, NULL_PTR, 0, NULL_PTR, 0, phPublicKey, phPrivateKey)
C_UnwrapKey(hSession, pMechanism, hUnwrappingKey, pWrappedKey, ulWrappedKeyLen, NULL_PTR, 0, phKey)



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3891 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-10 14:50:32 +00:00
s 1ec5a6b25d fix: return CKR_ARGUMENTS_BAD from C_Login, C_InitPIN, C_SetPIN, if pPin == NULL_PTR and PinLen > 0
PKCS#11:
"To log into a token with a protected authentication path, the pPin parameter to C_Login should be NULL_PTR."
"To initialize the normal user?s PIN on a token with such a protected authentication path, the pPin parameter to C_InitPIN should be NULL_PTR."
"To modify the current user?s PIN on a token with such a protected authentication path, the pOldPin and pNewPin parameters to C_SetPIN should be NULL_PTR."


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3890 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-10 12:34:04 +00:00
s 781c3c0fff add to changeset 3887
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3888 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-08 18:34:55 +00:00
s 425ec51f78 fix:
CK_MECHANISM gostMech = { CKM_GOSTR3410_KEY_PAIR_GEN, NULL, 0 };
...
C_GenerateKeyPair(hSession, &gostMech, NULL_PTR, 0, NULL_PTR, 0, &hPubKey, &hPrvKey);
-> CKR_OK and Generate RSA Key Pair


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3887 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-08 18:28:22 +00:00
s 22a950cd0d Fix: return CKR_SESSION_READ_ONLY from C_InitPIN, C_SetPIN,
C_CreateObject, C_CopyObject, C_DestroyObject, C_SetAttributeValue,
C_GenerateKey, C_GenerateKeyPair, C_UnwrapKey, C_DeriveKey if session is
read-only.

PKCS#11:
"C_InitPIN can only be called in the 'R/W SO Functions' state."

"C_SetPIN can only be called in the 'R/W Public Session' state, 'R/W SO
Functions' state, or 'R/W User Functions' state. An attempt to call it
from a session in any other state fails with error CKR_SESSION_READ_ONLY."

"Only session objects can be created/destroyed/modified
(C_CreateObject/C_DestroyObject/C_SetAttributeValue) during a read-only
session."


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3886 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-08 14:29:49 +00:00
s 5881b46ac1 PKCS#11: Spec does not allow CKR_OBJECT_HANDLE_INVALID from C_EncryptInit, C_DecryptInit, C_DigestKey, C_SignInit, C_SignRecoverInit, C_VerifyInit, C_VerifyRecoverInit, C_WrapKey, C_DeriveKey, C_UnwrapKey
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3885 c6295689-39f2-0310-b995-f0e70906c6a9
2009-12-07 12:50:59 +00:00
s d201a1d86d add get CKA_GOSTR3410_PARAMS attribute for GOST private key
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3868 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-27 11:07:23 +00:00
s 05b96a1f5e CKR_USER_ALREADY_LOGGED_IN: It indicates that the specified user cannot be logged into the session, because it is already logged into the session.
CKR_USER_ANOTHER_ALREADY_LOGGED_IN: It indicates that the specified user cannot be logged into the session, because another user is already logged into the session.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3862 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-20 15:23:12 +00:00
s 5320ca6fd1 Corrected GOSTR3410 public key structure
Working now with GOST R 34.10:
$ pkcs15-init --store-private-key key --key-usage sign,decrypt --auth-id 2 --id 1 --pin "12345678"
$ pkcs15-init --store-certificate my_cert --id 1 --pin "12345678"

But have problem: no CKA_GOSTR3410_PARAMS by retrieve pub_key from certificate, if pub_key object was removed (see parse_x509_cert, asn1_decode_gostr3410_params)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3859 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-19 15:41:03 +00:00
martin df20fe72e1 merge [3823:3844/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3845 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-13 19:01:21 +00:00
martin 84de38855f Fix a compiler warning
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3838 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-13 11:23:16 +00:00
martin 48924f3222 Remove unused variables
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3832 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-13 11:14:10 +00:00
martin 3ea5bb7987 Merge [3804:3822/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3824 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-13 09:45:21 +00:00
martin 450e1fc5ae Merge [3794:3803/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3804 c6295689-39f2-0310-b995-f0e70906c6a9
2009-11-05 18:27:56 +00:00
martin 30ab50600b Merged [3783:3794/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3795 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-25 20:22:11 +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 95a5ab0654 Re-implement PIN cache on PKCS#15 layer; remove it from PKCS#11. Re-name and log PKCS#15 options to better reflect the purpose.
Data objects and PKCS#15 init are left broken currently.



git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3784 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-22 08:59:59 +00:00
martin ea37069272 Merged r3749:3758 from trunk
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3759 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-05 20:10:07 +00:00
martin 831d1a539e PKCS#11: Fix a crash in C_GetMechanismList if pulCount is NULL
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3732 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 10:12:24 +00:00
martin a614dff522 PKCS#11: Implement more token flags that describe available PIN retries.
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3731 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 10:05:40 +00:00
martin 446fe0f18d PKCS#11: Spec does not allow CKR_DEVICE_ERROR from C_Initialize
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3725 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:59:58 +00:00
martin 847e0ade96 PKCS#11: translate SC_ERROR_CARD_UNRESPONSIVE
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3724 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:56:39 +00:00
martin 6a48771ce1 Implement CKA_ALWAYS_AUTHENTICATE
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3722 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:51:53 +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
aj 61b8f0a35d Latest version from scute svn with this change:
Stef Walter: Make all constants UL that should be.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3712 c6295689-39f2-0310-b995-f0e70906c6a9
2009-07-23 08:30:43 +00:00
aj e8b1f540bd Kalev Lember: fix onepin-opensc-pkcs11.dll manifest embedding
with Microsoft compilers.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3707 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-28 10:08:17 +00:00
ludovic.rousseau 2752c33108 removed unused variable
misc.c:317: warning: unused variable 'i'


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3654 c6295689-39f2-0310-b995-f0e70906c6a9
2009-02-25 09:13:35 +00:00
ludovic.rousseau 042d47aaeb iattr_extract(): use sizeof(CK_CERTIFICATE_TYPE) for a
CKA_CERTIFICATE_TYPE

thanks to Wan-Teh Chang for the better patch
http://www.opensc-project.org/pipermail/opensc-devel/2009-February/011892.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3653 c6295689-39f2-0310-b995-f0e70906c6a9
2009-02-25 09:10:38 +00:00
ludovic.rousseau 4987d22c9a attr_extract(): use sizeof(CK_ULONG) instead of sizeof(CKA_CERTIFICATE_TYPE)
Thanks to Marc Rios Valles for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2009-February/011890.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3652 c6295689-39f2-0310-b995-f0e70906c6a9
2009-02-24 17:15:57 +00:00
martin 1bf7e9c418 typo fix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3645 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-30 11:59:12 +00:00
martin 24d69c655d hide_empty_tokens should not affect emulated cards (always on)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3644 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-29 11:50:21 +00:00
alonbl 09a849c906 Set default of hide_empty_tokens to true
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3639 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-23 09:30:42 +00:00
alonbl 17cf43eeb1 Rename PKCS#11 v2_20_mode option to plug_and_play
As it is the only feature it controls.
Also, change the default to true.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3637 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-23 09:14:15 +00:00
alonbl fbd51c705e Revert 3630
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3631 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-20 08:42:47 +00:00
alonbl ce5c5f3ae9 Add SCARD_E_NO_SERVICE to internal-winscard.h
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3630 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-19 19:43:19 +00:00
martin c58bcfab84 Configurable for PKCS#11 v2.20 related changes.
- Correctly report Cryptoki version if v2.20 is used.
 - Consistently report no version for hardware/software we know no version information about.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3627 c6295689-39f2-0310-b995-f0e70906c6a9
2009-01-19 12:06:38 +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
aj a89b14668f Enable lock_login by default for security.
Disable soft_keygen by default for security.
Make defaults code more readable.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3604 c6295689-39f2-0310-b995-f0e70906c6a9
2008-12-28 16:01:04 +00:00
martin f4c85e7502 Cosmetic fix for [3595]
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3599 c6295689-39f2-0310-b995-f0e70906c6a9
2008-12-05 15:57:51 +00:00
martin 94d0f8d835 Remove ancient unused code
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3598 c6295689-39f2-0310-b995-f0e70906c6a9
2008-12-05 15:53:31 +00:00
ludovic.rousseau 6f3012d959 add CKM_SHA256* and CKM_SHA384* logs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3596 c6295689-39f2-0310-b995-f0e70906c6a9
2008-11-27 10:44:57 +00:00
martin 1e41d4d267 * Fix issues with pkcs11-tool testing of C_GenerateRandom/C_SeedRandom and OpenSC PKCS#11 implementation of those functions.
Thanks goes to Rickard Bondesson who noticed the issues.

http://www.opensc-project.org/pipermail/opensc-devel/2008-November/011436.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3595 c6295689-39f2-0310-b995-f0e70906c6a9
2008-11-24 22:06:27 +00:00
martin 7b93c51230 Missing SHAs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3593 c6295689-39f2-0310-b995-f0e70906c6a9
2008-11-24 21:53:56 +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
ludovic.rousseau 56ea99d8a0 print_mech_info(): replace printf by fprintf to correctly redirect the
log


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3554 c6295689-39f2-0310-b995-f0e70906c6a9
2008-08-12 09:51:43 +00:00
alonbl 7d6cf6b694 Prepare for libtool-2
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3528 c6295689-39f2-0310-b995-f0e70906c6a9
2008-06-05 17:03:47 +00:00
ludovic.rousseau 4fd85ce0cf print_generic() & print_print(): size is a CK_ULONG (unsigned) so compare
using "!= (CK_LONG)(-1)" instead of "> 0"


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3525 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-26 08:30:39 +00:00
ludovic.rousseau 4d1218b64f completely initialize pkcs11_secret_key_ops structure with NULL pointers
secretkey.c:225: warning: missing initializer
secretkey.c:225: warning: (near initialization for 'pkcs11_secret_key_ops.destroy_object')


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3524 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-22 12:37:57 +00:00
ludovic.rousseau 28c0c6283d print_ptr_in(): change log format
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3516 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-20 09:47:27 +00:00
ludovic.rousseau 232a26b62d C_Initialize(): log the value of the pInitArgs argument
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3515 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-20 09:41:44 +00:00
ludovic.rousseau d7bb718e24 C_Finalize(): do not unload the module since the application may try to
make PKCS#11 calls again


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3513 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-12 09:41:48 +00:00
ludovic.rousseau 91177e51ec Use size_t instead of int when needed, plus some other minor changes
Patch bug.1 included in Ticket #176


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3510 c6295689-39f2-0310-b995-f0e70906c6a9
2008-05-05 13:00:01 +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 6c740b907e More MSVC fixups by Douglas E. Engert
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3503 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-29 06:09:00 +00:00
ludovic.rousseau 0b239489fc completely initialize the sc_pkcs11_framework_ops structure (using NULL
for undefined callbacks)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3498 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-28 07:36:07 +00:00
ludovic.rousseau 040ac682d8 completely initialize the struct fmap fields
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3497 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-28 07:33:26 +00:00
alonbl 865f6e9c70 More fixups to maintainer-clean
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3471 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-11 12:52:46 +00:00
alonbl d84077749b Distribute autoconf generated files for MSVC build
Construct resource files and winconfig.h using autoconf
substitutions.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3468 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-08 18:36:42 +00:00
alonbl 5f567f7a3c More MSVC build additions
(1) use the exports for opensc-pkcs11.dll, onepin-opensc-pkcs11.dll,
      and pkcs11-spy.dll

  (2) don't link common.lib with scconf.lib, to avoid duplicate messages
      later.

  (3) add piv-tool to openssl_programs.

By Douglas E. Engert



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3466 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-07 21:35:11 +00:00
alonbl 54c1c735f3 Attached are the latest mode to OpenSC svn 3462 to use the Makefile.mak
files to build on Windows.

I got rutoken to compile, and took out the #ifdef's I had in last week.
The rutoken programmer declared some variables in the middle of a block
rather then having all the declare statements at the beginning of a block
as is normally done in C. The Microsoft compile treats this as an error.
(Actual many errors.)

The makedef.pl is no longer needed, as the exports files can be used.
Note that in the original Makefile.mak files only opensc.def and
pkcs15init.def were created.

winconfig.h has a number of changes. As discussed last week this could
be created by autoconf. I also noted that the Active State Perl that
was required for the makedef.pl has a psed command that could be used
like sed to update winconfig.h.  I did not attempt to do this.



  win32/Make.rules.mak - Use ENABLE_OPENSSL and ENABLE_ZLIB

  src/tools/Makefile.mak - add the rutoken.tool.exe

  src/tools/eidenv.c - use PACKAGE_VERSION

  src/pkcs11/Makefile.mak - reorder the objest to match the list in the
           Makefile.am. Makes it easier to read.

  src/include/winconfig.h - The windows version of the config.h
           Changes based on discussions on the list last week.

  src/common/Makefile.mak - renamed modules.

  src/pkcs15init/Makefile.mak - reordered, and added back the rutoken modules
           replaced the use of makdef.pl to sue the exports file.

  src/scconf/Makefile.mak - reordered objects.

  src/libopensc/card-rutoken.c -
           error. Moved the declares to the beginning of blocks.

  src/libopensc/Makefile.mak - reorder names, and add rutoken.
           Use the libopensc.exports file.

  src/libopensc/pkcs15-prkey-rutoken.c - more moving of declare statements.

By Douglas E. Engert

http://www.opensc-project.org/pipermail/opensc-devel/2008-April/011011.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3464 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-07 19:42:43 +00:00
alonbl 6e65efb257 Some more build cleanups
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3462 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-04 20:38:20 +00:00
alonbl e4eeba26cd Fix MSVC compiler error
http://www.opensc-project.org/pipermail/opensc-devel/2008-April/010997.html

Thanks to Douglas E. Engert


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3459 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-04 16:21:08 +00:00
alonbl 87db3c96c2 More separate srcdir fixups
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3450 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-01 19:04:33 +00:00
alonbl 39abe22798 More separate srcdir fixups
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3449 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-01 17:08:17 +00:00
ludovic.rousseau 7e30721378 use $(srcdir) when needed to be able to build in separate build
directories using: cd foobar ; ../configure srcdir=..

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


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3445 c6295689-39f2-0310-b995-f0e70906c6a9
2008-04-01 12:43:26 +00:00
alonbl 2f997da125 Install PKCS#11 providers at bin for Windows
This will place file in more expected location, and
reduce runtime dependencies as dependency DLL will be located
at the same directory.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3441 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-27 14:13:00 +00:00
alonbl 80a16f686d ruToken cleanups
Move constants out of standard files.
Create ruToken specific interface.
Update symbols.

Thread at:
http://www.opensc-project.org/pipermail/opensc-devel/2008-March/010917.html

Cleanup of:
http://www.opensc-project.org/pipermail/opensc-devel/2007-December/010617.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3439 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-26 06:24:37 +00:00
alonbl 314f2a5501 Cygwin should load .dll version of PKCS#11
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3432 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-19 21:23:47 +00:00
alonbl 8ac87f1b1e Remove useless comments
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3414 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-09 21:24:24 +00:00
alonbl 0a809dd5cb Complete rewrite of OpenSC build system.
1.  Build system now supports MinGW (Windows) compilation using msys and cross compilation.
2.  Ability to explicitly disable and enable dependencies of the package.
3.  openct, pcsc and nsplugins features are disabled by default.
4.  Modified pcsc driver to use pcsc dynamically, no compile time dependency is required.
5.  --enable-pcsc-lite configuration option renamed to --enable-pcsc.
6.  Install opensc.conf file (as opensc.conf.new if opensc.conf exists).
7.  Add--enable-doc configuration option, allow installing documentation into target.
8.  Add --disable-man configuration option, allow msys mingw32 users to
    build from svn without extra dependencies.
9.  Add export files to each library in order to export only required symbols.
    Windows native build may use these files instead of scanning objects' symbols.
10. Add opensc-tool --info to display some general information about the build.
11. Create compatibility library to be linked against library instread of recompiling the
    same source files in different places.
12. Add different win32 version resource to each class of outputs.
13. Make xsl-stylesheets location selectable.
14. Some win32 fixups.
15. Some warning fixups.
16. Many other autoconf/automake cleanups.

Alon Bar-Lev

svn diff -r 3315:3399 https://www.opensc-project.org/svn/opensc/branches/alonbl/mingw

_M   .
D    configure.in
_M   src
_M   src/openssh
M    src/openssh/Makefile.am
_M   src/tools
M    src/tools/rutoken-tool.c
M    src/tools/opensc-tool.c
M    src/tools/cardos-info.c
M    src/tools/pkcs15-crypt.c
M    src/tools/pkcs15-init.c
M    src/tools/piv-tool.c
M    src/tools/netkey-tool.c
M    src/tools/eidenv.c
M    src/tools/cryptoflex-tool.c
M    src/tools/util.c
M    src/tools/pkcs11-tool.c
M    src/tools/pkcs15-tool.c
M    src/tools/util.h
M    src/tools/opensc-explorer.c
M    src/tools/Makefile.am
_M   src/pkcs11
M    src/pkcs11/pkcs11-global.c
M    src/pkcs11/framework-pkcs15.c
M    src/pkcs11/mechanism.c
M    src/pkcs11/pkcs11-display.c
M    src/pkcs11/pkcs11-object.c
A    src/pkcs11/opensc-pkcs11.exports
M    src/pkcs11/sc-pkcs11.h
M    src/pkcs11/pkcs11-spy.c
M    src/pkcs11/openssl.c
M    src/pkcs11/Makefile.am
A    src/pkcs11/pkcs11-spy.exports
_M   src/tests
_M   src/tests/regression
M    src/tests/regression/Makefile.am
M    src/tests/sc-test.c
M    src/tests/pintest.c
M    src/tests/Makefile.am
_M   src/include
_M   src/include/opensc
M    src/include/opensc/Makefile.am
A    src/include/opensc/svnignore
M    src/include/Makefile.am
_M   src/signer
_M   src/signer/npinclude
M    src/signer/npinclude/Makefile.am
M    src/signer/Makefile.am
A    src/signer/signer.exports
_M   src/common
A    src/common/compat_dummy.c
D    src/common/getopt.txt
D    src/common/strlcpy.c
D    src/common/LICENSE
A    src/common/compat_getopt.txt
A    src/common/compat_strlcpy.c
A    src/common/LICENSE.compat_getopt
A    src/common/compat_getopt.c
D    src/common/strlcpy.h
D    src/common/ChangeLog
D    src/common/getpass.c
D    src/common/my_getopt.c
A    src/common/compat_strlcpy.h
A    src/common/compat_getpass.c
A    src/common/compat_getopt.h
A    src/common/ChangeLog.compat_getopt
D    src/common/README.strlcpy
D    src/common/my_getopt.h
A    src/common/compat_getpass.h
A    src/common/README.compat_strlcpy
D    src/common/strlcpy.3
A    src/common/README.compat_getopt
D    src/common/getopt.3
D    src/common/README.my_getopt
A    src/common/compat_strlcpy.3
A    src/common/compat_getopt.3
M    src/common/Makefile.am
M    src/Makefile.am
_M   src/pkcs15init
M    src/pkcs15init/pkcs15-oberthur.c
M    src/pkcs15init/profile.c
M    src/pkcs15init/pkcs15-lib.c
M    src/pkcs15init/pkcs15-rutoken.c
A    src/pkcs15init/pkcs15init.exports
M    src/pkcs15init/pkcs15-gpk.c
M    src/pkcs15init/Makefile.am
_M   src/scconf
M    src/scconf/Makefile.am
M    src/scconf/parse.c
A    src/scconf/scconf.exports
_M   src/libopensc
M    src/libopensc/card-rutoken.c
M    src/libopensc/compression.c
M    src/libopensc/sc.c
M    src/libopensc/card-piv.c
M    src/libopensc/pkcs15-openpgp.c
M    src/libopensc/pkcs15-postecert.c
M    src/libopensc/pkcs15-tcos.c
M    src/libopensc/opensc-config.in
M    src/libopensc/reader-pcsc.c
A    src/libopensc/internal-winscard.h
M    src/libopensc/ctx.c
A    src/libopensc/libopensc.exports
M    src/libopensc/pkcs15-piv.c
M    src/libopensc/pkcs15-infocamere.c
M    src/libopensc/internal.h
M    src/libopensc/pkcs15-actalis.c
M    src/libopensc/pkcs15-starcert.c
M    src/libopensc/card-oberthur.c
M    src/libopensc/pkcs15-atrust-acos.c
M    src/libopensc/p15card-helper.c
D    src/libopensc/part10.h
M    src/libopensc/ui.c
M    src/libopensc/card-gpk.c
M    src/libopensc/pkcs15-wrap.c
M    src/libopensc/pkcs15-gemsafeGPK.c
M    src/libopensc/log.c
M    src/libopensc/pkcs15-esteid.c
M    src/libopensc/pkcs15-prkey-rutoken.c
M    src/libopensc/log.h
M    src/libopensc/Makefile.am
M    src/libopensc/reader-openct.c
_M   aclocal
M    aclocal/Makefile.am
_M   win32
M    win32/Makefile.am
A    win32/versioninfo.rc.in
A    win32/ltrc.inc
A    configure.ac
_M   doc
_M   doc/tools
M    doc/tools/pkcs15-profile.xml
D    doc/changelog.sh
D    doc/export-wiki.xsl
_M   doc/api
_M   doc/api/file
M    doc/api/man.xsl
_M   doc/api/asn1
_M   doc/api/apps
_M   doc/api/init
_M   doc/api/types
_M   doc/api/card
M    doc/api/html.xsl
_M   doc/api/misc
_M   doc/api/util
M    doc/Makefile.am
D    doc/export-wiki.sh
AM   doc/nonpersistent
A    doc/nonpersistent/export-wiki.xsl
A    doc/nonpersistent/Makefile.am
A    doc/nonpersistent/export-wiki.sh
A    doc/nonpersistent/svn2cl.xsl
D    doc/generate-man.sh
D    doc/svn2cl.xsl
M    Makefile.am
A    svnignore
_M   etc
M    etc/opensc.conf.in
M    etc/Makefile.am
D    man
_M   solaris
M    solaris/Makefile



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3405 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-06 16:06:59 +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
alonbl 1875a25c40 PKCS#11 "Application and processes" instructs the sequence
that should be taken after fork().
Applications should call C_Initialize() immediately after fork()
to reinitialize the provider.

The change monitor the pid that calls C_Initialize(), if it is
different than previous C_Finalize() is called.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3402 c6295689-39f2-0310-b995-f0e70906c6a9
2008-03-06 14:56:31 +00:00
martin 04942bb4f6 * Correctly return CKR_PIN_INCORRECT if PIN is out of range.
* By Alon Bar-Lev from svn diff -r 3397:3398 https://www.opensc-project.org/svn/opensc/branches/alonbl/pkcs11-login-rv



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3400 c6295689-39f2-0310-b995-f0e70906c6a9
2008-02-29 10:18:51 +00:00
ludovic.rousseau 91288d4955 remove $(pkcs11dir)/opensc-pkcs11.so so that creating the symbolink link
does not fail if the file already exists.

Thanks to Jean-Pierre Szikora for the bug report


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3314 c6295689-39f2-0310-b995-f0e70906c6a9
2008-01-11 16:28:00 +00:00
ludovic.rousseau bf9d6beaac new patch for ruToken support
Thanks to Andrew V. Stepanov
http://www.opensc-project.org/pipermail/opensc-devel/2007-December/010631.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3310 c6295689-39f2-0310-b995-f0e70906c6a9
2008-01-03 08:59:14 +00:00
ludovic.rousseau 0ecc294ed8 add support of ruToken
Thanks to Andrew V. Stepanov for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2007-December/010617.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3304 c6295689-39f2-0310-b995-f0e70906c6a9
2007-12-17 13:39:20 +00:00
ludovic.rousseau 4bf320b304 add support of /usr/lib/pkcs11/ directory. See
http://wiki.cacert.org/wiki/Pkcs11TaskForce

Thanks to Alon Bar-Lev for the better patch


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3300 c6295689-39f2-0310-b995-f0e70906c6a9
2007-11-13 09:38:18 +00:00
aj 177ff402f3 fix typo, found by Gürer Özen.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3259 c6295689-39f2-0310-b995-f0e70906c6a9
2007-08-28 20:34:42 +00:00
aj 9a10cdeebd add cflags for ltdl.h where needed.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3245 c6295689-39f2-0310-b995-f0e70906c6a9
2007-08-13 19:10:26 +00:00
ludovic.rousseau 345ce22c63 use LTLIB_CFLAGS and LTLIB_LIBS instead of the global LIBS to find and use
libltdl

thanks to Alon Bar-Lev for the patch


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3243 c6295689-39f2-0310-b995-f0e70906c6a9
2007-08-13 08:30:19 +00:00
aj dea6f8b090 update pkcs11.h header file from scute.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3196 c6295689-39f2-0310-b995-f0e70906c6a9
2007-07-03 14:14:58 +00:00
aj 4ca4eba365 silence more warnings by gcc/sparse.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3189 c6295689-39f2-0310-b995-f0e70906c6a9
2007-06-21 13:58:38 +00:00
aj 0c604cb294 silence more warnings.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3183 c6295689-39f2-0310-b995-f0e70906c6a9
2007-06-21 12:58:57 +00:00
aj c66889dc9e fix broken changes.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3182 c6295689-39f2-0310-b995-f0e70906c6a9
2007-06-21 12:14:50 +00:00