Commit Graph

414 Commits

Author SHA1 Message Date
Nuno Goncalves 3635dbe78a pkcs11: remove redundant validation of PIN length
PIN length validation is done at pkcs15 layer and shall be done only there.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
Frank Morgner 24b7507a69 pkcs11: don't shrink the number of slots
... as required by PKCS#11 2.30, if the application doesn't call
`C_GetSlotList` with `NULL`.

Fixes ghost tokens in Firefox when detaching a reader that contained a
card.

Fixes https://github.com/OpenSC/OpenSC/issues/629
2017-01-09 08:35:42 +01:00
Frank Morgner 526ae18696 PKCS#11: Don't use ':' in the token name
Fixes https://github.com/OpenSC/OpenSC/issues/849
2016-09-01 01:25:29 +02:00
carblue 1ab99f3756 pkcs11-tool: in 4rd test use other signature keys
also increase signature buffer in framework-pkcs15

closes #814
2016-07-24 19:26:10 +02:00
Frank Morgner 2f10de4f5c use sc_pkcs15_get_pin_info in C_GetTokenInfo
introduced paramter to signal back the login state
- used for the pin command SC_PIN_CMD_GET_INFO
- implemented in accordance to ISO 7816-4; all other implementations
  are currently set to an unknown login state

implemented and exporeted sc_pkcs15_get_pin_info

use sc_pkcs15_get_pin_info in C_GetTokenInfo

C_GetSessionInfo: Check whether a logout was done

Closes https://github.com/OpenSC/OpenSC/pull/624

rebased by @viktorTarasov
2016-07-17 14:07:43 +02:00
Raul Metsma 22f9ad704a Move PIN type label front of description
With very long labels it is unable identify which PIN Firefox is asking.
PKCS11 label is 32 char's and it gets truncated.

Current format "LABEL (PIN1)"
New format "PIN1: LABEL"
2016-04-13 13:57:32 +03:00
Ludovic Rousseau 89ec66fbe8 framework-pkcs15.c: fix compiler warning
framework-pkcs15.c:706:1: warning: unused function
      '__pkcs15_create_secret_key_object' [-Wunused-function]
__pkcs15_create_secret_key_object(struct pkcs15_fw_data *fw_data,
^
2016-02-29 20:19:42 +01:00
Viktor Tarasov b8c3722bf5 pkcs11/framework: no more 'for-applications' mode for slot creation
Simplify create tokens rules, no need to manipulate applications in
'pkcs11' configuration part,
applications can be enabled/disabled on the 'pkcs15' one.

Fix the possibility to expose only 'sign' PIN
2016-02-24 13:39:27 +01:00
Frank Morgner 89f9d9e85d add compatibility implementation for strnlen
fixes https://github.com/OpenSC/OpenSC/issues/660
2016-01-20 10:47:27 +01:00
Frank Morgner e8d8f9f2bb Merge pull request #650 from vletoux/pkcs11-crash-when-read-public-key-fails
fix a pkcs11 crash when the public key reading fails

fixes #649
2016-01-06 07:30:15 +01:00
LE TOUX Vincent 6e5ae841eb fix a pkcs11 crash when the public key reading fails 2016-01-02 09:31:36 +01:00
Uri Blumenthal 76ed06981b Made sure attribute CKA_TOKEN is set to TRUE. 2015-12-22 13:31:42 -05:00
Uri Blumenthal 2b6b0ee05a According to PKCS#11 standard, public key should not have the
attribute CKA_SENSITIVE set to TRUE. This attribute is for
private and secret keys only.
2015-12-21 12:11:48 -05:00
Frank Morgner 5129c5a060 Fixed memory leaks 2015-12-09 08:22:45 +01:00
Frank Morgner 1046d951ba framework-pkcs15.c: fixed accessing label in sc_pkcs15_object_t 2015-10-04 17:33:14 +02:00
Frank Morgner d551f9a8e0 avoid registering pkcs11 mechanisms multiple times
fixes #349
2015-09-07 09:53:02 +02:00
Doug Engert b48fa70308 sc_pkcs11_card improvements
This is name change only fix.

    The variable name "card" was being used to refer to a struct sc_card or a struct sc_pkcs11_card
    in some files including sc_pkcs11.h. In other files the variable name "p11card" is used for struct sc_pkcs11_card.
    This creates hard to read code, such as: slot->card->card.

    All definitations of sc_pkcs11_card *card now use p11card as the variable name.

Fix #471
2015-05-24 11:41:29 +02:00
Philip Wendland 78e434da93 register EC mechanisms with flags independent of RSA flags
Prior to this commit, all hashes registered for RSA or other key types were
registered for ECDSA as well.

register ECDH mechanism only when supported by card

ECDH should only be registered if the card driver sets the
SC_ALGORITHM_ECDH_CDH_RAW flag.

register software PKCS#1 (1.5) padding only when RAW RSA is supported by card

If OpenSC supports PSS/OAEP padding or other padding mechanisms in
future, and there would be a card that enforces hardware PSS/OAEP
padding, the PKCS#1 v1.5 padding mechanism should not be registered.
2015-05-08 20:45:27 +02:00
Frank Morgner e338b7c1ab framework-pkcs15: fixed memory leak when encoding pubkey 2015-05-08 09:11:55 +02:00
Frank Morgner e84951a5bf fix resource leaks in while registering PKCS#11 mechanisms
introduces a free_mech_data for sc_pkcs11_mechanism_type_t to clear the
mechanisms private memory
2015-05-08 09:11:55 +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
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
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 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 17c1cffb3d Fix typo on CKF_EC_UNCOMPRESS 2015-01-20 23:14:50 -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 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
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
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
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 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 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
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
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
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
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
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
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
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 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 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
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
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 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
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 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
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 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 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 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 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 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
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
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
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
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 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 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
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 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
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
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
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
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 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
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 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 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
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 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