Commit Graph

954 Commits

Author SHA1 Message Date
Frank Morgner 9f318b829f remove slots of removed readers 2015-04-21 02:00:06 +02:00
Frank Morgner 54f285d57a correctly handle readers that have been removed 2015-04-21 01:04:18 +02:00
Frank Morgner c45c90a337 sc_pkcs11_close_all_sessions: close all sessions even if closing one fails 2015-04-20 16:18:11 +02:00
Frank Morgner 643080baf9 honour key capabilities for decryption/verification
fixes #419
2015-04-12 11:28:25 +02:00
vletoux 8ea328ff7f Minor code quality improvements.
Basically checks that the memory allocation succeed.

The ctbcs.c change improve the readability
because count = 0 and len > 254 does not add any value.

VTA: added few coding style changes
2015-04-05 13:15:57 +02:00
Frank Morgner c019a62309 pkcs11: parameter checking for 'get_mechanism_list'
fixes #409
2015-03-29 12:11:08 +02:00
Viktor Tarasov 6f6286de99 pkcs11: generate EC key: use allocated EC params
For internal use allocate and copy the EC params data from the caller's template,
rather then use them directly as a pointer in internal public key data.
2015-03-04 19:47:13 +01:00
Frank Morgner 16ea926d29 fixed indentation 2015-02-20 19:54:40 +01:00
Viktor Tarasov fa923831f8 introduce EC curve OID into algorithm info data
needed to store information about EC curve supported by card.
Primary usage is when importing/generating key to get know if particular curve is supported by card.
2015-02-20 13:49:18 +01:00
Thomas Calderon 22fb49b554 PKCS#11: Improve compliance for public keys.
* Key usage required when calling C_CreateObject for public key are not used.
    This adds the logic to convert from PKCS#11 attributes to PKCS#15 in the
    structure that is sent to underlying _store_pubkey functions.
2015-02-07 20:17:12 +01:00
Viktor Tarasov 96265e6d08 pkcs15init: superpluous 'ec-params' in init data
Pkcs15init data, used to import/generate key objects, includes twice the same EC parameters data:
 - explicit 'params' data
 - part of sc_pkcs15_pubkey/sc_pkcs15_prkey
Explicit 'ec-params' data is removed.
2015-02-07 20:00:41 +01:00
Viktor Tarasov 08eb700b97 revert or partially revert some of recent commits
b94c163 - invalid, non-tested
11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored,
3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373
3a92bf7 -- src/tools/piv-tool.c -- confirmed by author
6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
2015-02-07 19:31:17 +01:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +01:00
Frank Morgner 11881a61b8 removed/fixed dead code 2015-02-05 01:38:41 +01:00
Frank Morgner 6759c04b26 don't ignore errors 2015-01-28 04:45:08 +01:00
Frank Morgner ac0424e947 fixed pkcs11spy's version number 2015-01-28 07:09:02 +01:00
Frank Morgner 77752f442d fixed unused value 2015-01-28 05:47:20 +01:00
Frank Morgner 7a34c204c1 fixed dereference before null check
silence warnings reported by coverity-scan
2015-01-22 20:29:33 +01:00
Mathias Brossard 762d466b23 Add display of Elliptic Curve flags 2015-01-20 23:15:41 -08:00
Mathias Brossard 7a455f64c7 Support of additional type, mechanisms and attributes 2015-01-20 23:15:31 -08:00
Mathias Brossard 3dadd3fba1 Add some missing PKCS#11 values 2015-01-20 23:15:22 -08:00
Mathias Brossard 17c1cffb3d Fix typo on CKF_EC_UNCOMPRESS 2015-01-20 23:14:50 -08:00
Mathias Brossard c3a0bbc715 Update email and year 2015-01-20 23:14:36 -08:00
Thomas Calderon ed87ea38b9 PKCS#11: Fetch real value of CKA_LOCAL for pubkey
* Fetch value from pub_info structure for CKA_LOCAL attribute.
2015-01-14 17:38:08 +01:00
Thomas Calderon d727acb47a PKCS#11: Remove inconsistent attributes
* Improve compliance related to PKCS#11 attribute fetching.
2015-01-14 17:22:43 +01:00
Thomas Calderon 4915eaa56b Improve PKCS#11 compliance. Issue #335
* This simple patch allows for values of PKCS#11 attributes to be fetched
  from the underlying card.
2015-01-05 14:00:22 +01:00
Doug Engert cd01a73caf C_Digest does not check if buffer too small before update. Issue #327
C_Digest will now query for the buffer size using sc_pkcs15_md_final
before calling sc_pkcs15_md_update. This avoids doing a double update
when the user passes in a buffer to small, then gets the buffer and calls
C_Digest again.
2014-12-02 11:15:24 +01:00
Frank Morgner 8672291a73 Merge pull request #312 from frankmorgner/fix-p15
fixed type of pkcs15init_initialize
2014-11-05 10:38:42 +01:00
Doug Engert fd22098e19 Public certs and pubkeys with an auth_id are treated as private (See #291)
Code to test for an auth_id for certs and pubkeys was removed.
See: PKCS#15 section 4.1.3 Access methods

This is conseritive change and all objects could be treaded the same.
2014-11-01 14:02:39 -05:00
Frank Morgner d3c8fbcf1d fixed type of pkcs15init_initialize
regression from 95b6b4cc
2014-10-27 23:22:40 +01:00
Doug Engert 189e998486 PKCS#11 hashes for cards without RAW (see #241)
The framework-pkcs15.c did not add hashes correctly if the card did not support RSA RAW.
    This change fixes that and only adds hashes if the card did not specify a list of hashes.
    It also will not add hashes done in software if ENABLE_OPENSSL is not specified.
    Some error conditions are also tested for EC mechanisms.

    See bug report #241 for more information.
2014-10-13 10:29:27 -05:00
Andreas Schwier be200ab3c8 Merge pull request #282 from CardContact/fix-deleted-related-public-key
framework-pkcs15: Duplicate public key related to private key rather than referencing the framework object

Referencing the related public key is required to return PKCS#11 attributes for a private key only available
in the public key object (i.e. CKA_MODULUS). This patch adds a copy of the public key to the private key object rather than
referencing the public key object in the framework. This prevents SEGV when the public key framework object
is deleted with C_DestroyObject, but the reference from the public key remains intact.

The bug leads to all kind of stability problems when keys are created and deleted in the same session.

The patch is in particular important if OpenSC is used with EJBCA or any other application using the
SUN PKCS#11 provider: When generating key pairs, then the public key object is eventually garbage collected
which removes the related object in the PKCS#11 module. Because there is no fixed time for this operation,
corruption occurs at random.

In a next step, the remaining related_xxx fields in sc_pkcs11_object should be revised and possibly removed.

framework: Added more error checking
2014-09-07 23:47:24 +02:00
Andreas Schwier e6505b3d9c pkcs11: Fixed wrong reference to PIN object in C_SetPIN() for SO-PIN 2014-09-07 22:11:39 +02:00
Frank Morgner 5d6c4b391d Merge pull request #253 from github-frankmorgner/remove-deadcode
card-asepcos: removed dead code
card-authentic: removed dead code
card-belpic: removed dead code
card-epass2003: removed dead code
card-flex: removed dead code
card-gpk: removed dead code
card-oberthur: removed dead code
card-piv: removed dead code
card-setcos: removed dead code
ctbcs: removed dead code
cwa14890: removed dead code
muscle: removed dead code
pkcs15-atrust-acos: removed dead code
pkcs15-gemsafeV1: removed dead code
pkcs15-skey: removed dead code
reader-ctapi: removed dead code
framework-pkcs15: removed dead code
pkcs11-object: removed dead code
pkcs15-asepcos: removed dead code
pkcs15-cardos: removed dead code
pkcs15-jcop: removed dead code
pkcs15-lib: removed dead code
pkcs15-oberthur: removed dead code
parse: removed dead code
sclex: removed dead code
sm-card-authentic: removed dead code
sm-card-iasecc: removed dead code
sm-cwa14890: removed dead code
sm-global-platform: removed dead code
sc-test: removed dead code
pkcs11-tool: removed dead code
pkcs15-tool: removed dead code
2014-09-07 21:22:43 +02:00
Emanuele Pucciarelli ee0566af09 pkcs11: pr-239: PKCS15 pubkey release fix 2014-06-01 18:55:56 +02:00
Raul Metsma 77c71be833 Don't depend configuration default value 2014-05-31 21:15:19 +02:00
Raul Metsma ccf6da2dbe Add windows onepin makefile 2014-05-31 21:15:19 +02:00
Raul Metsma 8e13acf51e Restore pkcs11 onepin module for Firefox usage 2014-05-31 21:15:19 +02:00
Henrik Andersson de6d61405b Dont use sha256 if openssl is older than 0.9.8. 2014-05-14 22:11:31 +02:00
Viktor Tarasov 808fff2246 pkcs11: take pubkey CKA_VALUE from pub_data 2014-05-13 18:34:09 +02:00
Viktor Tarasov b6ad7a92f5 pkcs11: more of debug messages 2014-05-13 18:33:58 +02:00
Frank Morgner a64326e768 fixed compiler warnings (partially submitted)
Signed-off-by: Frank Morgner <morgner@informatik.hu-berlin.de>

PR-222: commit 0b567dbaa8
partially submitted by Viktor Tarasov
2014-05-03 21:47:15 +02:00
Henrik Andersson fc5714a4c9 Set missing default create_slots_flags.
Without this pkcs11 cant be used without a configuration file
or a configfile without pkcs11 block due to the missing initialization
of default flag.
2014-04-21 13:53:57 +02:00
Viktor Tarasov dd5115bc02 pkcs15: use 'direct' public key value
pkcs15: in pubkey-info data
 * introduced new 'direct' 'raw' and 'spki' members
 * removed 'encoded der data' member
 * in 'read-public-key' try firstly SPKI direct value

pkcs11:
'direct' data used when getting CKA_VALUE attribute of public key

pkcs15init:
 * initialize 'raw' and 'spki' direct public key value
2014-02-09 18:49:58 +01:00
Viktor Tarasov 3f023d3342 pkcs15: PIN value not validated in pkcs15-verify
In pkcs15-verify the value of PIN is not more validated for conformity with PIN policy,
value is only checked for maximal allowed length.

So that, no more need of 'ignore-pin-length' configuration option - now it's default behavior of common framework.
2014-01-19 19:19:17 +01:00
Viktor Tarasov 0fa475ee5f build: define in configure.ac.in the common fields of version-info 2013-12-30 10:31:21 +01:00
Viktor Tarasov aec6f99ff4 win32: build: add 'VarFileInfo' block to version-info 2013-12-29 22:00:29 +01:00
Viktor Tarasov 53ed5dc502 win32: build: 'version-info' resource for each target 2013-12-29 22:00:29 +01:00
Viktor Tarasov 0761a5ea02 pkcs11: use 'ignore-pin-length' config option
When doing C_Login default behavior is to ignore the applied PINs with lengths less
then value of PKCS#15 PIN attribure 'min-length'. Such a PINs are not
really verified by card.

With 'ignore-pin-length' option in 'true' all applied PINs are verified by card.
2013-12-29 22:00:28 +01:00
Viktor Tarasov 77bed45283 pkcs11: implement generic 'init-token' procedure 2013-12-29 22:00:28 +01:00
Viktor Tarasov 161c83ff8b pkcs11: allow bind of non-recognized cards
To prepare C_InitToken of the non-initialized cards
allow bind of the non-recognized card
2013-12-29 22:00:28 +01:00
Viktor Tarasov 98333e56df pkcs11: excessif check of return value
tiny coding style fix
2013-12-29 22:00:28 +01:00
Viktor Tarasov d7285843f6 pkcs11 framework: more debug logs in 'login' handler 2013-12-29 19:46:56 +01:00
Viktor Tarasov 95b6b4ccd3 pkcs11: changes in framework API
to prepare future enhancements and in the sake of uniformity
in 'struct sc_pkcs11_framework_ops'
the 'struct sc_pkcs11_card' argument of 'init_token' handler is changed for 'struct sc_pkcs11_slot'

coding style issues
2013-12-29 19:46:56 +01:00
Viktor Tarasov f43a9fa41c pkcs11: fix translation of SC error to PKCS11
SC error SC_ERROR_WRONG_CARD and SC_ERROR_NO_CARD_SUPPORT are translated as CKR_TOKEN_NOT_RECOGNIZED
2013-12-29 19:46:56 +01:00
Viktor Tarasov 9fdd9ecaeb pkcs11: PIN-NOT-INITIALIZED error concerns only User PIN
C_Login returns CKR_USER_PIN_NOT_INITIALIZED error when token info flags do not
contains CKF_USER_PIN_INITIALIZED and CKU_USER login type is asked.

This flag is not consulted when CKU_SO or CKU_CONTEXT_SPECIFIC login type is needed
2013-12-29 19:46:56 +01:00
Doug Engert 03c196eeaf ECC ecpointQ Fixes
The original ECC code in OpenSC stored the ecpointQ as a DER encoded OCTET STRING.
Shortly before 0.13.0, code changes where made to store the ecpointQ as raw data
without the DER encoding.

Only some of the code was changed to support this but not all, and the comments
that said the ecpointQ was in DER where not changed either.

Some card drivers continued to work, using the original code in all place,
while some cards failed, as they where using a mixture of original code and
0.13.0 code.

This commit fixes these problems.

The ecpointQ is stored in raw format

A new structure type sc_pkcs15_u8 is defined.

The ecpointQ are changed to use the struct sc_pkcs15_u8. This was done to avoid
 the confusion of using struct sc_pkcs15_der to hold non-DER encoded data.
(There may be other uses for this too...)

Comments are change is many places.

sc_pkcs15_decode_pubkey_ec was fixed to store the raw ecpointQ correctly.

sc_pkcs15_pubkey_from_spki was change to get the sc_ec_params from the alg_id
and fix up u.ec.params. Unfortunately the OpenSC code has two places EC parameters
are stored. They can get out of sync, or there may still be code
that looks in the wrng oplace. o(TODO get it to only only place.)

The u.ec.params.field_length is now set in a number of places, as this is need
in many of the PKCS#11 routines.

framework-pkcs15.c will now correctly return the DER encode ecpointQ,
for the CKA_EC_POINT attribute using pubkey->data which has the DER encoding
for the ecpointQ.

framework-pkcs15.c will look for the EC parameters in either the u.ec.params.der,
or in the alg_id->params. (TODO get it to only only place.)

pkcs15-myeid.c has some comments, as it looks like the code is storing a TLV
rather then a DER encoding of the ecpointQ. With the wrong encoding PKCS#11 will
return the wrong attribute for CKA_ECDSA_PARAMS.

pkcs15-piv.c is changed so emulation of a pubkey taken from a certificate will
work correctly.
2013-11-06 16:31:34 -06:00
Viktor Tarasov f641ebd248 fixed errors reported by cppcheck: part 1
partially applied the pull request #182 from Frank Morgner -- updated the common frameworks source files
2013-09-29 20:28:45 +02:00
Frank Morgner 9a05414f9a let OpenSC compile without OpenSSL and without SM 2013-07-10 16:22:33 +02:00
Viktor Tarasov e8eb4cd7ed pkcs11-framework: do not wrap subject in a second ASN1 sequence
In a supplement to f5d53ab01783b0c37802e35f063fdbe5814bdbc7.

Subject and Issuer, returned by pkcs#15 framework, are already encoded as ASN1 sequence.
No need to wrap them in a second ASN1 sequence frame.
2013-04-07 17:09:15 +02:00
Martin Paljak 32ed309037 pkcs11: use calloc instead of malloc; remove obsolete malloc.h references. 2013-03-15 23:02:02 +02:00
Martin Paljak 3b4f7b9ff7 pkcs11: Don't touch readers or inserted cards in C_Initialize in 2.20 mode
This significantly speeds up calling C_Initialize.
Thanks to Nikos Mavrogiannopoulos for the tip.
2013-03-15 23:01:16 +02:00
Martin Paljak c2b6a0d500 pkcs11: report the library version based on plug-n-play feature. 2013-03-15 21:28:29 +02:00
Viktor Tarasov 6f1ae23b1e pkcs11: segfault if 'application-file' not defined
for some cards with emulated PKCS#15 'file_app' from 'application-info' is not defined
2013-03-12 10:23:35 +01:00
Martin Paljak 16ee818440 Update domain name. paljak.pri.ee is gone since 2011. 2013-02-25 11:58:25 +02:00
Anthony Foiani 27c677188e pcks11: trivial: fix debug output for CKA_PRIME_1 and CKA_PRIME_2
Without this patch, debugging output issues these as unknown
attributes:

  ... C_CreateObject(): CKA_PRIVATE_EXPONENT = 97F798...
  ... C_CreateObject(): Attribute 0x124 = EFE5AD...
  ... C_CreateObject(): Attribute 0x125 = D4D3F6...
  ... C_CreateObject(): CKA_EXPONENT_1 = 5815FD...

With this patch, we see:

  ... C_CreateObject(): CKA_PRIVATE_EXPONENT = 97F798...
  ... C_CreateObject(): CKA_PRIME_1 = EFE5AD...
  ... C_CreateObject(): CKA_PRIME_2 = D4D3F6...
  ... C_CreateObject(): CKA_EXPONENT_1 = 5815FD...

Signed-Off-By: Anthony Foiani <anthony.foiani@gmail.com>
2012-11-20 08:46:27 +01:00
Viktor Tarasov 6c051f8490 pkcs11: check arguments in get_bignum_bits() procedure
t451: segmentation fault when getting public key bits number
2012-11-12 16:46:25 +01:00
Viktor Tarasov 4cf3a3b204 move CK_VERSION data from 'pkcs15' to 'sc-card'
CK_VERSION is included into PKCS#11 data but is not specified by PKCS#15.

CK_VERSION can be provided by card's pkcs15 emulator or by the card's driver,
including the cards with the native support of pkcs#15 (and thus without pkcs15 emulator).

That's why the more general solution is to have these data included into 'sc-card' data type.
2012-10-21 16:24:11 +02:00
Andreas Schwier aaedef70b5 sc-hsm: Added ability to initialize SmartCard-HSM using C_Initialize and C_InitPIN on PKCS#11 interface 2012-10-21 15:51:55 +02:00
Andreas Schwier fba298c6f4 pksc11: Added ability to indicate hardware and firmware version information at PKCS#11 interface 2012-10-21 15:51:55 +02:00
Viktor Tarasov 40ff0e4ede pkcs11: Fixed SIGV when deleting public key objects via PKCS#11
Thanks to Andreas Schwier.
2012-10-02 09:26:35 +02:00
Andreas Schwier a9393aa983 framework-pkcs15: Fixed a SIGV when key generation returned ERROR_NOT_SUPPORTED 2012-10-01 13:04:02 +02:00
Andreas Schwier db3f5f5f17 framework-pkcs15: Fixed issued with uninitialized variable keysize 2012-10-01 13:04:02 +02:00
Viktor Tarasov 249b769a4b pkcs11: unlink 'pubkey' FW object when deleting related certificate
Thanks to Andreas Schwier.
http://www.opensc-project.org/pipermail/opensc-devel/2012-September/018455.html

In PKCS#11 FW, the 'certificate' FW object is used to create corresponding 'public'key' FW object
or to get some of its attributes.
Seg.fault occured when, in the same session, the related certificate was destroyed and after that
there was the attempt to get such public key attributes.
2012-10-01 10:47:52 +02:00
Viktor Tarasov df9a4d0b2c pkcs15: for 'sc_pkcs15_cer's data use the 'der' object type
To hold the raw certificate blob in 'sc_pkcs15_cert' data use the 'sc_pkcs15_der' data type.
also:
; in 'pkcs15-cert.c' use short call of the debug messages;
; in 'destroy-object' pkcs15 framework handler take into account the multi-application cards:
-- when binding card use the application info;
-- when finalizing profile use the application ID.
2012-09-30 22:54:52 +02:00
Ludovic Rousseau ea40e7fe24 Use AM_CPPFLAGS instead of INCLUDES
Fix autoreconf warnings:

$ autoreconf -vis -Wall
[...]
src/common/Makefile.am:12: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/libopensc/Makefile.am:19: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/minidriver/Makefile.am:15: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/pkcs11/Makefile.am:10: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/pkcs15init/Makefile.am:36: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/scconf/Makefile.am:12: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/sm/Makefile.am:8: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/tests/Makefile.am:9: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
src/tools/Makefile.am:15: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
2012-09-25 23:03:38 +02:00
Viktor Tarasov 58b4304957 libopensc: 'init', 'format', 'compare', 'is-valid' OID procedures
In a reason of number of bugs(*) that concern the OID management,
the general usage OID procedures 'init', 'format', 'compare', 'is-valid' are introduced.
These procedures should be used by all actors: libopensc, pkcs15, pkcs11, tools, ....

(*)
This bug reported by Andreas Schwier :
8e75d971cb (commitcomment-1792477)

In pkcs15-algo sc_asn1_get_algorithm_info() can return the OID without ending '-1's:
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L452
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L459
2012-09-06 10:47:29 +02:00
Andreas Schwier dc927fbe3c sc-hsm: Undo the change to mechanism.c in commit f24bcd346340d80b552c0859942a49fd5e8feeff
sc-hsm: Change ECDSA signature format from DER to r/s format
2012-08-20 11:22:02 +02:00
Andreas Schwier f678b68650 Activated ECDSA for SmartCard-HSM
Fixed issues in pkcs11-tool/test_signature is card has RSA and ECDSA keys
Fixed bug in sc_pkcs11_signature_size that returns the wrong ECDSA signature size
2012-08-20 11:22:02 +02:00
Viktor Tarasov ca08e97ab7 pkcs11: #162,#370,#115,#413: reselect application DF issue
Limit the number of cases when applicated re-selection of application DF to strict minimum.
I.e. only when pkcs11 login session is not locked and private key PKCS#15 object do not
contain the 'path' attribute.
2012-08-19 18:18:59 +02:00
Viktor Tarasov dfbc3996bf pkcs11: #439: 'SEQUENCE' of 'SET' issue when comparing cert attributes
Thanks to 'crank'.
https://www.opensc-project.org/opensc/ticket/439

Some pkcs11 callers (i.e. netscape) will pass in the ASN.1 encoded SEQUENCE OF SET,
while OpenSC just keeps the SET in the issuer/subject field.
2012-08-15 19:59:09 +02:00
Diego Elio Pettenò 1d6fae2241 build: use autoconf's MKDIR_P not automake's (deprecated) mkdir_p. 2012-07-01 17:03:27 +02:00
Mathias Brossard e423bac474 Move case block so that fall-through works as intended 2012-06-28 16:59:40 +02:00
Mathias Brossard bfbef6fe2b Support key type inference for CKM_GOSTR3410_KEY_PAIR_GEN 2012-06-28 16:56:59 +02:00
Mathias Brossard 3fc4547e45 Add CKM_GOSTR3410_KEY_PAIR_GEN if card supports onboard generation 2012-06-26 10:48:49 +02:00
Viktor Tarasov da894500c9 minidriver: build dependence on opensc_a.lib and pkcs15init.lib
spelling of comments and debug messages
2012-06-08 20:17:36 +02:00
Ludovic Rousseau 02a2b3d887 Display the flags argument of C_Initialize()
The the pInitArgs argument of C_Initialize() is not NULL it is a pointer
to a CK_C_INITIALIZE_ARGS structure.
This structure contains a flags bitfield with possible values:
- CKF_LIBRARY_CANT_CREATE_OS_THREADS
- CKF_OS_LOCKING_OK

This flags parameter is now parsed and displayed.
2012-06-04 15:42:57 +02:00
Viktor Tarasov 2cff47d9b3 pkcs11-tool: support for secret-key objects
support of 'secret-key' objects
key conversion procedures are now in libopensc library
change name for OPENSC NON-REPUDIATION CKA attribute
2012-06-02 18:25:23 +02:00
Viktor Tarasov fe80ffdbd2 pkcs11-spy: invalid ExpandEnvironmentStrings() call parameter
pkcs11-spy.c(168) : warning C4047: 'function' : 'DWORD' differs in levels of indirection from 'DWORD *'
pkcs11-spy.c(168) : warning C4024: 'ExpandEnvironmentStringsA' : different types for formal and actual parameter 3
pkcs11-spy.c(205) : warning C4047: 'function' : 'DWORD' differs in levels of indirection from 'DWORD *'
pkcs11-spy.c(205) : warning C4024: 'ExpandEnvironmentStringsA' : different types for formal and actual parameter 3
2012-05-30 10:08:30 +02:00
Viktor Tarasov 9c5dbea883 pkcs11: ECHD and secret keys support from Douglas
This support were initially proposed by Douglas (https://github.com/dengert/OpenSC/commits/ecdh) and
then merged into SM branch (https://github.com/viktorTarasov/OpenSC-SM/tree/secure-messaging).
2012-05-28 20:06:23 +02:00
Viktor Tarasov 76b8ad8ad6 pkcs11-spy: timestamp, environment strings in paths
Add to the spy logs the timestamp with millisecond resolution.
Environment strings are accepted in the key registries paths related to spy module.

pkcs11-spy: code formatting
2012-05-28 20:05:28 +02:00
Viktor Tarasov 10e1ad001d pkcs15init: change sc_pkcs15init_bind() prototype
Add new argument 'application-info',
that will allow to select the on-card application to by binded with.

pkcs11: use sc_pkcs15init_bind with 'AID' argument

Prototype of sc_pkcs15init_bind() has been changed to add argument with
AID of the on-card application to be binded with.
2012-05-26 09:36:25 +02:00
Viktor Tarasov 343fa20a00 pkcs11: create tokens and slots for multiple on-card applications
In card detection procedure bind all present applications
and create tokens for them.

Treatement of the different 'create-slots' configuration cases,
joining the objects from different applications into one slot
are previewed for the next commits.
2012-05-23 09:22:41 +02:00
Viktor Tarasov 14049fb806 pkcs11: prepare internal API for multi-application mode
- simplify some of framework handles: remove from it's prototype the arguments that can be derived from the other arguments;
for exemple: foo(slot, slot->card) --> foo(slot)
- add the 'application' argument to the bind, unbind and similar handles;
- preview more then one framework data attached to the pkcs11card object.
- placehold for the future 'derive' and 'can_do' handles.
2012-05-22 17:18:00 +02:00
Viktor Tarasov d1cf65754b pkcs11: no more 'hacked' mode and 'onepin' module version
'OnePIN' version of opensc-pkcs11 module is not installed.
Instead, in the 'pkcs11' section of OpenSC configuration,
there is a possibility to define in a different manner
how to create slots for the present PINs and applications.
2012-05-21 19:19:38 +02:00
Diego Elio Pettenò e88c08d138 build: allow cross-compilation build by reordering libraries' order.
If the system libraries are set before the locally built libraries,
libtool will pick the system copy of OpenSC instead of the local one,
and that can make cross-builds fail badly.

This patch is already applied in Gentoo for proper building.
2012-05-16 17:18:38 +02:00
Diego Elio Pettenò 3c324b8b73 build: fix parallel install by creating directory in the rule
Relying on the rule that creates the directory is a bad idea to be
parallel safe.
2012-05-16 17:18:38 +02:00
Viktor Tarasov 20bf3f5484 pkcs11: use short form of log messages
Change-Id: Ice298552238da9eeb0b646fc1ddfaf4d7a8ee4bb
2012-05-13 00:27:38 +02:00
Viktor Tarasov cb13633634 remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: If170e830d8d9587a31742feffb6fff54cfdf75b4
2012-04-03 00:00:56 +02:00
Alon Bar-Lev df8715849d Remove libltdl: Remove ltld references
http://www.opensc-project.org/pipermail/opensc-devel/2011-December/017490.html
cherry-picked from 'libtool' branch of Alon Barlev's github project git://github.com/alonbl/OpenSC.git
and rebased

Remove libltdl: Remove ltld references
(cherry picked from commit a350326c520c5b0cb185f90946648633f4d0e456)

Remove libltdl: Detect libdl
(cherry picked from commit 51e7de45c11823460e776492dcbd40e60583a7eb)

Remove libltdl: Use libscdl
(cherry picked from commit 09f3eadb8a1a47407c011dcd3d5ce461516f3b87)

Remove libltdl: Cleanup libscdl
(cherry picked from commit 52d5f1be01146079e3a6fad1c88ebb0f577d0a94)

Remove libltdl: Cleanup libscdl usage at Microsoft VC build

Untested, I don't have the environment, Martin, please test.
(cherry picked from commit 7fb18f8d0b0bae6d181981a0c71190440e917c2c)

Change-Id: I73c98ccb9365584b12f4b0b97b69316a190b6e45
2012-03-17 20:55:05 +01:00
Ludovic Rousseau c20cd12809 Fix lookup_enum_spec() prototype
A change introduced in c0072d16dd made the
compilation fail:
pkcs11-display.c:738:1: error: conflicting types for 'lookup_enum_spec'
pkcs11-display.h:64:13: note: previous declaration of 'lookup_enum_spec' was here
2012-02-20 14:01:53 +01:00
Viktor Tarasov c0072d16dd pkcs11: coding style
Signed-off-by: Viktor Tarasov <viktor.tarasov@gmail.com>
2012-02-20 11:54:02 +01:00
Viktor Tarasov 8f9bbbe780 pkcs11: win32 compilation error
pkcs11-display.c(139) : error C2275: 'CK_BYTE' : illegal use of this type as an expression

Signed-off-by: Viktor Tarasov <viktor.tarasov@gmail.com>
2012-02-20 11:34:22 +01:00
Ludovic Rousseau 48f8f982a0 Display the ASCII equivalent of a hex dump
The output format of a hex dump has changed from:
    668C045A 1C3A4EF4 CF8550F3 20926525 1E8BF478
to:
    00000000  66 8C 04 5A 1C 3A 4E F4 CF 85 50 F3 20 92 65 25  f..Z.:N...P. .e%
    00000010  1E 8B F4 78                                      ...x

Is it now possible to find text strings inside a hex dump
2012-01-10 13:44:20 +01:00
Ludovic Rousseau 9252eec2d3 Fix compiler warning and real problem
openssl.c: In function 'sc_pkcs11_verify_data':
openssl.c:384:19: warning: 'pkey_ctx' may be used uninitialized in this function [-Wuninitialized]
openssl.c:325:16: note: 'pkey_ctx' was declared here
2012-01-09 11:02:31 +01:00
Martin Paljak ea4eee5dc2 Merge remote-tracking branch 'ludovic/master' into proposed 2011-06-28 11:18:23 +03:00
Martin Paljak 78adc76da3 Merge remote-tracking branch 'viktor/master' into proposed 2011-06-28 11:17:36 +03:00
Ludovic Rousseau b7c2836d94 C_Digest(): check context validity before logging
If the context is invalid (no C_Initialize) the we get a:
log.c:76: sc_do_log_va: Assertion `ctx != ((void *)0)' failed.
2011-06-23 16:10:46 +02:00
Ludovic Rousseau 1f6a85fea9 only C_GetFunctionList needs to be exported
Calling applicatinos must locate function pointers through
C_GetFunctionList() after dlopen().
2011-06-23 11:57:05 +02:00
Ludovic Rousseau ce2d3c09be Check the lib is initialized before logging
C_CloseSession() and C_CloseAllSessions() were calling sc_debug() before
any check on the validity of the context. So if C_Initialize() was not
previously called you get an assert:
log.c:76: sc_do_log_va: Assertion `ctx != ((void *)0)' failed.
2011-06-21 10:41:41 +02:00
Viktor Tarasov c2abd9fd16 win32: build static version of the onepin PKCS#11 module 2011-06-14 14:38:58 +02:00
Martin Paljak 5a23069671 pkcs11: only C_GetFunctionList needs to be exported, calling applicatinos must locate function pointers though it after dlopen() 2011-06-14 14:41:29 +03:00
Viktor Tarasov b9f0513744 win32: build only static version of the PKCS#11 module 2011-06-14 11:47:01 +02:00
vtarasov ba64c5573d pkcs11: framework-pkcs15: invalid function name
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5568 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-11 20:17:30 +00:00
vtarasov 9863072845 pkcs11: framework-pkcs15: OpenSC specific 'non-repudiation' cryptoki attribute ...
In PKCS#11 there is no CKA_ attribute dedicated to the NON-REPUDIATION flag.
We need this flag in PKCS#15/libopensc to make dinstinction between 'signature' and 'qualified signature' key slots.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5567 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-10 16:46:41 +00:00
vtarasov a7607b8f30 pkcs11: framework-pkcs15: when storing private key, set the key usage from the object attributes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5566 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-10 16:41:04 +00:00
vtarasov efc5760646 win32: build also static version the pkcs11 module
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5551 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 16:14:11 +00:00
vtarasov d888b3fd55 pkcs15: use general 'AuthenticationObject' instead of 'PinObject'
now the attributes of the previous 'pin-info' data type are included
as the sub-type attributes of the general 'auth-info' data .
It will allow to include support of the 'biometricTemplate' and 'authKey' authentication types.

http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016655.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5550 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:46:25 +00:00
vtarasov d43e692e98 pkcs11: implement changing of SoPIN
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5540 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 18:17:02 +00:00
vtarasov 35bd07ed5e pkcs11: with 'init-pin-in-SO-session' PIN unblock style, try to set PIN when PUK value is not available
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5539 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 18:05:02 +00:00
vtarasov b3cbf5453e pkcs11: resolve problem 'change 5421 breaks MIT Kerberos login', thanks to Douglas.
http://www.opensc-project.org/pipermail/opensc-devel/2011-June/016734.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5537 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 17:20:10 +00:00
andre 7dff44ae53 framework-pkcs15.c: In function ‘set_gost_params’:
framework-pkcs15.c:1892: warning: comparison between signed and unsigned
framework-pkcs15.c:1902: warning: comparison between signed and unsigned


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5529 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-31 15:09:01 +00:00
vtarasov a41a9c3f82 pkcs11: pkcs15 framework support for the import of the GOST key
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5522 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:35:34 +00:00
vtarasov 1dd7d1fdeb pkcs11: debug title for GOSTRPARAMS
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5519 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 18:07:18 +00:00
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 e4711a485e WindowsInstaller: don't link against winscard.lib, winscard.dll is loaded on runtime. Link minidriver against correct opensc.lib
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5427 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-05 14:03:36 +00:00
vtarasov dc55351767 pkcs11: hide empty slots ...
The list of slots returned by C_GetSlotList() contains:
 - if present, virtual hotplug slot;
 - any slot with token;
 - without token(s), one empty slot per reader;


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5421 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-04 07:17:28 +00:00
vtarasov 5e50a14b3f libopensc: introduce 'key-params' data type that contains pointer, size and 'free' handler ...
http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016441.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5413 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-01 19:18:14 +00:00
vtarasov 78d90c4765 EC support: introduce data type dedicated to EC parameters ...
EC parameters can be presented in a three forms: namedCurve, OID and implicit data.
This new data type will facilitate manipulation of ec-parameters in the OpenSC tools and library.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5386 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-22 13:08:45 +00:00
vtarasov 7db9532f00 pkcs11 framework-pkcs15: add EC key generation mechanism
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5384 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-21 16:29:13 +00:00
vtarasov 9758bb28bf pkcs11: copy&past issue in r5356
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5382 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-21 16:14:36 +00:00
vtarasov ef1726e782 pkcs11: process the EC key generation type
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5356 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-17 18:45:27 +00:00
vtarasov 3aae1d39c2 framework-pkcs15: minor coding style issues
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5342 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-15 16:35:29 +00:00
vtarasov 2fecaa73bd pkcs15init: introduce EC key generation parameters
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5332 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-12 11:36:40 +00:00
andre be2c17c7e9 pkcs11: Fixes leftover from r4646.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5313 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-08 13:50:02 +00:00
martin 8f4dfe2c85 Amend r5201: put libscdl.h/libpkcs11.h to distribution package and link against libltdl where needed.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5210 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-17 20:46:13 +00:00
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